mirror of
https://github.com/m-xlsea/ruoyi-plus-soybean.git
synced 2025-09-24 07:49:47 +08:00
feat(projects): 1.0 beta
This commit is contained in:
@ -1,78 +1,59 @@
|
||||
import { getLoginModuleRegExp } from '@/utils';
|
||||
import type { ElegantConstRoute, ElegantRoute, CustomRoute } from '@elegant-router/types';
|
||||
import { generatedRoutes } from '../elegant/routes';
|
||||
import { layouts, views } from '../elegant/imports';
|
||||
import { transformElegantRoutesToVueRoutes } from '../elegant/transform';
|
||||
|
||||
/** 根路由: / */
|
||||
export const ROOT_ROUTE: AuthRoute.Route = {
|
||||
export const ROOT_ROUTE: CustomRoute = {
|
||||
name: 'root',
|
||||
path: '/',
|
||||
redirect: import.meta.env.VITE_ROUTE_HOME_PATH,
|
||||
redirect: '/home',
|
||||
meta: {
|
||||
title: 'Root'
|
||||
title: 'root',
|
||||
constant: true
|
||||
}
|
||||
};
|
||||
|
||||
/** 固定的路由 */
|
||||
export const constantRoutes: AuthRoute.Route[] = [
|
||||
const customRoutes: CustomRoute[] = [
|
||||
ROOT_ROUTE,
|
||||
{
|
||||
name: 'login',
|
||||
path: '/login',
|
||||
component: 'self',
|
||||
props: route => {
|
||||
const moduleType = (route.params.module as UnionKey.LoginModule) || 'pwd-login';
|
||||
return {
|
||||
module: moduleType
|
||||
};
|
||||
},
|
||||
meta: {
|
||||
title: '登录',
|
||||
dynamicPath: `/login/:module(${getLoginModuleRegExp()})?`,
|
||||
singleLayout: 'blank'
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'constant-page',
|
||||
path: '/constant-page',
|
||||
component: 'self',
|
||||
meta: {
|
||||
title: '固定页面',
|
||||
singleLayout: 'blank'
|
||||
}
|
||||
},
|
||||
{
|
||||
name: '403',
|
||||
path: '/403',
|
||||
component: 'self',
|
||||
meta: {
|
||||
title: '无权限',
|
||||
singleLayout: 'blank'
|
||||
}
|
||||
},
|
||||
{
|
||||
name: '404',
|
||||
path: '/404',
|
||||
component: 'self',
|
||||
meta: {
|
||||
title: '未找到',
|
||||
singleLayout: 'blank'
|
||||
}
|
||||
},
|
||||
{
|
||||
name: '500',
|
||||
path: '/500',
|
||||
component: 'self',
|
||||
meta: {
|
||||
title: '服务器错误',
|
||||
singleLayout: 'blank'
|
||||
}
|
||||
},
|
||||
// 匹配无效路径的路由
|
||||
{
|
||||
name: 'not-found',
|
||||
path: '/:pathMatch(.*)*',
|
||||
component: 'blank',
|
||||
component: 'layout.blank$view.404',
|
||||
meta: {
|
||||
title: '未找到',
|
||||
singleLayout: 'blank'
|
||||
title: 'not-found',
|
||||
constant: true
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
/**
|
||||
* create routes
|
||||
*/
|
||||
export function createRoutes() {
|
||||
const constantRoutes: ElegantRoute[] = [];
|
||||
|
||||
const authRoutes: ElegantRoute[] = [];
|
||||
|
||||
[...customRoutes, ...generatedRoutes].forEach(item => {
|
||||
if (item.meta?.constant) {
|
||||
constantRoutes.push(item);
|
||||
} else {
|
||||
authRoutes.push(item);
|
||||
}
|
||||
});
|
||||
|
||||
const constantVueRoutes = transformElegantRoutesToVueRoutes(constantRoutes, layouts, views);
|
||||
|
||||
return {
|
||||
constantVueRoutes,
|
||||
authRoutes
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* get auth vue routes
|
||||
* @param routes elegant routes
|
||||
*/
|
||||
export function getAuthVueRoutes(routes: ElegantConstRoute[]) {
|
||||
return transformElegantRoutesToVueRoutes(routes, layouts, views);
|
||||
}
|
||||
|
Reference in New Issue
Block a user