XiaoDaiGua-Ray 403fdd589a feat!: rebuild Ray Template as a monorepo
Share workspace packages between Ray Admin and the interactive docs.

BREAKING CHANGE: v6 is a new major line. v5 stays on legacy/v5.
2026-11-04 14:01:28 +08:00

52 lines
1.5 KiB
TypeScript

import Layout from '@/layout'
import type { RouteRecordRaw } from 'vue-router'
import { appExpandRoutes } from './app-route-modules'
import {
NOT_FOUND_ROUTE_PATH,
ROUTE_MANAGEMENT_JSON_PATH,
ROUTE_MANAGEMENT_PATH,
} from './constant'
const legacyRedirects = [
{ path: '/tables', redirect: '/tables/basic' },
{ path: '/table', redirect: '/tables/basic' },
{ path: '/table-pro', redirect: '/tables/remote' },
{ path: '/mock-demo', redirect: '/tables/remote' },
{ path: '/table-auto-height', redirect: '/tables/auto-height' },
]
export const constantRoutes: RouteRecordRaw[] = [
{ path: '/', name: 'RLogin', component: () => import('@/views/login') },
{ path: '/', name: 'RLayout', component: Layout },
]
export function getLayoutRoutes(): RouteRecordRaw[] {
const routes = appExpandRoutes()
const occupiedPaths = new Set(
routes.flatMap(({ path, alias }) => [
path.toLowerCase(),
...[alias ?? []].flat().map((entry) => entry.toLowerCase()),
]),
)
return [
...(routes as unknown as RouteRecordRaw[]),
...legacyRedirects.filter(
({ path, redirect }) =>
!occupiedPaths.has(path) && occupiedPaths.has(redirect),
),
{ path: ROUTE_MANAGEMENT_PATH, redirect: ROUTE_MANAGEMENT_JSON_PATH },
{
path: NOT_FOUND_ROUTE_PATH,
name: 'RNotFound',
component: () => import('@/views/error/views/Error404'),
meta: {
i18nKey: 'menu.Error',
icon: 'status/error',
hidden: true,
sameLevel: true,
},
},
]
}