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

+42 -11
View File
@@ -66,6 +66,19 @@ const COMPAT_PAGE_ORDER = [
const COMPAT_PAGE_ORDER_INDEX = new Map(COMPAT_PAGE_ORDER.map((key, index) => [key, index]))
const SECTION_DEFAULT_CHILDREN = {
global: 'global-common',
page_display: 'page-display-homepage',
'post-list': 'post-list-page',
permissions: 'permissions-comment',
users: 'users-auth',
payment: 'payment-gateway',
shop: 'shop-products',
forum: 'forum-boards',
extensions: 'extensions-ip',
'tools-compat': 'tools-import-export',
}
const DEMOTED_PAGE_OVERRIDES = {
'post-list-submit': {
label: '前台投稿(兼容)',
@@ -184,16 +197,30 @@ function pickChildren(section, childKeys = []) {
}))
}
function attachSectionDefaultRoute(section) {
const defaultChildKey = SECTION_DEFAULT_CHILDREN[section.key]
const defaultChild = (section.children || []).find((child) => child.key === defaultChildKey)
if (!defaultChild) {
return section
}
return {
...section,
defaultRoute: defaultChild.route,
}
}
const primarySections = [
globalSection,
pageDisplaySection,
withoutChildren(postListSection, DEMOTED_CHILDREN['post-list']),
permissionsSection,
withoutChildren(usersSection, DEMOTED_CHILDREN.users),
withoutChildren(paymentSection, DEMOTED_CHILDREN.payment),
withoutChildren(shopSection, DEMOTED_CHILDREN.shop),
withoutChildren(forumSection, DEMOTED_CHILDREN.forum),
withoutChildren(extensionsSection, DEMOTED_CHILDREN.extensions),
attachSectionDefaultRoute(globalSection),
attachSectionDefaultRoute(pageDisplaySection),
attachSectionDefaultRoute(withoutChildren(postListSection, DEMOTED_CHILDREN['post-list'])),
attachSectionDefaultRoute(permissionsSection),
attachSectionDefaultRoute(withoutChildren(usersSection, DEMOTED_CHILDREN.users)),
attachSectionDefaultRoute(withoutChildren(paymentSection, DEMOTED_CHILDREN.payment)),
attachSectionDefaultRoute(withoutChildren(shopSection, DEMOTED_CHILDREN.shop)),
attachSectionDefaultRoute(withoutChildren(forumSection, DEMOTED_CHILDREN.forum)),
attachSectionDefaultRoute(withoutChildren(extensionsSection, DEMOTED_CHILDREN.extensions)),
]
const compatChildren = [
@@ -212,19 +239,23 @@ const compatChildren = [
return leftIndex - rightIndex
})
export const compatToolsSection = {
export const compatToolsSection = attachSectionDefaultRoute({
key: 'tools-compat',
label: '兼容&工具',
icon: toolsSection.icon,
route: '/tools',
children: compatChildren,
}
})
export const ADMIN_SECTIONS = [
...primarySections,
compatToolsSection,
]
export function getAdminSections() {
return ADMIN_SECTIONS
}
export function getAllAdminPages() {
const pages = []