修复异常
This commit is contained in:
@@ -14,47 +14,35 @@ export default {
|
||||
},
|
||||
loadApps() {
|
||||
//新App的自动化格式
|
||||
const apps = require.context('../../', true, /\.(\/.+)\/App[A-Z][^\/]+\.vue$/, 'lazy')
|
||||
if (process.env.VUE_APP_DEV_MODE == 'fast') {
|
||||
waiting.init({innerHTML: '应用加载中..'})
|
||||
axios.post("/node/wechatapps/list", null, {
|
||||
params: {type: 'web', size: 999}, baseURL: "/ns"
|
||||
}).then(res => {
|
||||
if (res?.data) {
|
||||
return res.data.records.map(({label, name, libPath: path, id}) => {
|
||||
waiting.setContent(`加载${name}...`)
|
||||
const module = () => apps(`.${path}.vue`)
|
||||
const addApp = {label, name: id, path, component: appEntry, module}
|
||||
router.addRoute(addApp)
|
||||
store.commit("addApp", addApp)
|
||||
})
|
||||
}
|
||||
}).finally(() => waiting.close())
|
||||
} else {
|
||||
waiting.init({innerHTML: '应用加载中..'})
|
||||
Promise.all(apps.keys().map(path => apps(path).then(file => {
|
||||
if (file.default) {
|
||||
let {name, label} = file.default,
|
||||
addApp = {
|
||||
name: path.replace(/\.\/?(vue)?/g, '')?.split("/").join("_"), label: label || name,
|
||||
path: path.replace(/\.(\/.+\/App.+)\.vue$/, '$1'),
|
||||
component: appEntry,
|
||||
module: file.default
|
||||
}
|
||||
waiting.setContent(`加载${name}...`)
|
||||
router.addRoute(addApp)
|
||||
//命名规范入口文件必须以App开头
|
||||
return store.commit("addApp", addApp)
|
||||
} else return 0
|
||||
}))).then(() => {
|
||||
axios.post("/node/wechatapps/addOrUpdate", {
|
||||
type: "web",
|
||||
list: this.routes().map(({path: libPath, label, module: {name}, name: id}) => ({
|
||||
id, type: 'web', libPath, label, name
|
||||
}))
|
||||
}, {baseURL: "/ns"}).catch(() => 0)
|
||||
waiting.close()
|
||||
})
|
||||
}
|
||||
let apps = require.context('../../packages/', true, /\.(\/.+)\/App[A-Z][^\/]+\.vue$/, 'lazy'),
|
||||
projects = require.context('../../project/', true, /\.(\/.+)\/App[A-Z][^\/]+\.vue$/, 'lazy')
|
||||
const promise = (mods, base) => Promise.all(mods.keys().map(path => mods(path).then(file => {
|
||||
if (file.default) {
|
||||
let {name, label} = file.default,
|
||||
addApp = {
|
||||
name: path.replace(/\.\/?(vue)?/g, '')?.split("/").join("_"), label: label || name,
|
||||
path: `/${base}${path.replace(/\.(\/.+\/App.+)\.vue$/, '$1')}`,
|
||||
component: appEntry,
|
||||
module: file.default
|
||||
}
|
||||
waiting.setContent(`加载${name}...`)
|
||||
router.addRoute(addApp)
|
||||
//命名规范入口文件必须以App开头
|
||||
return store.commit("addApp", addApp)
|
||||
} else return 0
|
||||
})))
|
||||
waiting.init({innerHTML: '应用加载中..'})
|
||||
Promise.all([
|
||||
promise(apps, "packages"),
|
||||
promise(projects, "project")
|
||||
]).then(() => {
|
||||
axios.post("/node/wechatapps/addOrUpdate", {
|
||||
type: "web",
|
||||
list: this.routes().map(({path: libPath, label, module: {name}, name: id}) => ({
|
||||
id, type: 'web', libPath, label, name
|
||||
}))
|
||||
}, {baseURL: "/ns"}).catch(() => 0)
|
||||
waiting.close()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user