a95e8b2b73
Admin: - New CreditManagement.vue (tabs: rates, packages, plans, user credits, consumptions, stats) - Sidebar menu + router entry - Full CRUD for credit packages and subscription plans - User credit balance adjustment - Consumption log viewer User: - Credits.vue replaces Upgrade.vue (package purchase, subscription, history tabs) - Credit balance display in topbar + dashboard header CTA card - Navigation restructured: discovery first - Profile redirects to /credits - Dashboard upgrade dialog simplified to redirect to /credits
111 lines
3.3 KiB
JavaScript
111 lines
3.3 KiB
JavaScript
import { createRouter, createWebHistory } from 'vue-router'
|
|
import AdminLayout from '@/layouts/AdminLayout.vue'
|
|
|
|
const routes = [
|
|
{ path: '/login', redirect: to => ({ path: '/', query: to.query }) },
|
|
{ path: '/', name: 'Landing', component: () => import('@/views/Landing.vue') },
|
|
{
|
|
path: '/dashboard',
|
|
component: AdminLayout,
|
|
meta: { requiresAuth: true },
|
|
children: [
|
|
{ path: '', name: 'Dashboard', component: () => import('@/views/Dashboard.vue'), meta: { title: '概览' } },
|
|
]
|
|
},
|
|
{
|
|
path: '/users',
|
|
component: AdminLayout,
|
|
meta: { requiresAuth: true },
|
|
children: [
|
|
{ path: '', name: 'Users', component: () => import('@/views/Users.vue'), meta: { title: '用户' } },
|
|
]
|
|
},
|
|
{
|
|
path: '/stats',
|
|
component: AdminLayout,
|
|
meta: { requiresAuth: true },
|
|
children: [
|
|
{ path: '', name: 'Stats', component: () => import('@/views/Stats.vue'), meta: { title: '统计' } },
|
|
]
|
|
},
|
|
{
|
|
path: '/logs',
|
|
component: AdminLayout,
|
|
meta: { requiresAuth: true },
|
|
children: [
|
|
{ path: '', name: 'Logs', component: () => import('@/views/Logs.vue'), meta: { title: '日志' } },
|
|
]
|
|
},
|
|
{
|
|
path: '/payments',
|
|
component: AdminLayout,
|
|
meta: { requiresAuth: true },
|
|
children: [
|
|
{ path: '', name: 'Payments', component: () => import('@/views/Payments.vue'), meta: { title: '支付管理' } },
|
|
]
|
|
},
|
|
{
|
|
path: '/credits',
|
|
component: AdminLayout,
|
|
meta: { requiresAuth: true },
|
|
children: [
|
|
{ path: '', name: 'Credits', component: () => import('@/views/CreditManagement.vue'), meta: { title: '信用管理' } },
|
|
]
|
|
},
|
|
{
|
|
path: '/config',
|
|
component: AdminLayout,
|
|
meta: { requiresAuth: true },
|
|
children: [
|
|
{ path: '', name: 'Config', component: () => import('@/views/Config.vue'), meta: { title: '配置' } },
|
|
]
|
|
},
|
|
{
|
|
path: '/quota',
|
|
component: AdminLayout,
|
|
meta: { requiresAuth: true },
|
|
children: [
|
|
{ path: '', name: 'Quota', component: () => import('@/views/Quota.vue'), meta: { title: '翻译配额' } },
|
|
]
|
|
},
|
|
{
|
|
path: '/certifications',
|
|
component: AdminLayout,
|
|
meta: { requiresAuth: true },
|
|
children: [
|
|
{ path: '', name: 'Certifications', component: () => import('@/views/Certifications.vue'), meta: { title: '认证审核' } },
|
|
]
|
|
},
|
|
{
|
|
path: '/invoices',
|
|
component: AdminLayout,
|
|
meta: { requiresAuth: true },
|
|
children: [
|
|
{ path: '', name: 'Invoices', component: () => import('@/views/Invoices.vue'), meta: { title: '发票管理' } },
|
|
]
|
|
},
|
|
{
|
|
path: '/system/search-config',
|
|
component: AdminLayout,
|
|
meta: { requiresAuth: true },
|
|
children: [
|
|
{ path: '', name: 'SearchConfig', component: () => import('@/views/SearchConfig.vue'), meta: { title: '搜索配置' } },
|
|
{ path: 'ai-providers', name: 'AIProviders', component: () => import('@/views/AIProviders.vue'), meta: { title: 'AI 模型配置' } },
|
|
]
|
|
},
|
|
]
|
|
|
|
const router = createRouter({ history: createWebHistory('/admin/'), routes })
|
|
|
|
router.beforeEach((to, from, next) => {
|
|
if (to.meta?.requiresAuth) {
|
|
const token = localStorage.getItem('admin_token')
|
|
if (!token) next({ name: 'Login', query: { redirect: to.fullPath } })
|
|
else next()
|
|
} else {
|
|
next()
|
|
}
|
|
})
|
|
|
|
export default router
|