2021-10-11 17:51:16 +08:00
|
|
|
import type { RouteRecordRaw } from 'vue-router';
|
2022-01-06 11:22:14 +08:00
|
|
|
import { transformAuthRoutesToVueRoutes } from '@/utils';
|
2022-01-03 22:20:10 +08:00
|
|
|
import constantRoutes from './constant';
|
2021-11-28 12:17:48 +08:00
|
|
|
|
2021-10-11 17:51:16 +08:00
|
|
|
/** 所有路由 */
|
2022-01-06 11:22:14 +08:00
|
|
|
export const routes: RouteRecordRaw[] = transformAuthRoutesToVueRoutes(constantRoutes);
|
2021-10-11 17:51:16 +08:00
|
|
|
|
2022-01-06 02:00:42 +08:00
|
|
|
/** 路由名称 */
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2022-01-03 22:20:10 +08:00
|
|
|
export { constantRoutes };
|