- 移除「用户 → 推广码运营」页面(trait、子菜单、admin SPA 跳转路由) - 移除管理端 REST:/revenue/codes 列表与 generate/disable/regenerate 变更接口, 清理 rest_codes/rest_mutate_code/can_manage_codes/list_codes 死代码 - 推广码改为注册即得:bind_registered_user 内生成唯一推广码,无需后台管理 - 推广配置统一收敛到「支付&付费 → 推广返佣」设置段(现状保留,无改动) - 契约测试固化:无管理路由/页面残留 + 注册即得码
110 lines
3.0 KiB
JavaScript
110 lines
3.0 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/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,
|
|
})
|
|
|