mirror of
https://github.com/soybeanjs/soybean-admin.git
synced 2025-10-17 23:23:42 +08:00
refactor(projects): 单独路由逻辑重构、路由转换函数优化
This commit is contained in:
@@ -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