# Conflicts: # examples/main.js # examples/router/autoRoutes.js # package.json # packages/bigscreen/designer/AppDesigner.vue # packages/bigscreen/designer/components/Add.vue # packages/bigscreen/designer/components/Layout.vue # packages/bigscreen/designer/components/List.vue # packages/bigscreen/designer/components/SourceData.vue # packages/bigscreen/designer/components/form/DataConfig.vue # packages/bigscreen/designer/config.js # packages/bigscreen/viewer/AppGigscreenViewer.vue # packages/conv/creditScore/scoreManage/scoreChange.vue # packages/index.js # project/dv/apps/AppGridDV.vue # project/dvui/components/AiMonitor/dhVideo.vue # project/dvui/components/AiSwiper.vue # project/dvui/layout/AiDvBackground.vue # project/dvui/layout/AiDvSummary/AiDvSummary.vue # project/dvui/layout/AiDvWrapper/AiDvWrapper.vue # project/dvui/package.json # public/index.html # vue.config.js
45 lines
1.4 KiB
JavaScript
45 lines
1.4 KiB
JavaScript
import store from "../store";
|
|
import appEntry from "../views/appEntry";
|
|
import {waiting} from "../utils";
|
|
import router from "./router";
|
|
import axios from "./axios";
|
|
|
|
export default {
|
|
routes: [],
|
|
init() {
|
|
//约束正则式
|
|
store.commit("cleanApps")
|
|
this.routes = []
|
|
// 自动化本工程应用
|
|
return this.loadApps()
|
|
},
|
|
loadApps() {
|
|
//锁屏loading
|
|
waiting.init({innerHTML: '应用加载中..'})
|
|
let apps = require.context('../../', true, /\.(\/.+)\/App[A-Z][^\/]+\.vue$/, "lazy")
|
|
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()
|
|
})
|
|
}
|
|
}
|