diff --git a/bin/serve.js b/bin/serve.js index ee2627a3..39ed1d1f 100644 --- a/bin/serve.js +++ b/bin/serve.js @@ -1,57 +1,30 @@ -const fsExtra = require('fs-extra') -const path = require('path') -const fs = require('fs') -/** - * 将函数封装成promise - */ -const promisify = fn => { - return function () { - let args = arguments; - return new Promise(function (resolve, reject) { - [].push.call(args, function (err, result) { - if (err) { - console.log(err) - reject(err); - } else { - resolve(result); - } - }); - fn.apply(null, args); - }); +const {chalkTag, findPages, fs, fsExtra} = require("./tools"); +const axios = require("axios"); +let apps = {list: [], desc: "用于产品库主页面获取应用使用"} +const getFileInfo = (app, file) => { + let vue = fs.readFileSync(file).toString() + if (/appName/.test(vue)) { + let appName = vue.replace(/[\s\S]*(appName:.+),[\s\S]*/gm, '$1') + app.label = appName.replace(/(appName:|["'])/g, '')?.trim() + if (/customNavigation/.test(vue)) { + app.style = {navigationStyle: "custom"} + } else + app.style = {navigationBarTitleText: app.label} + } + if (/^App/.test(app.name)) { + let {name, label} = app, + path = app.path.replace(/.+[\\\/]([^\\\/]+)[\\\/]([^\\\/]+)$/g, `/apps/$1/$2`) + apps.list.push({id: name, name, label, path, libPath: file?.replace(/\\/g, '/')?.replace(/^src(\/.+)\.vue/, '$1'), type: 'wxwork'}) + } +} +const saveApps = app => { + if (app.list.length > 0) { + axios.post("http://192.168.1.87:12525/node/wechatapps/addOrUpdate", app).then(res => { + if (res?.code == 0) chalkTag.done("产品库目录已同步至后台数据库...") + }).catch(() => 0) } } -const readdir = promisify(fs.readdir) -const stat = promisify(fs.stat) -/** - * 封装打印工具 - */ -const chalk = require('chalk') -const {log} = console -const chalkTag = { - info: msg => log([chalk.bgBlue.black(' INFO '), msg].join(' ')), - done: msg => log([chalk.bgGreen.black(' DONE '), msg].join(' ')), - warn: msg => log([chalk.bgYellow.black(' WARN '), msg].join(' ')), - error: msg => log([chalk.bgRed.black(' ERROR '), msg].join(' ')), -} - -/** - * 遍历应用的方法 - */ -const findApp = (dir, cb) => { - return readdir(dir).then(apps => { - return Promise.all(apps.map(e => { - let cPath = path.join(dir, e) - return stat(cPath).then(state => { - if (state.isDirectory()) { - return findApp(cPath, cb) - } else if (state.isFile()) { - cb && cb(cPath) - } - }) - }) || []) - }) -} const start = () => { chalkTag.info('开始生成pages.json...') let json = { @@ -68,67 +41,51 @@ const start = () => { navigationStyle: "custom" } } - findApp('src/components/pages', file => { - if (/.+\\[^\\]+\\[^\\]+\.vue/g.test(file)) { - let app = { - path: file.replace(/^src\\(.*).vue/g, '$1').replace(/\\/g, '/') + Promise.all([ + findPages('src/components/pages', file => { + if (/.+\\[^\\]+\\[^\\]+\.vue/g.test(file)) { + let app = { + path: file.replace(/^src\\(.*).vue/g, '$1').replace(/\\/g, '/') + } + getFileInfo(app, file) + return json.pages.push(app) } - let vue = fs.readFileSync(file).toString() - if (/appName/.test(vue)) { - let appName = vue.replace(/[\s\S]*(appName:.+),[\s\S]*/gm, '$1'), - title = appName.replace(/(appName:|["'])/g, '') - app.style = {navigationBarTitleText: title.trim()} + }), + findPages('src/apps', file => { + if (/.+\\App[^\\]+\\[^\\]+\.vue/g.test(file)) { + let app = { + name: file.replace(/.*\\([^\\]+).vue/g, '$1'), + path: file.replace(/^src\\(.*).vue/g, '$1').replace(/\\/g, '/') + } + getFileInfo(app, file) + return json.pages.push(app) } - json.pages.push(app) - } - }).then(() => findApp('src/apps', file => { - if (/.+\\App[^\\]+\\[^\\]+\.vue/g.test(file)) { - let app = { - name: file.replace(/.*\\([^\\]+).vue/g, '$1'), - path: file.replace(/^src\\(.*).vue/g, '$1').replace(/\\/g, '/') + }), + findPages('src/saas', file => { + if (/.+\\App[^\\]+\\[^\\]+\.vue/g.test(file)) { + let app = { + name: file.replace(/.*\\([^\\]+).vue/g, '$1'), + path: file.replace(/^src\\(.*).vue/g, '$1').replace(/\\/g, '/') + } + getFileInfo(app, file) + return json.pages.push(app) } - let vue = fs.readFileSync(file).toString() - if (/appName/.test(vue)) { - let appName = vue.replace(/[\s\S]*(appName:.+),[\s\S]*/gm, '$1'), - title = appName.replace(/(appName:|["'])/g, '') - app.style = {navigationBarTitleText: title.trim()} + }), + findPages('src/project', file => { + if (/.+\\App[^\\]+\\[^\\]+\.vue/g.test(file)) { + let app = { + name: file.replace(/.*\\([^\\]+).vue/g, '$1'), + path: file.replace(/^src\\(.*).vue/g, '$1').replace(/\\/g, '/') + } + getFileInfo(app, file) + return json.pages.push(app) } - json.pages.push(app) - } - })).then(() => findApp('src/saas', file => { - if (/.+\\App[^\\]+\\[^\\]+\.vue/g.test(file)) { - let app = { - name: file.replace(/.*\\([^\\]+).vue/g, '$1'), - path: file.replace(/^src\\(.*).vue/g, '$1').replace(/\\/g, '/') - } - let vue = fs.readFileSync(file).toString() - if (/appName/.test(vue)) { - let appName = vue.replace(/[\s\S]*(appName:.+),[\s\S]*/gm, '$1'), - title = appName.replace(/(appName:|["'])/g, '') - app.style = {navigationBarTitleText: title.trim()} - } - json.pages.push(app) - } - })).then(() => findApp('src/project', file => { - if (/.+\\App[^\\]+\\[^\\]+\.vue/g.test(file)) { - let app = { - name: file.replace(/.*\\([^\\]+).vue/g, '$1'), - path: file.replace(/^src\\(.*).vue/g, '$1').replace(/\\/g, '/') - } - let vue = fs.readFileSync(file).toString() - if (/appName/.test(vue)) { - let appName = vue.replace(/[\s\S]*(appName:.+),[\s\S]*/gm, '$1'), - title = appName.replace(/(appName:|["'])/g, '') - app.style = {navigationBarTitleText: title.trim()} - } - json.pages.push(app) - } - })).then(() => { + }) + ]).then(() => { + saveApps(apps) fsExtra.outputJson('src/pages.json', json, () => { chalkTag.done('生成pages.json') }) }) - } - start(); diff --git a/bin/tools.js b/bin/tools.js new file mode 100644 index 00000000..e7d21632 --- /dev/null +++ b/bin/tools.js @@ -0,0 +1,85 @@ +const fsExtra = require('fs-extra') +const path = require('path') +const chalk = require('chalk') +const fs = require('fs') +/** + * 将函数封装成promise + */ +const promisify = fn => { + return function () { + let args = arguments; + return new Promise(function (resolve, reject) { + [].push.call(args, function (err, result) { + if (err) { + console.log(err) + reject(err); + } else { + resolve(result); + } + }); + fn.apply(null, args); + }); + } +} + +const readdir = promisify(fs.readdir) +const stat = promisify(fs.stat) + +/** + * 封装打印工具 + */ +const {log} = console +const chalkTag = { + info: msg => log([chalk.bgBlue.black(' INFO '), msg].join(' ')), + done: msg => log([chalk.bgGreen.black(' DONE '), msg].join(' ')), + warn: msg => log([chalk.bgYellow.black(' WARN '), msg].join(' ')), + error: msg => log([chalk.bgRed.black(' ERROR '), msg].join(' ')), +} + +/** + * 遍历应用的方法 + */ +const findApp = (dir, cb) => { + fsExtra.ensureDirSync(dir) + return readdir(dir).then(apps => { + return Promise.all(apps.map(e => { + let cPath = path.join(dir, e) + return stat(cPath).then(state => { + if (state.isDirectory()) { + return findApp(cPath, cb) + } else if (state.isFile()) { + cb && cb(dir) + } + }) + }) || []) + }) +} +const findPages = (dir, cb) => { + fsExtra.ensureDirSync(dir) + return readdir(dir).then(apps => { + return Promise.all(apps.map(e => { + let cPath = path.join(dir, e) + return stat(cPath).then(state => { + if (state.isDirectory()) { + return findPages(cPath, cb) + } else if (state.isFile()) { + cb && cb(cPath) + } + }) + }) || []) + }) +} +const copyFiles = (dir, source = 'src/mods') => { + chalkTag.info(`开始扫描${source}...`) + return new Promise(resolve => { + fsExtra.emptyDir(dir, err => { + if (!err) { + fsExtra.copy(source, dir).then(() => { + chalkTag.done(source + ' 扫描完毕') + resolve() + }) + } + }) + }) +} +module.exports = {findApp, chalkTag, fsExtra, copyFiles, fs, path, findPages} diff --git a/src/apps/AppHelpDeclaration/components/img/add-icon.png b/src/apps/AppHelpDeclaration/components/img/add-icon.png deleted file mode 100644 index f751a7fa..00000000 Binary files a/src/apps/AppHelpDeclaration/components/img/add-icon.png and /dev/null differ diff --git a/src/apps/AppHelpDeclaration/components/img/bg-1.png b/src/apps/AppHelpDeclaration/components/img/bg-1.png deleted file mode 100644 index 696022e9..00000000 Binary files a/src/apps/AppHelpDeclaration/components/img/bg-1.png and /dev/null differ diff --git a/src/apps/AppHelpDeclaration/components/img/bg-2.png b/src/apps/AppHelpDeclaration/components/img/bg-2.png deleted file mode 100644 index 98fa31b8..00000000 Binary files a/src/apps/AppHelpDeclaration/components/img/bg-2.png and /dev/null differ diff --git a/src/apps/AppHelpDeclaration/components/img/bg-3.png b/src/apps/AppHelpDeclaration/components/img/bg-3.png deleted file mode 100644 index dc469567..00000000 Binary files a/src/apps/AppHelpDeclaration/components/img/bg-3.png and /dev/null differ diff --git a/src/apps/AppHelpDeclaration/components/img/down-icon.png b/src/apps/AppHelpDeclaration/components/img/down-icon.png deleted file mode 100644 index 6ffcc7a2..00000000 Binary files a/src/apps/AppHelpDeclaration/components/img/down-icon.png and /dev/null differ diff --git a/src/apps/AppHelpDeclaration/components/img/gird--select-icon.png b/src/apps/AppHelpDeclaration/components/img/gird--select-icon.png deleted file mode 100644 index 205144d2..00000000 Binary files a/src/apps/AppHelpDeclaration/components/img/gird--select-icon.png and /dev/null differ diff --git a/src/apps/AppHelpDeclaration/components/img/gird-icon.png b/src/apps/AppHelpDeclaration/components/img/gird-icon.png deleted file mode 100644 index f7f3e61f..00000000 Binary files a/src/apps/AppHelpDeclaration/components/img/gird-icon.png and /dev/null differ diff --git a/src/apps/AppHelpDeclaration/components/img/handle-icon-active.png b/src/apps/AppHelpDeclaration/components/img/handle-icon-active.png deleted file mode 100644 index 1cb07503..00000000 Binary files a/src/apps/AppHelpDeclaration/components/img/handle-icon-active.png and /dev/null differ diff --git a/src/apps/AppHelpDeclaration/components/img/handle-icon.png b/src/apps/AppHelpDeclaration/components/img/handle-icon.png deleted file mode 100644 index ab2d20c2..00000000 Binary files a/src/apps/AppHelpDeclaration/components/img/handle-icon.png and /dev/null differ diff --git a/src/apps/AppHelpDeclaration/components/img/jujue.png b/src/apps/AppHelpDeclaration/components/img/jujue.png deleted file mode 100644 index ea7387ad..00000000 Binary files a/src/apps/AppHelpDeclaration/components/img/jujue.png and /dev/null differ diff --git a/src/apps/AppHelpDeclaration/components/img/line-img.png b/src/apps/AppHelpDeclaration/components/img/line-img.png deleted file mode 100644 index 4d423855..00000000 Binary files a/src/apps/AppHelpDeclaration/components/img/line-img.png and /dev/null differ diff --git a/src/apps/AppHelpDeclaration/components/img/local-icon.png b/src/apps/AppHelpDeclaration/components/img/local-icon.png deleted file mode 100644 index 3e23aff6..00000000 Binary files a/src/apps/AppHelpDeclaration/components/img/local-icon.png and /dev/null differ diff --git a/src/apps/AppHelpDeclaration/components/img/no-admin.png b/src/apps/AppHelpDeclaration/components/img/no-admin.png deleted file mode 100644 index 3830c170..00000000 Binary files a/src/apps/AppHelpDeclaration/components/img/no-admin.png and /dev/null differ diff --git a/src/apps/AppHelpDeclaration/components/img/remove-icon.png b/src/apps/AppHelpDeclaration/components/img/remove-icon.png deleted file mode 100644 index 971b39ef..00000000 Binary files a/src/apps/AppHelpDeclaration/components/img/remove-icon.png and /dev/null differ diff --git a/src/apps/AppHelpDeclaration/components/img/right-icon.png b/src/apps/AppHelpDeclaration/components/img/right-icon.png deleted file mode 100644 index e1c626b7..00000000 Binary files a/src/apps/AppHelpDeclaration/components/img/right-icon.png and /dev/null differ diff --git a/src/apps/AppHelpDeclaration/components/img/search-icon.png b/src/apps/AppHelpDeclaration/components/img/search-icon.png deleted file mode 100644 index e3cb75af..00000000 Binary files a/src/apps/AppHelpDeclaration/components/img/search-icon.png and /dev/null differ diff --git a/src/apps/AppHelpDeclaration/components/img/set-icon-active.png b/src/apps/AppHelpDeclaration/components/img/set-icon-active.png deleted file mode 100644 index c025cb79..00000000 Binary files a/src/apps/AppHelpDeclaration/components/img/set-icon-active.png and /dev/null differ diff --git a/src/apps/AppHelpDeclaration/components/img/set-icon.png b/src/apps/AppHelpDeclaration/components/img/set-icon.png deleted file mode 100644 index 58651b64..00000000 Binary files a/src/apps/AppHelpDeclaration/components/img/set-icon.png and /dev/null differ diff --git a/src/apps/AppHelpDeclaration/components/img/setting-icon.png b/src/apps/AppHelpDeclaration/components/img/setting-icon.png deleted file mode 100644 index 29e4b29f..00000000 Binary files a/src/apps/AppHelpDeclaration/components/img/setting-icon.png and /dev/null differ diff --git a/src/apps/AppHelpDeclaration/components/img/statistics-icon-active.png b/src/apps/AppHelpDeclaration/components/img/statistics-icon-active.png deleted file mode 100644 index 81dbd3f7..00000000 Binary files a/src/apps/AppHelpDeclaration/components/img/statistics-icon-active.png and /dev/null differ diff --git a/src/apps/AppHelpDeclaration/components/img/statistics-icon.png b/src/apps/AppHelpDeclaration/components/img/statistics-icon.png deleted file mode 100644 index 63b98d33..00000000 Binary files a/src/apps/AppHelpDeclaration/components/img/statistics-icon.png and /dev/null differ diff --git a/src/apps/AppHelpDeclaration/components/img/tx@2x.png b/src/apps/AppHelpDeclaration/components/img/tx@2x.png deleted file mode 100644 index d9620e08..00000000 Binary files a/src/apps/AppHelpDeclaration/components/img/tx@2x.png and /dev/null differ diff --git a/src/apps/AppHelpDeclaration/components/img/user-img.png b/src/apps/AppHelpDeclaration/components/img/user-img.png deleted file mode 100644 index ae49d85f..00000000 Binary files a/src/apps/AppHelpDeclaration/components/img/user-img.png and /dev/null differ diff --git a/src/apps/AppHelpDeclaration/components/img/xz.png b/src/apps/AppHelpDeclaration/components/img/xz.png deleted file mode 100644 index 98f78cda..00000000 Binary files a/src/apps/AppHelpDeclaration/components/img/xz.png and /dev/null differ diff --git a/src/apps/AppHelpDeclaration/components/img/xzh.png b/src/apps/AppHelpDeclaration/components/img/xzh.png deleted file mode 100644 index 967fa399..00000000 Binary files a/src/apps/AppHelpDeclaration/components/img/xzh.png and /dev/null differ diff --git a/src/apps/AppHelpDeclaration/components/img/zhuanjiao.png b/src/apps/AppHelpDeclaration/components/img/zhuanjiao.png deleted file mode 100644 index f6c932fa..00000000 Binary files a/src/apps/AppHelpDeclaration/components/img/zhuanjiao.png and /dev/null differ diff --git a/src/apps/AppHelpDeclaration/details.vue b/src/apps/AppHelpDeclaration/details.vue index c415547b..a6eb1013 100644 --- a/src/apps/AppHelpDeclaration/details.vue +++ b/src/apps/AppHelpDeclaration/details.vue @@ -53,7 +53,7 @@
diff --git a/src/apps/AppHelpDeclaration/list.vue b/src/apps/AppHelpDeclaration/list.vue index d77fbb3e..45f4e7e1 100644 --- a/src/apps/AppHelpDeclaration/list.vue +++ b/src/apps/AppHelpDeclaration/list.vue @@ -6,23 +6,23 @@
- - -
- {{ areaName }} + +
+ {{ areaName }} 所在地区 - - +
+
风险类型 {{ $dict.getLabel('helpDeclarationReason', declareReason) }} - + +
@@ -52,18 +52,22 @@