|
@@ -6,23 +6,21 @@ import { ElNotification } from 'element-plus'
|
|
// 加载views下面所有的.vue文件
|
|
// 加载views下面所有的.vue文件
|
|
const modules = import.meta.glob('@/views/**/*.vue')
|
|
const modules = import.meta.glob('@/views/**/*.vue')
|
|
|
|
|
|
-console.log(modules)
|
|
|
|
|
|
|
|
-export const asyncAddRouter = () => {
|
|
|
|
- const globalStore = GlobalStore()
|
|
|
|
- globalStore.GET_Flat_Menu.forEach((item: any) => {
|
|
|
|
- item.children && delete item.children
|
|
|
|
- if (item.component && typeof item.component == 'string') {
|
|
|
|
- // item.component = modules['/src/views' + item.component + '.vue']
|
|
|
|
- console.log(item)
|
|
|
|
- }
|
|
|
|
- if (item.meta.isFull) {
|
|
|
|
- router.addRoute(item)
|
|
|
|
- } else {
|
|
|
|
- router.addRoute('Index', item)
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
-}
|
|
|
|
|
|
+// export const asyncAddRouter = () => {
|
|
|
|
+// const globalStore = GlobalStore()
|
|
|
|
+// globalStore.GET_Flat_Menu.forEach((item: any) => {
|
|
|
|
+// item.children && delete item.children
|
|
|
|
+// if (item.component && typeof item.component == 'string') {
|
|
|
|
+// item.component = modules['/src/views' + item.component + '.vue']
|
|
|
|
+// }
|
|
|
|
+// if (item.meta.isFull) {
|
|
|
|
+// router.addRoute(item)
|
|
|
|
+// } else {
|
|
|
|
+// router.addRoute('Index', item)
|
|
|
|
+// }
|
|
|
|
+// })
|
|
|
|
+// }
|
|
|
|
|
|
/**
|
|
/**
|
|
* 初始化动态路由
|
|
* 初始化动态路由
|
|
@@ -49,7 +47,25 @@ export const initDynamicRouter = async () => {
|
|
return Promise.reject('No permission')
|
|
return Promise.reject('No permission')
|
|
}
|
|
}
|
|
// 3.添加动态路由
|
|
// 3.添加动态路由
|
|
- asyncAddRouter()
|
|
|
|
|
|
+ globalStore.GET_Flat_Menu.forEach((item: any) => {
|
|
|
|
+ item.children && delete item.children
|
|
|
|
+ if (item.component && typeof item.component == 'string') {
|
|
|
|
+ // console.log(item.component);
|
|
|
|
+
|
|
|
|
+ item.component = modules['/src/views' + item.component + '.vue']
|
|
|
|
+ // console.log(modules['/src/views' + item.component + '.vue'], modules)
|
|
|
|
+
|
|
|
|
+ // console.log(item)
|
|
|
|
+ // /src/views/home/Home.vue
|
|
|
|
+ // /src/views' + item.component + '.vue
|
|
|
|
+ // "/home/Home"
|
|
|
|
+ }
|
|
|
|
+ if (item.meta.isFull) {
|
|
|
|
+ router.addRoute(item)
|
|
|
|
+ } else {
|
|
|
|
+ router.addRoute('Index', item)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
|
|
// 4.最后添加 notFoundRouter
|
|
// 4.最后添加 notFoundRouter
|
|
router.addRoute(notFoundRouter)
|
|
router.addRoute(notFoundRouter)
|