Files
wordpress-theme-aksrt/assets/admin/src/router/index.js
T
kate522 381256ed59 feat(admin): host the ban/report settings page in the SPA schema
The users-interaction sidebar entry 禁封/举报 was a redirect stub; it is
now a schema-driven settings page replicating the reference theme
field-for-field:

- user_ban_s / user_report_s switches, ban_preset_reason and
  ban_appeal_keys as repeatable group rows ({t}), ban_appeal_desc and
  user_report_desc HTML textareas with the reference default copy, and
  user_report_img_s — keys, labels, help texts, defaults and ordering
  all mirrored in SchemaUsers.php and the SPA report.js schema
- UserRuntime::ban_settings()/report_settings() and
  BanAppeal::settings() read the new group-array values with fallback
  to the previous line/comma formats
- delete the self-built SPA queue pages (UsersBan, UsersReport,
  ReportDetailDrawer, UsersMessages) that the reference theme does not
  have; legacy /users/report bookmarks still redirect to the native page
- contract tests: lock the schema keys/labels, the schemaPage mount and
  the deleted-file state; drop reads of removed components
2026-09-19 22:24:55 +08:00

111 lines
3.2 KiB
JavaScript

import { createRouter, createWebHashHistory } from 'vue-router'
import { getAdminSections, getAllAdminPages } from '@/constants/admin-sections'
import { componentLoaders } from './component-loaders/index.js'
const ADMIN_DEFAULT_ROUTE = '/global/common'
function resolveComponent(page) {
if (componentLoaders[page.component]) {
return componentLoaders[page.component]
}
// Log missing component for debugging — avoids silent fallback to DeferredPage
if (page.component && page.component !== 'DeferredPage') {
console.warn(
`[AKSRT Route] Component "${page.component}" not found in componentLoaders for route "${page.route}". Falling back to DeferredPage.`
)
}
return componentLoaders.DeferredPage
}
function createRouteMeta(page) {
const meta = {
title: page.title,
section: page.sectionKey || '',
desc: page.desc || '',
status: page.status || 'available',
secondaryEntry: page.secondaryEntry === true,
}
if (page.compatSourceSection) {
meta.compatSourceSection = page.compatSourceSection
}
if (page.canonicalDomain) {
meta.canonicalDomain = page.canonicalDomain
}
if (page.section) {
meta.section = page.section
}
if (page.component === 'DeferredPage') {
meta.deferred = true
meta.deferredProps = {
title: page.title,
description: page.desc || '',
icon: page.iconClass || 'fa fas fa-compass',
phase: page.phase || '',
status: page.status || 'deferred',
dependsOn: page.dependsOn || [],
reason: page.reason || '',
features: page.features || [],
}
}
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,
}
})
}
/**
* Old SPA ops routes → native WP admin pages.
* Bookmarks under order-related paths land on NativeOpsRedirect.
* (封禁/举报 as a sidebar entry lives in constants/sections/users.js → /users/ban.)
*/
const NATIVE_OPS_REDIRECTS = [
{ path: '/users/messages', title: '消息中心', nativeAdminPath: 'users.php?page=aksrt_messages' },
{ path: '/users/referral-codes', title: '推广码运营', nativeAdminPath: 'users.php?page=aksrt_referral_codes' },
{ path: '/users/report', title: '禁封/举报', nativeAdminPath: 'users.php?page=aksrt_user_ban' },
]
const routes = [
{ path: '/', redirect: ADMIN_DEFAULT_ROUTE },
...createSectionRedirectRoutes(),
...getAllAdminPages().map((page) => ({
path: page.route,
name: page.name,
component: resolveComponent(page),
meta: createRouteMeta(page),
})),
...NATIVE_OPS_REDIRECTS.map((item) => ({
path: item.path,
name: `NativeRedirect_${item.path.replace(/\W+/g, '_')}`,
component: componentLoaders.NativeOpsRedirect,
meta: {
title: item.title,
nativeAdminPath: item.nativeAdminPath,
status: 'redirect',
},
})),
]
export default createRouter({
history: createWebHashHistory(),
routes,
})