修复异常
This commit is contained in:
27
bin/pages.js
27
bin/pages.js
@@ -1,22 +1,25 @@
|
||||
const axios = require('axios')
|
||||
const {chalkTag, findApp, fsExtra, fs} = require("./tools");
|
||||
const {chalkTag, findPages, fsExtra, fs} = require("./tools");
|
||||
let apps = {list: [], desc: "用于产品库主页面获取应用使用"}
|
||||
const getFileInfo = (app, file) => {
|
||||
let vue = fs.readFileSync(file).toString()
|
||||
if (/customNavigation/.test(vue)) {
|
||||
app.style = {navigationStyle: "custom"}
|
||||
} else if (/appName/.test(vue)) {
|
||||
let appName = vue.replace(/[\s\S]*(appName:.+),[\s\S]*/gm, '$1'),
|
||||
title = appName.replace(/(appName:|["'])/g, '')
|
||||
app.style = {navigationBarTitleText: title}
|
||||
if (/appName/.test(vue)) {
|
||||
let appName = vue.replace(/[\s\S]*(appName:.+),[\s\S]*/gm, '$1')
|
||||
app.label = appName.replace(/(appName:|["'])/g, '')
|
||||
if (/customNavigation/.test(vue)) {
|
||||
app.style = {navigationStyle: "custom"}
|
||||
} else
|
||||
app.style = {navigationBarTitleText: app.label}
|
||||
}
|
||||
/AppPhotoAlbum/.test(app.name)
|
||||
if (/^App/.test(app.name)) {
|
||||
let {name, style: {navigationBarTitleText: label}} = app
|
||||
let {name, label} = app
|
||||
apps.list.push({id: name, name, label, path: `/mods/${name}/${name}`, libPath: file?.replace(/\\/g, '/')?.replace(/^src(\/.+)\.vue/, '$1')})
|
||||
}
|
||||
}
|
||||
const saveApps = app => {
|
||||
if (app.list.length > 0) {
|
||||
console.log(app.list)
|
||||
axios.post("http://192.168.1.87:12525/node/wechatapps/addOrUpdate", app).then(res => {
|
||||
if (res?.code == 0) chalkTag.done("产品库目录已同步至后台数据库...")
|
||||
}).catch(() => 0)
|
||||
@@ -45,8 +48,8 @@ const start = () => {
|
||||
}
|
||||
}
|
||||
Promise.all([
|
||||
findApp('src/components/pages', file => {
|
||||
if (/.+\\[^\\]+\\[^\\]+\.vue/g.test(file)) {
|
||||
findPages('src/components/pages', file => {
|
||||
if (/.+\\pages\\[^\\]+\.vue/g.test(file)) {
|
||||
let app = {
|
||||
path: file.replace(/^src\\components\\pages\\(.*).vue/g, '$1').replace(/\\/g, '/')
|
||||
}
|
||||
@@ -54,7 +57,7 @@ const start = () => {
|
||||
return json.subPackages[1].pages.push(app)
|
||||
}
|
||||
}),
|
||||
findApp('src/mods', file => {
|
||||
findPages('src/mods', file => {
|
||||
if (/.+\\App[^\\]+\\[^\\]+\.vue/g.test(file)) {
|
||||
let app = {
|
||||
name: file.replace(/.*\\([^\\]+).vue/g, '$1'),
|
||||
@@ -64,7 +67,7 @@ const start = () => {
|
||||
return json.subPackages[0].pages.push(app)
|
||||
}
|
||||
}),
|
||||
findApp('src/project', file => {
|
||||
findPages('src/project', file => {
|
||||
if (/.+\\App[^\\]+\\[^\\]+\.vue/g.test(file)) {
|
||||
let app = {
|
||||
name: file.replace(/.*\\([^\\]+).vue/g, '$1'),
|
||||
|
||||
Reference in New Issue
Block a user