mirror of
https://github.com/soybeanjs/soybean-admin.git
synced 2025-09-18 09:46:36 +08:00
41 lines
1.0 KiB
TypeScript
41 lines
1.0 KiB
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';
|
|
|
|
/**
|
|
* custom routes
|
|
*
|
|
* @link https://github.com/soybeanjs/elegant-router?tab=readme-ov-file#custom-route
|
|
*/
|
|
const customRoutes: CustomRoute[] = [];
|
|
|
|
/** create routes when the auth route mode is static */
|
|
export function createStaticRoutes() {
|
|
const constantRoutes: ElegantRoute[] = [];
|
|
|
|
const authRoutes: ElegantRoute[] = [];
|
|
|
|
[...customRoutes, ...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);
|
|
}
|