|
@@ -33,7 +33,7 @@ export const moduleRoutes = {
|
|
|
redirect: {name: 'login'},
|
|
|
meta: {title: '主入口布局'},
|
|
|
children: [
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -48,7 +48,7 @@ const router = new Router({
|
|
|
|
|
|
router.beforeEach((to, from, next) => {
|
|
|
|
|
|
- filterToken(to, from, next)
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -68,23 +68,43 @@ router.beforeEach((to, from, next) => {
|
|
|
Vue.prototype.$message.error(res.msg)
|
|
|
return next({name: 'login'})
|
|
|
}
|
|
|
- let homePage = {
|
|
|
- 'uuid': 'index1',
|
|
|
- 'parentUUID': 0,
|
|
|
- 'name': '首页',
|
|
|
- 'ename': 'home',
|
|
|
- 'path': 'home',
|
|
|
- 'componentPath': 'modules/home'
|
|
|
- }
|
|
|
- res.list.unshift(homePage)
|
|
|
+ let firstPath = getParent(res.list)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
window.SITE_CONFIG['menuList'] = res.list
|
|
|
fnAddDynamicMenuRoutes(window.SITE_CONFIG['menuList'])
|
|
|
- next({...to, replace: true})
|
|
|
+
|
|
|
+ next({path: firstPath, replace: true})
|
|
|
}).catch(() => {
|
|
|
next({name: 'login'})
|
|
|
})
|
|
|
})
|
|
|
|
|
|
+function getParent (list) {
|
|
|
+ let arr = list.filter((e) => {
|
|
|
+ if (!e.path) {
|
|
|
+ e.path = e.UUID
|
|
|
+ }
|
|
|
+ if (!e.url) {
|
|
|
+
|
|
|
+ }
|
|
|
+ return !e.parentUUID && e.path && e.url
|
|
|
+ })
|
|
|
+ return arr[0].path
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
* 判断当前路由是否为页面路由
|
|
|
* @param {*} route 当前路由
|
|
@@ -117,7 +137,8 @@ function fnAddDynamicMenuRoutes (menuList = [], routes = []) {
|
|
|
}
|
|
|
let path = menuList[i].path
|
|
|
let componentPath = menuList[i].componentPath
|
|
|
- if (!path) {
|
|
|
+ let url = menuList[i].url
|
|
|
+ if (!url) {
|
|
|
continue
|
|
|
}
|
|
|
|
|
@@ -127,14 +148,15 @@ function fnAddDynamicMenuRoutes (menuList = [], routes = []) {
|
|
|
component: '',
|
|
|
name: menuList[i].ename,
|
|
|
meta: {
|
|
|
- uuid: menuList[i].uuid,
|
|
|
+ UUID: menuList[i].UUID,
|
|
|
parentUUID: menuList[i].parentUUID,
|
|
|
title: menuList[i].name
|
|
|
}
|
|
|
}
|
|
|
- menuList[i].url = 'https://juejin.im/'
|
|
|
- if (isURL(menuList[i].url)) {
|
|
|
- route.meta.iframeURL = menuList[i].url
|
|
|
+
|
|
|
+
|
|
|
+ if (isURL(url)) {
|
|
|
+ route.meta.iframeURL = url
|
|
|
route.component = () => import(`@/views/modules/home`)
|
|
|
} else {
|
|
|
route.component = () => import(`@/views/${componentPath}`)
|
|
@@ -167,6 +189,24 @@ function fnAddDynamicMenuRoutes (menuList = [], routes = []) {
|
|
|
if (temp.length >= 1) {
|
|
|
return fnAddDynamicMenuRoutes(temp, routes)
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
router.addRoutes([
|
|
|
{
|