34 lines
869 B
TypeScript
34 lines
869 B
TypeScript
import type { CustomRoute, ElegantConstRoute, ElegantRoute } from '@elegant-router/types';
|
|
import { generatedRoutes } from '../elegant/routes';
|
|
import { layouts, views } from '../elegant/imports';
|
|
import { transformElegantRoutesToVueRoutes } from '../elegant/transform';
|
|
|
|
/** create routes when the auth route mode is static */
|
|
export function createStaticRoutes() {
|
|
const constantRoutes: ElegantRoute[] = [];
|
|
|
|
const authRoutes: ElegantRoute[] = [];
|
|
|
|
[...generatedRoutes].forEach(item => {
|
|
if (item.meta?.constant) {
|
|
constantRoutes.push(item);
|
|
} else {
|
|
authRoutes.push(item);
|
|
}
|
|
});
|
|
|
|
return {
|
|
constantRoutes,
|
|
authRoutes
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Get auth vue routes
|
|
*
|
|
* @param routes Elegant routes
|
|
*/
|
|
export function getAuthVueRoutes(routes: ElegantConstRoute[]) {
|
|
return transformElegantRoutesToVueRoutes(routes, layouts, views);
|
|
}
|