ruoyi-plus-soybean/src/router/routes.ts

126 lines
3.4 KiB
TypeScript
Raw Normal View History

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}/)?`,
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
};
},
meta: {
fullPage: true
}
2021-09-09 12:00:18 +08:00
},
// 404
{
name: RouteNameMap.get('not-found'),
path: EnumRoutePaths['not-found'],
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'],
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'],
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,
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-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
}
];