|
@@ -1,52 +1,12 @@
|
|
|
-import lodash from "lodash"
|
|
|
import {createRouter, createWebHashHistory, RouteRecordRaw} from 'vue-router'
|
|
|
-import typeUtils from './utils/typeUtils'
|
|
|
|
|
|
// 基本页面
|
|
|
const basePages = {
|
|
|
- empty: () => import('@/components/Empty.vue'),
|
|
|
design: () => import('@/pages/Design.vue'),
|
|
|
studio: () => import('@/pages/Studio.vue'),
|
|
|
404: () => import('@/components/NotFound.vue'),
|
|
|
}
|
|
|
|
|
|
-// 利用vite扫描所有的页面组件 | /src/pages/Demo.vue -> import('/src/pages/Demo.vue') -> Module.default
|
|
|
-const imports = import.meta.glob(
|
|
|
- ['@/pages/**/*.vue'],
|
|
|
- {eager: false},
|
|
|
-);
|
|
|
-const pages = {};
|
|
|
-lodash.forEach(imports, (cmp, key: string) => {
|
|
|
- let component = cmp;
|
|
|
- if (typeUtils.variableTypeOf(cmp) === typeUtils.typeEnum.function) {
|
|
|
- component = async () => {
|
|
|
- return cmp().then((module: any) => {
|
|
|
- // console.log("@@@", menu.pagePath)
|
|
|
- if (module?.default) module.default.__filename = key;
|
|
|
- return module;
|
|
|
- });
|
|
|
- };
|
|
|
- }
|
|
|
- pages[key] = component;
|
|
|
-});
|
|
|
-window['pages'] = pages
|
|
|
-
|
|
|
-const designJS = {};
|
|
|
-lodash.forEach(pages, (value, key: string) => {
|
|
|
- if (key.startsWith("/src/pages")) {
|
|
|
- key = key.substring(11, key.length - 4);
|
|
|
- }
|
|
|
- designJS[key] = async () => {
|
|
|
- const module: any = await value();
|
|
|
- let vjson = {};
|
|
|
- if (lodash.isFunction(module?.default?.mixins[0]?.data)) {
|
|
|
- vjson = module.default.mixins[0].data().vjson || {};
|
|
|
- }
|
|
|
- return vjson;
|
|
|
- };
|
|
|
-});
|
|
|
-window['designJS'] = designJS
|
|
|
-
|
|
|
/** 获取路由数据 */
|
|
|
async function getRoutes(): Promise<RouteRecordRaw[]> {
|
|
|
const routes: RouteRecordRaw[] = [];
|
|
@@ -87,7 +47,6 @@ async function initRouter() {
|
|
|
}
|
|
|
|
|
|
export {
|
|
|
- pages,
|
|
|
initRouter,
|
|
|
router,
|
|
|
};
|