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,32 +11,34 @@ var fs = require('fs') | ||
| 11 | 11 | ||
| 12 | var platform = process.platform; | 12 | var platform = process.platform; |
| 13 | var iswin = platform=='win32'; | 13 | var iswin = platform=='win32'; |
| 14 | -var separator = platform=='win32'?'\\':'/'; | 14 | +var sp = platform=='win32'?'\\':'/'; |
| 15 | //不参与的目录 | 15 | //不参与的目录 |
| 16 | var pName = 'bsth_control' | 16 | var pName = 'bsth_control' |
| 17 | , path = process.cwd() | 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 | var realCtl = { | 29 | var realCtl = { |
| 29 | /** | 30 | /** |
| 30 | * 处理线调首页 | 31 | * 处理线调首页 |
| 31 | */ | 32 | */ |
| 32 | handleMain: function (cb) { | 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 | handleCss($, function () { | 37 | handleCss($, function () { |
| 38 | handleJs($, mainFile, cb); | 38 | handleJs($, mainFile, cb); |
| 39 | }); | 39 | }); |
| 40 | + | ||
| 41 | + | ||
| 40 | }, | 42 | }, |
| 41 | /** | 43 | /** |
| 42 | * 处理地图模块 | 44 | * 处理地图模块 |
| @@ -50,6 +52,17 @@ var realCtl = { | @@ -50,6 +52,17 @@ var realCtl = { | ||
| 50 | handleCss($, function () { | 52 | handleCss($, function () { |
| 51 | handleJs($, mapFile, cb); | 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,7 +97,7 @@ var handleCss = function ($, cb) { | ||
| 84 | var data = out.styles; | 97 | var data = out.styles; |
| 85 | var fName = (k + '_' + md5(data)) + '.css'; | 98 | var fName = (k + '_' + md5(data)) + '.css'; |
| 86 | //写入 assets css 目录下 | 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 | fs.open(descFile, 'a', function (err, fd) { | 101 | fs.open(descFile, 'a', function (err, fd) { |
| 89 | 102 | ||
| 90 | fs.write(fd, data, function () { | 103 | fs.write(fd, data, function () { |
| @@ -138,7 +151,7 @@ var handleJs = function ($, file, cb) { | @@ -138,7 +151,7 @@ var handleJs = function ($, file, cb) { | ||
| 138 | var data = result.code; | 151 | var data = result.code; |
| 139 | var fName = (k + '_' + md5(data)) + '.js'; | 152 | var fName = (k + '_' + md5(data)) + '.js'; |
| 140 | //写入 assets js 目录下 | 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 | fs.open(descFile, 'a', function (err, fd) { | 155 | fs.open(descFile, 'a', function (err, fd) { |
| 143 | 156 | ||
| 144 | fs.write(fd, data, function () { | 157 | fs.write(fd, data, function () { |
src/main/resources/fatso/parse.js
| @@ -64,7 +64,7 @@ function write(file, text){ | @@ -64,7 +64,7 @@ function write(file, text){ | ||
| 64 | console.log(err.toString().red); | 64 | console.log(err.toString().red); |
| 65 | process.exit(); | 65 | process.exit(); |
| 66 | } | 66 | } |
| 67 | - console.log(file.green); | 67 | + //console.log(file.green); |
| 68 | }); | 68 | }); |
| 69 | } | 69 | } |
| 70 | 70 |
src/main/resources/fatso/start.js
| @@ -14,19 +14,19 @@ var fs = require('fs') | @@ -14,19 +14,19 @@ var fs = require('fs') | ||
| 14 | 14 | ||
| 15 | var platform = process.platform; | 15 | var platform = process.platform; |
| 16 | var iswin = platform=='win32'; | 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 | ,ep = new EventProxy() | 20 | ,ep = new EventProxy() |
| 21 | ,pName = 'bsth_control' | 21 | ,pName = 'bsth_control' |
| 22 | ,path = process.cwd() | 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,7 +45,7 @@ ep.tail('mvn-clean',function(){ | ||
| 45 | //ep.emit('copy-project'); | 45 | //ep.emit('copy-project'); |
| 46 | //清理target | 46 | //清理target |
| 47 | logInfo('mvn clean...'); | 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 | if(error) | 49 | if(error) |
| 50 | logError(error); | 50 | logError(error); |
| 51 | 51 | ||
| @@ -88,7 +88,7 @@ ep.tail('minifier-js', function(){ | @@ -88,7 +88,7 @@ ep.tail('minifier-js', function(){ | ||
| 88 | //再处理首页 | 88 | //再处理首页 |
| 89 | ep.emit('handle-index', function(){ | 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 | ep.emit('handle-fragment', item); | 92 | ep.emit('handle-fragment', item); |
| 93 | }, | 93 | }, |
| 94 | function(){ | 94 | function(){ |
| @@ -96,7 +96,10 @@ ep.tail('minifier-js', function(){ | @@ -96,7 +96,10 @@ ep.tail('minifier-js', function(){ | ||
| 96 | handle_real_ctl.handleMain(function () { | 96 | handle_real_ctl.handleMain(function () { |
| 97 | //处理线调地图 | 97 | //处理线调地图 |
| 98 | handle_real_ctl.handleMap(function () { | 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,7 +115,7 @@ ep.tail('package-jar', function(file){ | ||
| 112 | 115 | ||
| 113 | logSuccess('mvn package success'); | 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 | output(cProcess); | 121 | output(cProcess); |
| @@ -122,7 +125,7 @@ ep.tail('package-jar', function(file){ | @@ -122,7 +125,7 @@ ep.tail('package-jar', function(file){ | ||
| 122 | ep.tail('handle-fragment', function(file){ | 125 | ep.tail('handle-fragment', function(file){ |
| 123 | //要排除的文件 | 126 | //要排除的文件 |
| 124 | for(var i = 0, ex; ex = excludes[i++];){ | 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 | return false; | 129 | return false; |
| 127 | } | 130 | } |
| 128 | handleJavascript(file, function(mini, $){ | 131 | handleJavascript(file, function(mini, $){ |
| @@ -139,12 +142,12 @@ ep.tail('handle-fragment', function(file){ | @@ -139,12 +142,12 @@ ep.tail('handle-fragment', function(file){ | ||
| 139 | 142 | ||
| 140 | //处理首页 | 143 | //处理首页 |
| 141 | ep.tail('handle-index', function(cb){ | 144 | ep.tail('handle-index', function(cb){ |
| 142 | - var index = dest + _static + separator + 'index.html'; | 145 | + var index = dest + _static + sp + 'index.html'; |
| 143 | handleJavascript(index, function(mini, $){ | 146 | handleJavascript(index, function(mini, $){ |
| 144 | var jsMiniText = mini.inside + mini.outside; | 147 | var jsMiniText = mini.inside + mini.outside; |
| 145 | 148 | ||
| 146 | var code = md5(jsMiniText); | 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 | if(err) | 151 | if(err) |
| 149 | logError(err); | 152 | logError(err); |
| 150 | 153 | ||
| @@ -204,7 +207,7 @@ function write(file, text){ | @@ -204,7 +207,7 @@ function write(file, text){ | ||
| 204 | console.log(err.toString().red); | 207 | console.log(err.toString().red); |
| 205 | process.exit(); | 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,7 +222,7 @@ function walk(path ,handleFile, over) { | ||
| 219 | console.log('read dir error'.red); | 222 | console.log('read dir error'.red); |
| 220 | } else { | 223 | } else { |
| 221 | files.forEach(function(item) { | 224 | files.forEach(function(item) { |
| 222 | - var tmpPath = path + separator + item; | 225 | + var tmpPath = path + sp + item; |
| 223 | fs.stat(tmpPath, function(err1, stats) { | 226 | fs.stat(tmpPath, function(err1, stats) { |
| 224 | if (err1) { | 227 | if (err1) { |
| 225 | console.log('stat error'); | 228 | console.log('stat error'); |