2021-08-17 14:59:59 +08:00
|
|
|
import type { RouteRecordRaw } from 'vue-router';
|
2021-09-11 02:34:36 +08:00
|
|
|
import { BasicLayout, BlankLayout } from '@/layouts';
|
2021-09-09 12:00:18 +08:00
|
|
|
import { EnumRoutePaths } from '@/enum';
|
2021-09-11 02:34:36 +08:00
|
|
|
import type { RoutePathKey, LoginModuleType } from '@/interface';
|
|
|
|
import { getLoginModuleRegExp } from '@/utils';
|
2021-09-09 12:00:18 +08:00
|
|
|
|
|
|
|
/** 路由名称 */
|
2021-09-11 02:34:36 +08:00
|
|
|
export const RouteNameMap = new Map<RoutePathKey, RoutePathKey>(
|
|
|
|
(Object.keys(EnumRoutePaths) as RoutePathKey[]).map(v => [v, v])
|
|
|
|
);
|
|
|
|
|
|
|
|
const loginModuleRegExp = getLoginModuleRegExp();
|
2021-09-09 12:00:18 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 固定不变的路由
|
|
|
|
* @description !最后一项重定向未找到的路由须放置路由的最后一项
|
|
|
|
*/
|
|
|
|
export const constantRoutes: Array<RouteRecordRaw> = [
|
|
|
|
{
|
|
|
|
name: 'system',
|
|
|
|
path: '/system',
|
|
|
|
component: BlankLayout,
|
|
|
|
redirect: { name: 'not-found' },
|
|
|
|
children: [
|
|
|
|
// 登录
|
|
|
|
{
|
|
|
|
name: RouteNameMap.get('login'),
|
2021-09-11 02:34:36 +08:00
|
|
|
path: `${EnumRoutePaths.login}/:module(/${loginModuleRegExp}/)?`,
|
2021-09-09 18:40:38 +08:00
|
|
|
component: () => import('@/views/system/login/index.vue'),
|
2021-09-11 02:34:36 +08:00
|
|
|
props: route => {
|
|
|
|
const moduleType: LoginModuleType = (route.params.module as LoginModuleType) || 'pwd-login';
|
|
|
|
return {
|
|
|
|
module: moduleType
|
|
|
|
};
|
|
|
|
},
|
2021-09-09 18:40:38 +08:00
|
|
|
meta: {
|
|
|
|
fullPage: true
|
|
|
|
}
|
2021-09-09 12:00:18 +08:00
|
|
|
},
|
|
|
|
// 404
|
|
|
|
{
|
|
|
|
name: RouteNameMap.get('not-found'),
|
|
|
|
path: EnumRoutePaths['not-found'],
|
2021-09-09 18:40:38 +08:00
|
|
|
component: () => import('@/views/system/exception/404.vue'),
|
|
|
|
meta: {
|
|
|
|
fullPage: true
|
|
|
|
}
|
2021-09-09 12:00:18 +08:00
|
|
|
},
|
|
|
|
// 403
|
|
|
|
{
|
|
|
|
name: RouteNameMap.get('no-permission'),
|
|
|
|
path: EnumRoutePaths['no-permission'],
|
2021-09-09 18:40:38 +08:00
|
|
|
component: () => import('@/views/system/exception/403.vue'),
|
|
|
|
meta: {
|
|
|
|
fullPage: true
|
|
|
|
}
|
2021-09-09 12:00:18 +08:00
|
|
|
},
|
|
|
|
// 500
|
|
|
|
{
|
|
|
|
name: RouteNameMap.get('service-error'),
|
|
|
|
path: EnumRoutePaths['service-error'],
|
2021-09-09 18:40:38 +08:00
|
|
|
component: () => import('@/views/system/exception/500.vue'),
|
|
|
|
meta: {
|
|
|
|
fullPage: true
|
|
|
|
}
|
2021-09-09 12:00:18 +08:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
// 匹配无效的路径重定向404
|
|
|
|
{
|
|
|
|
path: '/:pathMatch(.*)*',
|
|
|
|
redirect: { name: 'not-found' }
|
|
|
|
}
|
|
|
|
];
|
2021-08-17 14:59:59 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 自定义路由
|
|
|
|
*/
|
|
|
|
export const customRoutes: Array<RouteRecordRaw> = [
|
|
|
|
{
|
|
|
|
name: 'root',
|
|
|
|
path: '/',
|
2021-09-11 02:34:36 +08:00
|
|
|
redirect: { name: RouteNameMap.get('dashboard-analysis') }
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'dashboard',
|
|
|
|
path: '/dashboard',
|
|
|
|
component: BasicLayout,
|
2021-09-09 18:40:38 +08:00
|
|
|
redirect: { name: RouteNameMap.get('dashboard-analysis') },
|
2021-09-11 02:34:36 +08:00
|
|
|
children: [
|
|
|
|
{
|
|
|
|
name: RouteNameMap.get('dashboard-analysis'),
|
|
|
|
path: EnumRoutePaths['dashboard-analysis'],
|
|
|
|
component: () => import('@/views/dashboard/analysis/index.vue')
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: RouteNameMap.get('dashboard-workbench'),
|
|
|
|
path: EnumRoutePaths['dashboard-workbench'],
|
|
|
|
component: () => import('@/views/dashboard/workbench/index.vue')
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'exception',
|
|
|
|
path: '/exception',
|
2021-08-18 12:02:59 +08:00
|
|
|
component: BasicLayout,
|
|
|
|
children: [
|
|
|
|
{
|
2021-09-11 02:34:36 +08:00
|
|
|
name: RouteNameMap.get('exception-403'),
|
|
|
|
path: EnumRoutePaths['exception-403'],
|
|
|
|
component: () => import('@/views/system/exception/403.vue')
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: RouteNameMap.get('exception-404'),
|
|
|
|
path: EnumRoutePaths['exception-404'],
|
|
|
|
component: () => import('@/views/system/exception/404.vue')
|
2021-09-09 18:40:38 +08:00
|
|
|
},
|
|
|
|
{
|
2021-09-11 02:34:36 +08:00
|
|
|
name: RouteNameMap.get('exception-500'),
|
|
|
|
path: EnumRoutePaths['exception-500'],
|
|
|
|
component: () => import('@/views/system/exception/500.vue')
|
2021-08-18 12:02:59 +08:00
|
|
|
}
|
|
|
|
]
|
2021-08-17 14:59:59 +08:00
|
|
|
}
|
|
|
|
];
|