Commit 303a3846a46725f6dc4d0bb1872d21f183833bee
1 parent
440454e4
update...
Showing
3 changed files
with
46 additions
and
30 deletions
src/main/resources/fatso/handle_real_ctl.js
| ... | ... | @@ -11,32 +11,34 @@ var fs = require('fs') |
| 11 | 11 | |
| 12 | 12 | var platform = process.platform; |
| 13 | 13 | var iswin = platform=='win32'; |
| 14 | -var separator = platform=='win32'?'\\':'/'; | |
| 14 | +var sp = platform=='win32'?'\\':'/'; | |
| 15 | 15 | //不参与的目录 |
| 16 | 16 | var pName = 'bsth_control' |
| 17 | 17 | , path = process.cwd() |
| 18 | 18 | //根目录 |
| 19 | - , root = path.substr(0, path.indexOf(separator + 'src'+separator+'main')) | |
| 20 | - , workspace = root.substr(0, root.lastIndexOf(separator + pName)) | |
| 19 | + , root = path.substr(0, path.indexOf(sp + 'src'+sp+'main')) | |
| 20 | + , workspace = root.substr(0, root.lastIndexOf(sp + pName)) | |
| 21 | 21 | //临时目录 |
| 22 | - , dest = (workspace + separator + pName + '@fatso_copy')//.replace(/\//g, '\\') | |
| 23 | - , _static = separator + 'src'+separator+'main'+separator+'resources'+separator+'static'; | |
| 22 | + , dest = (workspace + sp + pName + '@fatso_copy')//.replace(/\//g, '\\') | |
| 23 | + , _static = sp + 'src'+sp+'main'+sp+'resources'+sp+'static'; | |
| 24 | 24 | |
| 25 | 25 | |
| 26 | -var mainFile = dest + _static + separator + 'real_control_v2'+separator+'main.html'; | |
| 27 | -var mapFile = dest + _static + separator + 'real_control_v2'+separator+'mapmonitor'+separator+'real.html'; | |
| 26 | +var mainFile = dest + _static + sp + 'real_control_v2'+sp+'main.html'; | |
| 27 | +var aloneMapWrapFile = dest + _static + sp + 'real_control_v2'+sp+'alone_page'+sp+'map'+sp+'alone_wrap.html'; | |
| 28 | +var mapFile = dest + _static + sp + 'real_control_v2'+sp+'mapmonitor'+sp+'real.html'; | |
| 28 | 29 | var realCtl = { |
| 29 | 30 | /** |
| 30 | 31 | * 处理线调首页 |
| 31 | 32 | */ |
| 32 | 33 | handleMain: function (cb) { |
| 33 | - //读取文件 | |
| 34 | - var data = fs.readFileSync(mainFile, 'utf-8') | |
| 35 | - , $ = cheerio.load(data); | |
| 36 | - | |
| 34 | + //处理main.html | |
| 35 | + var data = fs.readFileSync(mainFile, 'utf-8'), | |
| 36 | + $ = cheerio.load(data); | |
| 37 | 37 | handleCss($, function () { |
| 38 | 38 | handleJs($, mainFile, cb); |
| 39 | 39 | }); |
| 40 | + | |
| 41 | + | |
| 40 | 42 | }, |
| 41 | 43 | /** |
| 42 | 44 | * 处理地图模块 |
| ... | ... | @@ -50,6 +52,17 @@ var realCtl = { |
| 50 | 52 | handleCss($, function () { |
| 51 | 53 | handleJs($, mapFile, cb); |
| 52 | 54 | }); |
| 55 | + }, | |
| 56 | + /** | |
| 57 | + * 处理单屏地图页面 | |
| 58 | + * @param cb | |
| 59 | + */ | |
| 60 | + handleAlonePage: function (cb) { | |
| 61 | + var data = fs.readFileSync(aloneMapWrapFile, 'utf-8'); | |
| 62 | + var $ = cheerio.load(data); | |
| 63 | + handleCss($, function () { | |
| 64 | + handleJs($, aloneMapWrapFile, cb); | |
| 65 | + }); | |
| 53 | 66 | } |
| 54 | 67 | }; |
| 55 | 68 | |
| ... | ... | @@ -84,7 +97,7 @@ var handleCss = function ($, cb) { |
| 84 | 97 | var data = out.styles; |
| 85 | 98 | var fName = (k + '_' + md5(data)) + '.css'; |
| 86 | 99 | //写入 assets css 目录下 |
| 87 | - var descFile = dest + _static + separator + 'real_control_v2'+separator+'assets'+separator+'css' + separator + fName; | |
| 100 | + var descFile = dest + _static + sp + 'real_control_v2'+sp+'assets'+sp+'css' + sp + fName; | |
| 88 | 101 | fs.open(descFile, 'a', function (err, fd) { |
| 89 | 102 | |
| 90 | 103 | fs.write(fd, data, function () { |
| ... | ... | @@ -138,7 +151,7 @@ var handleJs = function ($, file, cb) { |
| 138 | 151 | var data = result.code; |
| 139 | 152 | var fName = (k + '_' + md5(data)) + '.js'; |
| 140 | 153 | //写入 assets js 目录下 |
| 141 | - var descFile = dest + _static + separator + 'real_control_v2'+separator+'assets'+separator+'js' + separator + fName; | |
| 154 | + var descFile = dest + _static + sp + 'real_control_v2'+sp+'assets'+sp+'js' + sp + fName; | |
| 142 | 155 | fs.open(descFile, 'a', function (err, fd) { |
| 143 | 156 | |
| 144 | 157 | fs.write(fd, data, function () { | ... | ... |
src/main/resources/fatso/parse.js
src/main/resources/fatso/start.js
| ... | ... | @@ -14,19 +14,19 @@ var fs = require('fs') |
| 14 | 14 | |
| 15 | 15 | var platform = process.platform; |
| 16 | 16 | var iswin = platform=='win32'; |
| 17 | -var separator = platform=='win32'?'\\':'/'; | |
| 17 | +var sp = platform=='win32'?'\\':'/'; | |
| 18 | 18 | //不参与的目录 |
| 19 | -var excludes = ['scheduleApp', 'trafficManage', 'control', 'permission'+separator+'authorize_all', 'summary'] | |
| 19 | +var excludes = ['scheduleApp', 'trafficManage', 'control', 'permission'+sp+'authorize_all', 'summary', 'report'+sp+'oil'] | |
| 20 | 20 | ,ep = new EventProxy() |
| 21 | 21 | ,pName = 'bsth_control' |
| 22 | 22 | ,path = process.cwd() |
| 23 | 23 | //根目录 |
| 24 | - ,root = path.substr(0, path.indexOf(separator + 'src'+separator+'main')) | |
| 25 | - ,workspace = root.substr(0, root.lastIndexOf(separator + pName)) | |
| 24 | + ,root = path.substr(0, path.indexOf(sp + 'src'+sp+'main')) | |
| 25 | + ,workspace = root.substr(0, root.lastIndexOf(sp + pName)) | |
| 26 | 26 | //临时目录 |
| 27 | - ,dest = (workspace + separator + pName+'@fatso_copy') | |
| 28 | - ,_static = separator + 'src'+separator+'main'+separator+'resources'+separator+'static' | |
| 29 | - ,_pages = dest + _static + separator + 'pages'; | |
| 27 | + ,dest = (workspace + sp + pName+'@fatso_copy') | |
| 28 | + ,_static = sp + 'src'+sp+'main'+sp+'resources'+sp+'static' | |
| 29 | + ,_pages = dest + _static + sp + 'pages'; | |
| 30 | 30 | |
| 31 | 31 | |
| 32 | 32 | //创建临时目录 |
| ... | ... | @@ -45,7 +45,7 @@ ep.tail('mvn-clean',function(){ |
| 45 | 45 | //ep.emit('copy-project'); |
| 46 | 46 | //清理target |
| 47 | 47 | logInfo('mvn clean...'); |
| 48 | - cProcess = child_process.exec("mvn clean",{cwd: workspace + separator + pName},function(error){ | |
| 48 | + cProcess = child_process.exec("mvn clean",{cwd: workspace + sp + pName},function(error){ | |
| 49 | 49 | if(error) |
| 50 | 50 | logError(error); |
| 51 | 51 | |
| ... | ... | @@ -88,7 +88,7 @@ ep.tail('minifier-js', function(){ |
| 88 | 88 | //再处理首页 |
| 89 | 89 | ep.emit('handle-index', function(){ |
| 90 | 90 | //递归处理片段 |
| 91 | - walk(dest + _static + separator + 'pages', function(item){ | |
| 91 | + walk(dest + _static + sp + 'pages', function(item){ | |
| 92 | 92 | ep.emit('handle-fragment', item); |
| 93 | 93 | }, |
| 94 | 94 | function(){ |
| ... | ... | @@ -96,7 +96,10 @@ ep.tail('minifier-js', function(){ |
| 96 | 96 | handle_real_ctl.handleMain(function () { |
| 97 | 97 | //处理线调地图 |
| 98 | 98 | handle_real_ctl.handleMap(function () { |
| 99 | - ep.emit('package-jar'); | |
| 99 | + //处理单屏页面 | |
| 100 | + handle_real_ctl.handleAlonePage(function () { | |
| 101 | + ep.emit('package-jar'); | |
| 102 | + }); | |
| 100 | 103 | }); |
| 101 | 104 | }); |
| 102 | 105 | }); |
| ... | ... | @@ -112,7 +115,7 @@ ep.tail('package-jar', function(file){ |
| 112 | 115 | |
| 113 | 116 | logSuccess('mvn package success'); |
| 114 | 117 | |
| 115 | - console.log(('成功打包在 ' + dest + separator + 'target 目录下').cyan); | |
| 118 | + console.log(('成功打包在 ' + dest + sp + 'target 目录下').cyan); | |
| 116 | 119 | }); |
| 117 | 120 | |
| 118 | 121 | output(cProcess); |
| ... | ... | @@ -122,7 +125,7 @@ ep.tail('package-jar', function(file){ |
| 122 | 125 | ep.tail('handle-fragment', function(file){ |
| 123 | 126 | //要排除的文件 |
| 124 | 127 | for(var i = 0, ex; ex = excludes[i++];){ |
| 125 | - if(file.indexOf(_pages + separator + ex) != -1) | |
| 128 | + if(file.indexOf(_pages + sp + ex) != -1) | |
| 126 | 129 | return false; |
| 127 | 130 | } |
| 128 | 131 | handleJavascript(file, function(mini, $){ |
| ... | ... | @@ -139,12 +142,12 @@ ep.tail('handle-fragment', function(file){ |
| 139 | 142 | |
| 140 | 143 | //处理首页 |
| 141 | 144 | ep.tail('handle-index', function(cb){ |
| 142 | - var index = dest + _static + separator + 'index.html'; | |
| 145 | + var index = dest + _static + sp + 'index.html'; | |
| 143 | 146 | handleJavascript(index, function(mini, $){ |
| 144 | 147 | var jsMiniText = mini.inside + mini.outside; |
| 145 | 148 | |
| 146 | 149 | var code = md5(jsMiniText); |
| 147 | - fs.open( dest + _static + separator + 'assets'+separator+'js' + separator + code + '.js', 'a', function(err, fd){ | |
| 150 | + fs.open( dest + _static + sp + 'assets'+sp+'js' + sp + code + '.js', 'a', function(err, fd){ | |
| 148 | 151 | if(err) |
| 149 | 152 | logError(err); |
| 150 | 153 | |
| ... | ... | @@ -204,7 +207,7 @@ function write(file, text){ |
| 204 | 207 | console.log(err.toString().red); |
| 205 | 208 | process.exit(); |
| 206 | 209 | } |
| 207 | - console.log(file.green); | |
| 210 | + //console.log(file.green); | |
| 208 | 211 | }); |
| 209 | 212 | } |
| 210 | 213 | |
| ... | ... | @@ -219,7 +222,7 @@ function walk(path ,handleFile, over) { |
| 219 | 222 | console.log('read dir error'.red); |
| 220 | 223 | } else { |
| 221 | 224 | files.forEach(function(item) { |
| 222 | - var tmpPath = path + separator + item; | |
| 225 | + var tmpPath = path + sp + item; | |
| 223 | 226 | fs.stat(tmpPath, function(err1, stats) { |
| 224 | 227 | if (err1) { |
| 225 | 228 | console.log('stat error'); | ... | ... |