parent
69c8175339
commit
b4a9568fad
@ -0,0 +1,9 @@ |
|||||||
|
/*需要权限控制的路由表*/ |
||||||
|
const modulesFiles = require.context('./modules', false, /\.js$/) |
||||||
|
const modules = modulesFiles.keys().reduce((modules, modulePath) => { |
||||||
|
const value = modulesFiles(modulePath).default |
||||||
|
Array.isArray(value) ? modules.push(...value) : modules.push(value) |
||||||
|
return modules |
||||||
|
}, []) |
||||||
|
|
||||||
|
export default modules |
||||||
@ -1,17 +0,0 @@ |
|||||||
/*需要权限控制的路由表*/ |
|
||||||
import purchaseRouter from '@/router/modules/purchase' |
|
||||||
import sellRouter from '@/router/modules/sell' |
|
||||||
import stockRouter from '@/router/modules/stock' |
|
||||||
import messageRouter from '@/router/modules/message' |
|
||||||
import systemRouter from '@/router/modules/system' |
|
||||||
|
|
||||||
|
|
||||||
const authorityRoutes = [ |
|
||||||
purchaseRouter, |
|
||||||
sellRouter, |
|
||||||
stockRouter, |
|
||||||
messageRouter, |
|
||||||
systemRouter, |
|
||||||
] |
|
||||||
|
|
||||||
export default authorityRoutes |
|
||||||
@ -0,0 +1,33 @@ |
|||||||
|
/*路由表:系统页面*/ |
||||||
|
import Layout from '@/layout' |
||||||
|
|
||||||
|
const router = [ |
||||||
|
{ |
||||||
|
path: '/redirect', |
||||||
|
component: Layout, |
||||||
|
children: [ |
||||||
|
{ |
||||||
|
path: '/redirect/:path(.*)', |
||||||
|
component: () => import('@/views/app/redirect') |
||||||
|
} |
||||||
|
] |
||||||
|
}, |
||||||
|
{ |
||||||
|
path: '/login', |
||||||
|
component: () => import('@/views/app/login') |
||||||
|
}, |
||||||
|
{ |
||||||
|
path: '/register', |
||||||
|
component: () => import('@/views/app/register') |
||||||
|
}, |
||||||
|
{ |
||||||
|
path: '/404', |
||||||
|
component: () => import('@/views/app/404') |
||||||
|
}, |
||||||
|
{ |
||||||
|
path: '/403', |
||||||
|
component: () => import('@/views/app/403') |
||||||
|
} |
||||||
|
] |
||||||
|
|
||||||
|
export default router |
||||||
@ -0,0 +1,30 @@ |
|||||||
|
import {pathToRegexp} from 'path-to-regexp' |
||||||
|
import {isEmpty} from "@/utils" |
||||||
|
import {title} from "@/config" |
||||||
|
|
||||||
|
//拼接页面标题
|
||||||
|
export function getPageTitle(pageTitle) { |
||||||
|
return pageTitle ? `${pageTitle} - ${title}` : title |
||||||
|
} |
||||||
|
|
||||||
|
//将给定的白名单url转换为正则
|
||||||
|
export function transformWhiteList(list) { |
||||||
|
return list.map(url => pathToRegexp(url)) |
||||||
|
} |
||||||
|
|
||||||
|
//子路由继承父路由meta上的{affix,noAuth,noCache},优先使用子路由的值
|
||||||
|
export function metaExtend(routes, meta) { |
||||||
|
routes.forEach(route => { |
||||||
|
if (meta) { |
||||||
|
const keys = ['affix', 'noAuth', 'noCache'] |
||||||
|
Object.keys(meta).forEach(key => { |
||||||
|
if (keys.includes(key) && !isEmpty(meta[key]) && isEmpty(route.meta[key])) { |
||||||
|
route.meta[key] = meta[key] |
||||||
|
} |
||||||
|
}) |
||||||
|
} |
||||||
|
if (route.children) { |
||||||
|
metaExtend(route.children, route.meta) |
||||||
|
} |
||||||
|
}) |
||||||
|
} |
||||||
Loading…
Reference in new issue