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:
78
src/router/routes/constant.ts
Normal file
78
src/router/routes/constant.ts
Normal file
@ -0,0 +1,78 @@
|
||||
import type { RouteRecordRaw } from 'vue-router';
|
||||
import { EnumRoutePath, EnumRouteTitle } from '@/enum';
|
||||
import { BlankLayout } from '@/layouts';
|
||||
import type { LoginModuleType } from '@/interface';
|
||||
import { RouteNameMap, loginModuleRegExp } from '../helpers';
|
||||
import { Login, NoPermission, NotFound, ServiceError } from '../components';
|
||||
|
||||
/**
|
||||
* 固定不变的路由
|
||||
* @description !最后一项重定向未找到的路由须放置路由的最后一项
|
||||
*/
|
||||
const constantRoutes: RouteRecordRaw[] = [
|
||||
{
|
||||
name: RouteNameMap.get('system'),
|
||||
path: EnumRoutePath.system,
|
||||
component: BlankLayout,
|
||||
redirect: { name: RouteNameMap.get('not-found') },
|
||||
meta: {
|
||||
keepAlive: true,
|
||||
title: EnumRouteTitle.system
|
||||
},
|
||||
children: [
|
||||
// 登录
|
||||
{
|
||||
name: RouteNameMap.get('login'),
|
||||
path: `${EnumRoutePath.login}/:module(/${loginModuleRegExp}/)?`,
|
||||
component: Login,
|
||||
props: route => {
|
||||
const moduleType: LoginModuleType = (route.params.module as LoginModuleType) || 'pwd-login';
|
||||
return {
|
||||
module: moduleType
|
||||
};
|
||||
},
|
||||
meta: {
|
||||
title: EnumRouteTitle.login,
|
||||
fullPage: true
|
||||
}
|
||||
},
|
||||
// 403
|
||||
{
|
||||
name: RouteNameMap.get('no-permission'),
|
||||
path: EnumRoutePath['no-permission'],
|
||||
component: NoPermission,
|
||||
meta: {
|
||||
title: EnumRouteTitle['no-permission'],
|
||||
fullPage: true
|
||||
}
|
||||
},
|
||||
// 404
|
||||
{
|
||||
name: RouteNameMap.get('not-found'),
|
||||
path: EnumRoutePath['not-found'],
|
||||
component: NotFound,
|
||||
meta: {
|
||||
title: EnumRouteTitle['not-found'],
|
||||
fullPage: true
|
||||
}
|
||||
},
|
||||
// 500
|
||||
{
|
||||
name: RouteNameMap.get('service-error'),
|
||||
path: EnumRoutePath['service-error'],
|
||||
component: ServiceError,
|
||||
meta: {
|
||||
title: EnumRouteTitle['service-error'],
|
||||
fullPage: true
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
// 匹配无效的路径重定向404
|
||||
{
|
||||
path: '/:pathMatch(.*)*',
|
||||
redirect: { name: 'not-found' }
|
||||
}
|
||||
];
|
||||
|
||||
export default constantRoutes;
|
9
src/router/routes/index.ts
Normal file
9
src/router/routes/index.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import type { RouteRecordRaw } from 'vue-router';
|
||||
import ROUTE_HOME from './routeHome';
|
||||
import customRoutes from '../modules';
|
||||
import constantRoutes from './constant';
|
||||
|
||||
/** 所有路由 */
|
||||
export const routes: RouteRecordRaw[] = [...customRoutes, ...constantRoutes];
|
||||
|
||||
export { ROUTE_HOME, customRoutes };
|
18
src/router/routes/routeHome.ts
Normal file
18
src/router/routes/routeHome.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import type { CustomRoute } from '@/interface';
|
||||
import { EnumRoutePath, EnumRouteTitle } from '@/enum';
|
||||
import { RouteNameMap } from '../helpers';
|
||||
import { DashboardAnalysis } from '../components';
|
||||
|
||||
/** 路由首页 */
|
||||
const ROUTE_HOME: CustomRoute = {
|
||||
name: RouteNameMap.get('dashboard_analysis'),
|
||||
path: EnumRoutePath.dashboard_analysis,
|
||||
component: DashboardAnalysis,
|
||||
meta: {
|
||||
keepAlive: true,
|
||||
requiresAuth: true,
|
||||
title: EnumRouteTitle.dashboard_analysis
|
||||
}
|
||||
};
|
||||
|
||||
export default ROUTE_HOME;
|
Reference in New Issue
Block a user