Align admin section default routes

This commit is contained in:
kate522 committed 2026-07-06 11:29:33 +08:00
1 parent ca0a550af8
commit 4043de2473
2 files changed
+58 -12

No files matched your search

+16 -1
View File
@@ -1,5 +1,5 @@
import { createRouter, createWebHashHistory } from 'vue-router'
import { getAllAdminPages } from '@/constants/admin-sections'
import { getAdminSections, getAllAdminPages } from '@/constants/admin-sections'
import { componentLoaders } from './component-loaders/index.js'
const ADMIN_DEFAULT_ROUTE = '/global/common'
@@ -57,8 +57,23 @@ function createRouteMeta(page) {
return meta
}
function createSectionRedirectRoutes() {
const seenPaths = new Set(['/'])
return getAdminSections()
.filter((section) => section.defaultRoute && section.route !== section.defaultRoute && !seenPaths.has(section.route))
.map((section) => {
seenPaths.add(section.route)
return {
path: section.route,
redirect: section.defaultRoute,
}
})
}
const routes = [
{ path: '/', redirect: ADMIN_DEFAULT_ROUTE },
...createSectionRedirectRoutes(),
...getAllAdminPages().map((page) => ({
path: page.route,
name: page.name,