Merge branch 'dev' into vite
# 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
This commit is contained in:
@@ -2,6 +2,8 @@ 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() {
|
||||
@@ -14,30 +16,29 @@ export default {
|
||||
loadApps() {
|
||||
//锁屏loading
|
||||
waiting.init({innerHTML: '应用加载中..'})
|
||||
//新App的自动化格式
|
||||
let files = import.meta.glob('../../packages/**/App*.vue')
|
||||
let cores = import.meta.glob('../../core/**/App*.vue')
|
||||
let projects = import.meta.glob('../../project/**/App*.vue')
|
||||
files = {...files, ...cores, ...projects}
|
||||
return Promise.all(Object.keys(files).map(path => {
|
||||
if (/App[A-Z]\w+\.vue/.test(path)) {
|
||||
return files?.[path]()?.then(file => {
|
||||
let {name, label} = file.default,
|
||||
addApp = {
|
||||
name: [path.replace(/[.\/]+(project)?[\/]([a-z]+).+/, '$2'), name].join("_"), label: label || name,
|
||||
path: path.replace(/[.\/]+([a-zA-Z].+\/App[A-Z]\w+)\.vue$/, '/v/$1'),
|
||||
component: appEntry,
|
||||
module: file.default
|
||||
}
|
||||
//命名规范入口文件必须以App开头
|
||||
waiting.setContent(`加载${name}...`)
|
||||
router.addRoute(addApp)
|
||||
this.routes.push(addApp)
|
||||
return store.commit("addApp", addApp)
|
||||
})
|
||||
} else {
|
||||
return Promise.resolve()
|
||||
}
|
||||
})).then(() => waiting.close())
|
||||
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()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user