|
@@ -4,6 +4,7 @@ import { globalRoutes } from "./module/globalRoutes";
|
|
|
import { useStore } from 'vuex'
|
|
|
import { menuList } from "@/api";
|
|
|
import { fork } from 'child_process';
|
|
|
+import { toRaw } from "vue";
|
|
|
const routes: any = [
|
|
|
...globalRoutes,
|
|
|
]
|
|
@@ -38,11 +39,12 @@ router.beforeEach(async (to, from, next) => {
|
|
|
} else {
|
|
|
const reslut: any = await initDynamicRouter()
|
|
|
const dynamicRouter = Fn(reslut)
|
|
|
- routes[1].children = dynamicRouter
|
|
|
- dynamicRouter.forEach((element:any) => {
|
|
|
- router.addRoute(element)
|
|
|
+ routes[1].children = [...dynamicRouter]
|
|
|
+ console.log('返回',dynamicRouter)
|
|
|
+ dynamicRouter.forEach((item:any) => {
|
|
|
+ router.addRoute(item)
|
|
|
});
|
|
|
- store.commit('setMenuFun', reslut) //存储用户个人信息
|
|
|
+ store.commit('setMenuFun', dynamicRouter) //存储用户个人信息
|
|
|
return next({ ...to, replace: true })
|
|
|
}
|
|
|
} else {//当前存在动态导航
|
|
@@ -65,6 +67,6 @@ function Fn(arr: any) {
|
|
|
arr[j].component = () => import(`${arr[j].component}`)
|
|
|
if(arr[j].children && arr[j].children.length) Fn(arr[j].children)
|
|
|
}
|
|
|
- return arr
|
|
|
+ return toRaw(arr)
|
|
|
}
|
|
|
export default router
|