Commit df7cd2003220f72551a501eddd339fcaddbf886a
1 parent
2e7ee981
1.国际化查漏补缺
Showing
2 changed files
with
269 additions
and
269 deletions
src/main/resources/fatso/start.js
| 1 | -/** | ||
| 2 | - * @author PanZhao | ||
| 3 | - * @date 2016年3月17日 下午12:44:06 | ||
| 4 | - */ | ||
| 5 | -var fs = require('fs') | ||
| 6 | - , colors = require('colors') | ||
| 7 | - , child_process = require('child_process') | ||
| 8 | - , EventProxy = require('eventproxy') | ||
| 9 | - , parse = require('./parse') | ||
| 10 | - , minifier = require('./minifier') | ||
| 11 | - , crypto = require("crypto") | ||
| 12 | - , handle_real_ctl = require('./handle_real_ctl'); | ||
| 13 | - | ||
| 14 | - | ||
| 15 | -var platform = process.platform; | ||
| 16 | -var iswin = platform == 'win32'; | ||
| 17 | -var sp = platform == 'win32' ? '\\' : '/'; | ||
| 18 | -//不参与的目录 | ||
| 19 | -var excludes = ['scheduleApp', 'trafficManage', 'control', 'permission' + sp + 'authorize_all','permission' + sp + 'user', 'summary', 'history_sch', 'report' + sp + 'oil', 'base' + sp + 'geo_data_edit', 'base' + sp + 'carpark', 'forms', 'mforms', 'report', 'punctual', 'base' + sp + 'timesmodel', 'base' + sp + 'stationroute'] | ||
| 20 | - , ep = new EventProxy() | ||
| 21 | - , pName = 'bsth_control' | ||
| 22 | - , path = process.cwd() | ||
| 23 | - //根目录 | ||
| 24 | - , root = path.substr(0, path.indexOf(sp + 'src' + sp + 'main')) | ||
| 25 | - , workspace = root.substr(0, root.lastIndexOf(sp + pName)) | ||
| 26 | - //临时目录 | ||
| 27 | - , dest = (workspace + sp + pName + '@fatso_copy') | ||
| 28 | - , _static = sp + 'src' + sp + 'main' + sp + 'resources' + sp + 'static' | ||
| 29 | - , _pages = dest + _static + sp + 'pages'; | ||
| 30 | - | ||
| 31 | - | ||
| 32 | -//创建临时目录 | ||
| 33 | -fs.mkdir(dest, function (e) { | ||
| 34 | - if (e) | ||
| 35 | - logError('创建临时目录出错,请检查目录 ' + dest + '是否存在'); | ||
| 36 | - | ||
| 37 | - setTimeout(function () { | ||
| 38 | - ep.emit('mvn-clean'); | ||
| 39 | - }, 500); | ||
| 40 | -}); | ||
| 41 | -//子进程 | ||
| 42 | -var cProcess; | ||
| 43 | - | ||
| 44 | -ep.tail('mvn-clean', function () { | ||
| 45 | - //ep.emit('copy-project'); | ||
| 46 | - //清理target | ||
| 47 | - logInfo('mvn clean...'); | ||
| 48 | - cProcess = child_process.exec("mvn clean", {cwd: workspace + sp + pName}, function (error) { | ||
| 49 | - if (error) | ||
| 50 | - logError(error); | ||
| 51 | - | ||
| 52 | - logSuccess('mvn clean success'); | ||
| 53 | - | ||
| 54 | - ep.emit('copy-project'); | ||
| 55 | - }); | ||
| 56 | - output(cProcess); | ||
| 57 | -}); | ||
| 58 | - | ||
| 59 | -//复制项目副本 | ||
| 60 | -ep.tail('copy-project', function () { | ||
| 61 | - logInfo('copy project...'); | ||
| 62 | - var xcopyCom; | ||
| 63 | - if (iswin) | ||
| 64 | - xcopyCom = 'XCOPY ' + root.replace(/\//g, '\\') + ' ' + dest + ' /e /exclude:' + path + '\\exclude.txt'; | ||
| 65 | - else | ||
| 66 | - xcopyCom = 'cp -a ' + root + '/. ' + dest; | ||
| 67 | - | ||
| 68 | - cProcess = child_process.exec(xcopyCom, {cwd: workspace, maxBuffer: 5000 * 1024}, function (error) { | ||
| 69 | - if (error) | ||
| 70 | - logError(error); | ||
| 71 | - | ||
| 72 | - logSuccess('copy project success'); | ||
| 73 | - | ||
| 74 | - ep.emit('check-js'); | ||
| 75 | - }); | ||
| 76 | - //output(cProcess); | ||
| 77 | -}); | ||
| 78 | - | ||
| 79 | -//检查JS | ||
| 80 | -ep.tail('check-js', function () { | ||
| 81 | - ep.emit('minifier-js'); | ||
| 82 | -}); | ||
| 83 | - | ||
| 84 | -//合并压缩JS | ||
| 85 | -ep.tail('minifier-js', function () { | ||
| 86 | - logInfo('handle index.html...'); | ||
| 87 | - | ||
| 88 | - //再处理首页 | ||
| 89 | - ep.emit('handle-index', function () { | ||
| 90 | - //递归处理片段 | ||
| 91 | - walk(dest + _static + sp + 'pages', function (item) { | ||
| 92 | - ep.emit('handle-fragment', item); | ||
| 93 | - }, | ||
| 94 | - function () { | ||
| 95 | - //处理线调首页 | ||
| 96 | - handle_real_ctl.handleMain(function () { | ||
| 97 | - //处理线调地图 | ||
| 98 | - handle_real_ctl.handleMap(function () { | ||
| 99 | - //处理单屏地图页面 | ||
| 100 | - handle_real_ctl.handleAlonePage(function () { | ||
| 101 | - //处理单屏主页 | ||
| 102 | - handle_real_ctl.handleAloneHomePage(function () { | ||
| 103 | - ep.emit('package-jar'); | ||
| 104 | - }); | ||
| 105 | - }); | ||
| 106 | - }); | ||
| 107 | - }); | ||
| 108 | - }); | ||
| 109 | - }); | ||
| 110 | -}); | ||
| 111 | - | ||
| 112 | -//打包 | ||
| 113 | -ep.tail('package-jar', function (file) { | ||
| 114 | - var packageCom = 'mvn clean package -DskipTests'; | ||
| 115 | - cProcess = child_process.exec(packageCom, {maxBuffer: 5000 * 1024, cwd: dest}, function (error) { | ||
| 116 | - if (error) | ||
| 117 | - logError(error); | ||
| 118 | - | ||
| 119 | - logSuccess('mvn package success'); | ||
| 120 | - | ||
| 121 | - console.log(('成功打包在 ' + dest + sp + 'target 目录下').cyan); | ||
| 122 | - }); | ||
| 123 | - | ||
| 124 | - output(cProcess); | ||
| 125 | -}); | ||
| 126 | - | ||
| 127 | -//处理片段 | ||
| 128 | -ep.tail('handle-fragment', function (file) { | ||
| 129 | - //要排除的文件 | ||
| 130 | - for (var i = 0, ex; ex = excludes[i++];) { | ||
| 131 | - if (file.indexOf(_pages + sp + ex) != -1) | ||
| 132 | - return false; | ||
| 133 | - } | ||
| 134 | - handleJavascript(file, function (mini, $) { | ||
| 135 | - var jsMini; | ||
| 136 | - if (mini.inside) | ||
| 137 | - jsMini = '(function(){' + mini.inside + '\n' + mini.outside + '})();'; | ||
| 138 | - else | ||
| 139 | - jsMini = '(function(){' + mini.outside + '})();'; | ||
| 140 | - | ||
| 141 | - write(file, $.html() + '<script>' + jsMini + '</script>'); | ||
| 142 | - }); | ||
| 143 | - | ||
| 144 | -}); | ||
| 145 | - | ||
| 146 | -//处理首页 | ||
| 147 | -ep.tail('handle-index', function (cb) { | ||
| 148 | - var index = dest + _static + sp + 'index.html'; | ||
| 149 | - handleJavascript(index, function (mini, $) { | ||
| 150 | - var jsMiniText = mini.inside + mini.outside; | ||
| 151 | - | ||
| 152 | - var code = md5(jsMiniText); | ||
| 153 | - fs.open(dest + _static + sp + 'assets' + sp + 'js' + sp + code + '.js', 'a', function (err, fd) { | ||
| 154 | - if (err) | ||
| 155 | - logError(err); | ||
| 156 | - | ||
| 157 | - fs.write(fd, jsMiniText, function () { | ||
| 158 | - var ss = $('script'); | ||
| 159 | - | ||
| 160 | - $(ss[ss.length - 1]).before('<script src="/assets/js/' + code + '.js"></script>\n'); | ||
| 161 | - for (var i = 0, s; s = ss[i++];) { | ||
| 162 | - $(s).removeAttr('data-exclude') | ||
| 163 | - .removeAttr('flag') | ||
| 164 | - .removeAttr('data-autocephaly'); | ||
| 165 | - } | ||
| 166 | - write(index, $.html()); | ||
| 167 | - | ||
| 168 | - cb && cb(); | ||
| 169 | - }); | ||
| 170 | - }); | ||
| 171 | - }); | ||
| 172 | -}); | ||
| 173 | - | ||
| 174 | - | ||
| 175 | -function handleJavascript(item, cb) { | ||
| 176 | - //解析页面 | ||
| 177 | - var htmlResult = parse.html(item, dest + _static) | ||
| 178 | - , jsArray = htmlResult.jsArray | ||
| 179 | - , $ = htmlResult.$ | ||
| 180 | - , scrStr = htmlResult.scriptString; | ||
| 181 | - | ||
| 182 | - //合并压缩 | ||
| 183 | - var mini = minifier.mergeAndMini(jsArray, scrStr, dest + _static, item); | ||
| 184 | - | ||
| 185 | - cb && cb(mini, $); | ||
| 186 | -} | ||
| 187 | - | ||
| 188 | -function removeJsLink(s, e) { | ||
| 189 | - var newArray = [], flag; | ||
| 190 | - | ||
| 191 | - for (var i = 0, si; si = s[i++];) { | ||
| 192 | - flag = 0; | ||
| 193 | - for (var j = 0, ei; ei = e[j++];) { | ||
| 194 | - if (si.indexOf(ei) != -1) { | ||
| 195 | - flag = -1; | ||
| 196 | - break; | ||
| 197 | - } | ||
| 198 | - } | ||
| 199 | - | ||
| 200 | - if (flag == 0) { | ||
| 201 | - newArray.push(si); | ||
| 202 | - } | ||
| 203 | - } | ||
| 204 | - return newArray; | ||
| 205 | -} | ||
| 206 | - | ||
| 207 | -function write(file, text) { | ||
| 208 | - fs.writeFile(file, text, function (err) { | ||
| 209 | - if (err) { | ||
| 210 | - console.log(err.toString().red); | ||
| 211 | - process.exit(); | ||
| 212 | - } | ||
| 213 | - //console.log(file.green); | ||
| 214 | - }); | ||
| 215 | -} | ||
| 216 | - | ||
| 217 | -function md5(text) { | ||
| 218 | - return crypto.createHash("md5").update(text).digest("hex"); | ||
| 219 | -} | ||
| 220 | - | ||
| 221 | - | ||
| 222 | -function walk(path, handleFile, over) { | ||
| 223 | - fs.readdir(path, function (err, files) { | ||
| 224 | - if (err) { | ||
| 225 | - console.log('read dir error'.red); | ||
| 226 | - } else { | ||
| 227 | - files.forEach(function (item) { | ||
| 228 | - var tmpPath = path + sp + item; | ||
| 229 | - fs.stat(tmpPath, function (err1, stats) { | ||
| 230 | - if (err1) { | ||
| 231 | - console.log('stat error'); | ||
| 232 | - } else { | ||
| 233 | - if (stats.isDirectory()) { | ||
| 234 | - walk(tmpPath, handleFile); | ||
| 235 | - } else if (item.indexOf('.html') != -1) { | ||
| 236 | - handleFile(tmpPath); | ||
| 237 | - } | ||
| 238 | - } | ||
| 239 | - }) | ||
| 240 | - }); | ||
| 241 | - | ||
| 242 | - over && over(); | ||
| 243 | - } | ||
| 244 | - }); | ||
| 245 | -} | ||
| 246 | - | ||
| 247 | -function logInfo(t) { | ||
| 248 | - console.log(t); | ||
| 249 | -} | ||
| 250 | - | ||
| 251 | -function logSuccess(t) { | ||
| 252 | - console.log(t.green); | ||
| 253 | -} | ||
| 254 | - | ||
| 255 | -function logError(e) { | ||
| 256 | - console.log(e.toString().red); | ||
| 257 | - process.exit(); | ||
| 258 | -} | ||
| 259 | - | ||
| 260 | -function output(cProcess) { | ||
| 261 | - //标准输出 | ||
| 262 | - cProcess.stdout.on('data', function (s) { | ||
| 263 | - console.log(s); | ||
| 264 | - }); | 1 | +/** |
| 2 | + * @author PanZhao | ||
| 3 | + * @date 2016年3月17日 下午12:44:06 | ||
| 4 | + */ | ||
| 5 | +var fs = require('fs') | ||
| 6 | + , colors = require('colors') | ||
| 7 | + , child_process = require('child_process') | ||
| 8 | + , EventProxy = require('eventproxy') | ||
| 9 | + , parse = require('./parse') | ||
| 10 | + , minifier = require('./minifier') | ||
| 11 | + , crypto = require("crypto") | ||
| 12 | + , handle_real_ctl = require('./handle_real_ctl'); | ||
| 13 | + | ||
| 14 | + | ||
| 15 | +var platform = process.platform; | ||
| 16 | +var iswin = platform == 'win32'; | ||
| 17 | +var sp = platform == 'win32' ? '\\' : '/'; | ||
| 18 | +//不参与的目录 | ||
| 19 | +var excludes = ['scheduleApp', 'trafficManage', 'control', 'permission' + sp + 'authorize_all','permission' + sp + 'user', 'summary', 'history_sch', 'report' + sp + 'oil', 'base' + sp + 'geo_data_edit', 'base' + sp + 'carpark', 'forms', 'mforms', 'report', 'punctual', 'base' + sp + 'timesmodel', 'base' + sp + 'stationroute', 'kl', 'dsm'] | ||
| 20 | + , ep = new EventProxy() | ||
| 21 | + , pName = 'bsth_control' | ||
| 22 | + , path = process.cwd() | ||
| 23 | + //根目录 | ||
| 24 | + , root = path.substr(0, path.indexOf(sp + 'src' + sp + 'main')) | ||
| 25 | + , workspace = root.substr(0, root.lastIndexOf(sp + pName)) | ||
| 26 | + //临时目录 | ||
| 27 | + , dest = (workspace + sp + pName + '@fatso_copy') | ||
| 28 | + , _static = sp + 'src' + sp + 'main' + sp + 'resources' + sp + 'static' | ||
| 29 | + , _pages = dest + _static + sp + 'pages'; | ||
| 30 | + | ||
| 31 | + | ||
| 32 | +//创建临时目录 | ||
| 33 | +fs.mkdir(dest, function (e) { | ||
| 34 | + if (e) | ||
| 35 | + logError('创建临时目录出错,请检查目录 ' + dest + '是否存在'); | ||
| 36 | + | ||
| 37 | + setTimeout(function () { | ||
| 38 | + ep.emit('mvn-clean'); | ||
| 39 | + }, 500); | ||
| 40 | +}); | ||
| 41 | +//子进程 | ||
| 42 | +var cProcess; | ||
| 43 | + | ||
| 44 | +ep.tail('mvn-clean', function () { | ||
| 45 | + //ep.emit('copy-project'); | ||
| 46 | + //清理target | ||
| 47 | + logInfo('mvn clean...'); | ||
| 48 | + cProcess = child_process.exec("mvn clean", {cwd: workspace + sp + pName}, function (error) { | ||
| 49 | + if (error) | ||
| 50 | + logError(error); | ||
| 51 | + | ||
| 52 | + logSuccess('mvn clean success'); | ||
| 53 | + | ||
| 54 | + ep.emit('copy-project'); | ||
| 55 | + }); | ||
| 56 | + output(cProcess); | ||
| 57 | +}); | ||
| 58 | + | ||
| 59 | +//复制项目副本 | ||
| 60 | +ep.tail('copy-project', function () { | ||
| 61 | + logInfo('copy project...'); | ||
| 62 | + var xcopyCom; | ||
| 63 | + if (iswin) | ||
| 64 | + xcopyCom = 'XCOPY ' + root.replace(/\//g, '\\') + ' ' + dest + ' /e /exclude:' + path + '\\exclude.txt'; | ||
| 65 | + else | ||
| 66 | + xcopyCom = 'cp -a ' + root + '/. ' + dest; | ||
| 67 | + | ||
| 68 | + cProcess = child_process.exec(xcopyCom, {cwd: workspace, maxBuffer: 5000 * 1024}, function (error) { | ||
| 69 | + if (error) | ||
| 70 | + logError(error); | ||
| 71 | + | ||
| 72 | + logSuccess('copy project success'); | ||
| 73 | + | ||
| 74 | + ep.emit('check-js'); | ||
| 75 | + }); | ||
| 76 | + //output(cProcess); | ||
| 77 | +}); | ||
| 78 | + | ||
| 79 | +//检查JS | ||
| 80 | +ep.tail('check-js', function () { | ||
| 81 | + ep.emit('minifier-js'); | ||
| 82 | +}); | ||
| 83 | + | ||
| 84 | +//合并压缩JS | ||
| 85 | +ep.tail('minifier-js', function () { | ||
| 86 | + logInfo('handle index.html...'); | ||
| 87 | + | ||
| 88 | + //再处理首页 | ||
| 89 | + ep.emit('handle-index', function () { | ||
| 90 | + //递归处理片段 | ||
| 91 | + walk(dest + _static + sp + 'pages', function (item) { | ||
| 92 | + ep.emit('handle-fragment', item); | ||
| 93 | + }, | ||
| 94 | + function () { | ||
| 95 | + //处理线调首页 | ||
| 96 | + handle_real_ctl.handleMain(function () { | ||
| 97 | + //处理线调地图 | ||
| 98 | + handle_real_ctl.handleMap(function () { | ||
| 99 | + //处理单屏地图页面 | ||
| 100 | + handle_real_ctl.handleAlonePage(function () { | ||
| 101 | + //处理单屏主页 | ||
| 102 | + handle_real_ctl.handleAloneHomePage(function () { | ||
| 103 | + ep.emit('package-jar'); | ||
| 104 | + }); | ||
| 105 | + }); | ||
| 106 | + }); | ||
| 107 | + }); | ||
| 108 | + }); | ||
| 109 | + }); | ||
| 110 | +}); | ||
| 111 | + | ||
| 112 | +//打包 | ||
| 113 | +ep.tail('package-jar', function (file) { | ||
| 114 | + var packageCom = 'mvn clean package -DskipTests'; | ||
| 115 | + cProcess = child_process.exec(packageCom, {maxBuffer: 5000 * 1024, cwd: dest}, function (error) { | ||
| 116 | + if (error) | ||
| 117 | + logError(error); | ||
| 118 | + | ||
| 119 | + logSuccess('mvn package success'); | ||
| 120 | + | ||
| 121 | + console.log(('成功打包在 ' + dest + sp + 'target 目录下').cyan); | ||
| 122 | + }); | ||
| 123 | + | ||
| 124 | + output(cProcess); | ||
| 125 | +}); | ||
| 126 | + | ||
| 127 | +//处理片段 | ||
| 128 | +ep.tail('handle-fragment', function (file) { | ||
| 129 | + //要排除的文件 | ||
| 130 | + for (var i = 0, ex; ex = excludes[i++];) { | ||
| 131 | + if (file.indexOf(_pages + sp + ex) != -1) | ||
| 132 | + return false; | ||
| 133 | + } | ||
| 134 | + handleJavascript(file, function (mini, $) { | ||
| 135 | + var jsMini; | ||
| 136 | + if (mini.inside) | ||
| 137 | + jsMini = '(function(){' + mini.inside + '\n' + mini.outside + '})();'; | ||
| 138 | + else | ||
| 139 | + jsMini = '(function(){' + mini.outside + '})();'; | ||
| 140 | + | ||
| 141 | + write(file, $.html() + '<script>' + jsMini + '</script>'); | ||
| 142 | + }); | ||
| 143 | + | ||
| 144 | +}); | ||
| 145 | + | ||
| 146 | +//处理首页 | ||
| 147 | +ep.tail('handle-index', function (cb) { | ||
| 148 | + var index = dest + _static + sp + 'index.html'; | ||
| 149 | + handleJavascript(index, function (mini, $) { | ||
| 150 | + var jsMiniText = mini.inside + mini.outside; | ||
| 151 | + | ||
| 152 | + var code = md5(jsMiniText); | ||
| 153 | + fs.open(dest + _static + sp + 'assets' + sp + 'js' + sp + code + '.js', 'a', function (err, fd) { | ||
| 154 | + if (err) | ||
| 155 | + logError(err); | ||
| 156 | + | ||
| 157 | + fs.write(fd, jsMiniText, function () { | ||
| 158 | + var ss = $('script'); | ||
| 159 | + | ||
| 160 | + $(ss[ss.length - 1]).before('<script src="/assets/js/' + code + '.js"></script>\n'); | ||
| 161 | + for (var i = 0, s; s = ss[i++];) { | ||
| 162 | + $(s).removeAttr('data-exclude') | ||
| 163 | + .removeAttr('flag') | ||
| 164 | + .removeAttr('data-autocephaly'); | ||
| 165 | + } | ||
| 166 | + write(index, $.html()); | ||
| 167 | + | ||
| 168 | + cb && cb(); | ||
| 169 | + }); | ||
| 170 | + }); | ||
| 171 | + }); | ||
| 172 | +}); | ||
| 173 | + | ||
| 174 | + | ||
| 175 | +function handleJavascript(item, cb) { | ||
| 176 | + //解析页面 | ||
| 177 | + var htmlResult = parse.html(item, dest + _static) | ||
| 178 | + , jsArray = htmlResult.jsArray | ||
| 179 | + , $ = htmlResult.$ | ||
| 180 | + , scrStr = htmlResult.scriptString; | ||
| 181 | + | ||
| 182 | + //合并压缩 | ||
| 183 | + var mini = minifier.mergeAndMini(jsArray, scrStr, dest + _static, item); | ||
| 184 | + | ||
| 185 | + cb && cb(mini, $); | ||
| 186 | +} | ||
| 187 | + | ||
| 188 | +function removeJsLink(s, e) { | ||
| 189 | + var newArray = [], flag; | ||
| 190 | + | ||
| 191 | + for (var i = 0, si; si = s[i++];) { | ||
| 192 | + flag = 0; | ||
| 193 | + for (var j = 0, ei; ei = e[j++];) { | ||
| 194 | + if (si.indexOf(ei) != -1) { | ||
| 195 | + flag = -1; | ||
| 196 | + break; | ||
| 197 | + } | ||
| 198 | + } | ||
| 199 | + | ||
| 200 | + if (flag == 0) { | ||
| 201 | + newArray.push(si); | ||
| 202 | + } | ||
| 203 | + } | ||
| 204 | + return newArray; | ||
| 205 | +} | ||
| 206 | + | ||
| 207 | +function write(file, text) { | ||
| 208 | + fs.writeFile(file, text, function (err) { | ||
| 209 | + if (err) { | ||
| 210 | + console.log(err.toString().red); | ||
| 211 | + process.exit(); | ||
| 212 | + } | ||
| 213 | + //console.log(file.green); | ||
| 214 | + }); | ||
| 215 | +} | ||
| 216 | + | ||
| 217 | +function md5(text) { | ||
| 218 | + return crypto.createHash("md5").update(text).digest("hex"); | ||
| 219 | +} | ||
| 220 | + | ||
| 221 | + | ||
| 222 | +function walk(path, handleFile, over) { | ||
| 223 | + fs.readdir(path, function (err, files) { | ||
| 224 | + if (err) { | ||
| 225 | + console.log('read dir error'.red); | ||
| 226 | + } else { | ||
| 227 | + files.forEach(function (item) { | ||
| 228 | + var tmpPath = path + sp + item; | ||
| 229 | + fs.stat(tmpPath, function (err1, stats) { | ||
| 230 | + if (err1) { | ||
| 231 | + console.log('stat error'); | ||
| 232 | + } else { | ||
| 233 | + if (stats.isDirectory()) { | ||
| 234 | + walk(tmpPath, handleFile); | ||
| 235 | + } else if (item.indexOf('.html') != -1) { | ||
| 236 | + handleFile(tmpPath); | ||
| 237 | + } | ||
| 238 | + } | ||
| 239 | + }) | ||
| 240 | + }); | ||
| 241 | + | ||
| 242 | + over && over(); | ||
| 243 | + } | ||
| 244 | + }); | ||
| 245 | +} | ||
| 246 | + | ||
| 247 | +function logInfo(t) { | ||
| 248 | + console.log(t); | ||
| 249 | +} | ||
| 250 | + | ||
| 251 | +function logSuccess(t) { | ||
| 252 | + console.log(t.green); | ||
| 253 | +} | ||
| 254 | + | ||
| 255 | +function logError(e) { | ||
| 256 | + console.log(e.toString().red); | ||
| 257 | + process.exit(); | ||
| 258 | +} | ||
| 259 | + | ||
| 260 | +function output(cProcess) { | ||
| 261 | + //标准输出 | ||
| 262 | + cProcess.stdout.on('data', function (s) { | ||
| 263 | + console.log(s); | ||
| 264 | + }); | ||
| 265 | } | 265 | } |
| 266 | \ No newline at end of file | 266 | \ No newline at end of file |
src/main/resources/static/pages/base/section/js/add-vmap-world.js
| @@ -80,14 +80,14 @@ var SectionVmapWorlds = function() { | @@ -80,14 +80,14 @@ var SectionVmapWorlds = function() { | ||
| 80 | }, | 80 | }, |
| 81 | // 根据名称获取坐标. | 81 | // 根据名称获取坐标. |
| 82 | sectionsNameToPoints : function(sectionNames, callback) { | 82 | sectionsNameToPoints : function(sectionNames, callback) { |
| 83 | - var arguments = new Array(); | 83 | + var args = new Array(); |
| 84 | for (var i = 0;i < sectionNames.length;i++) { | 84 | for (var i = 0;i < sectionNames.length;i++) { |
| 85 | - arguments.push('searchComplete' + i); | 85 | + args.push('searchComplete' + i); |
| 86 | } | 86 | } |
| 87 | - arguments.push(function(... args) { | ||
| 88 | - callback(args); | 87 | + args.push(function() { |
| 88 | + callback(arguments); | ||
| 89 | }) | 89 | }) |
| 90 | - var proxy = EventProxy.create(arguments); | 90 | + var proxy = EventProxy.create(args); |
| 91 | sectionNames.forEach(function(item, idx) { | 91 | sectionNames.forEach(function(item, idx) { |
| 92 | var localSearch = new BMap.LocalSearch(mapB); | 92 | var localSearch = new BMap.LocalSearch(mapB); |
| 93 | localSearch.setSearchCompleteCallback(function (searchResult) { | 93 | localSearch.setSearchCompleteCallback(function (searchResult) { |