mirror of
https://github.com/m-xlsea/ruoyi-plus-soybean.git
synced 2025-09-24 07:49:47 +08:00
refactor(projects): 单独路由逻辑重构、路由转换函数优化
This commit is contained in:
@ -13,8 +13,8 @@ const constantRoutes: AuthRoute.Route[] = [
|
||||
},
|
||||
{
|
||||
name: 'login',
|
||||
path: `/login/:module(${getLoginModuleRegExp()})?`,
|
||||
component: 'blank',
|
||||
path: '/login',
|
||||
component: 'self',
|
||||
props: route => {
|
||||
const moduleType = (route.params.module as LoginModuleKey) || 'pwd-login';
|
||||
return {
|
||||
@ -23,45 +23,45 @@ const constantRoutes: AuthRoute.Route[] = [
|
||||
},
|
||||
meta: {
|
||||
title: '登录',
|
||||
single: true,
|
||||
singleOriginPath: '/login'
|
||||
dynamicPath: `/login/:module(${getLoginModuleRegExp()})?`,
|
||||
singleLayout: 'blank'
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'no-permission',
|
||||
path: '/no-permission',
|
||||
component: 'blank',
|
||||
component: 'self',
|
||||
meta: {
|
||||
title: '无权限',
|
||||
single: true
|
||||
singleLayout: 'blank'
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'not-found',
|
||||
path: '/not-found',
|
||||
component: 'blank',
|
||||
component: 'self',
|
||||
meta: {
|
||||
title: '未找到',
|
||||
single: true
|
||||
singleLayout: 'blank'
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'service-error',
|
||||
path: '/service-error',
|
||||
component: 'blank',
|
||||
component: 'self',
|
||||
meta: {
|
||||
title: '服务器错误',
|
||||
single: true
|
||||
singleLayout: 'blank'
|
||||
}
|
||||
},
|
||||
// 匹配无效的路径重定向not-found的页面
|
||||
{
|
||||
name: 'redirect-not-found',
|
||||
name: 'not-found-page',
|
||||
path: '/:pathMatch(.*)*',
|
||||
component: 'blank',
|
||||
meta: {
|
||||
title: '未找到',
|
||||
single: true
|
||||
singleLayout: 'blank'
|
||||
}
|
||||
}
|
||||
];
|
||||
|
@ -5,4 +5,17 @@ import constantRoutes from './constant';
|
||||
/** 所有路由 */
|
||||
export const routes: RouteRecordRaw[] = constantRoutes.map(item => transformAuthRouteToVueRoute(item));
|
||||
|
||||
/** 路由名称 */
|
||||
export const routeName = (key: AuthRoute.RouteKey) => key;
|
||||
|
||||
/** 路由路径 */
|
||||
export function routePath(key: Exclude<AuthRoute.RouteKey, 'not-found-page'>): AuthRoute.RoutePath {
|
||||
const rootPath: AuthRoute.RoutePath = '/';
|
||||
if (key === 'root') return rootPath;
|
||||
const splitMark: AuthRoute.RouteSplitMark = '_';
|
||||
const pathSplitMark = '/';
|
||||
const path = key.split(splitMark).join(pathSplitMark);
|
||||
return (pathSplitMark + path) as AuthRoute.RoutePath;
|
||||
}
|
||||
|
||||
export { constantRoutes };
|
||||
|
Reference in New Issue
Block a user