feat: 小程序移除管理后台入口,新增admin-web前端项目
将管理后台功能从微信小程序中剥离,独立为Vue.js前端项目admin-web Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
102
admin-web/src/router/index.js
Normal file
102
admin-web/src/router/index.js
Normal file
@@ -0,0 +1,102 @@
|
||||
import Vue from 'vue'
|
||||
import VueRouter from 'vue-router'
|
||||
import { store, isLoggedIn, isAdmin } from '@/store'
|
||||
|
||||
Vue.use(VueRouter)
|
||||
|
||||
const Login = () => import('@/views/Login.vue')
|
||||
const Register = () => import('@/views/Register.vue')
|
||||
const AppLayout = () => import('@/layouts/AppLayout.vue')
|
||||
|
||||
const Home = () => import('@/views/Home.vue')
|
||||
const Detect = () => import('@/views/Detect.vue')
|
||||
const History = () => import('@/views/History.vue')
|
||||
const Inbox = () => import('@/views/Inbox.vue')
|
||||
const Batch = () => import('@/views/Batch.vue')
|
||||
const Profile = () => import('@/views/Profile.vue')
|
||||
|
||||
const AdminDashboard = () => import('@/views/admin/Dashboard.vue')
|
||||
const AdminReview = () => import('@/views/admin/Review.vue')
|
||||
const AdminSamples = () => import('@/views/admin/Samples.vue')
|
||||
const AdminUsers = () => import('@/views/admin/Users.vue')
|
||||
|
||||
const routes = [
|
||||
{ path: '/login', name: 'login', component: Login, meta: { public: true } },
|
||||
{ path: '/register', name: 'register', component: Register, meta: { public: true } },
|
||||
{
|
||||
path: '/',
|
||||
component: AppLayout,
|
||||
children: [
|
||||
{ path: '', name: 'home', component: Home, meta: { title: '首页' } },
|
||||
{ path: 'detect', name: 'detect', component: Detect, meta: { title: '信息发布' } },
|
||||
{ path: 'history', name: 'history', component: History, meta: { title: '发布历史' } },
|
||||
{ path: 'inbox', name: 'inbox', component: Inbox, meta: { title: '私信收件' } },
|
||||
{ path: 'batch', name: 'batch', component: Batch, meta: { title: '批量识别' } },
|
||||
{ path: 'profile', name: 'profile', component: Profile, meta: { title: '个人中心' } },
|
||||
{
|
||||
path: 'admin/dashboard',
|
||||
name: 'admin-dashboard',
|
||||
component: AdminDashboard,
|
||||
meta: { title: '运营看板', requiresAdmin: true }
|
||||
},
|
||||
{
|
||||
path: 'admin/review',
|
||||
name: 'admin-review',
|
||||
component: AdminReview,
|
||||
meta: { title: '复核与申诉', requiresAdmin: true }
|
||||
},
|
||||
{
|
||||
path: 'admin/samples',
|
||||
name: 'admin-samples',
|
||||
component: AdminSamples,
|
||||
meta: { title: '样本管理', requiresAdmin: true }
|
||||
},
|
||||
{
|
||||
path: 'admin/users',
|
||||
name: 'admin-users',
|
||||
component: AdminUsers,
|
||||
meta: { title: '用户管理', requiresAdmin: true }
|
||||
}
|
||||
]
|
||||
},
|
||||
{ path: '*', redirect: '/' }
|
||||
]
|
||||
|
||||
const router = new VueRouter({
|
||||
mode: 'hash',
|
||||
routes
|
||||
})
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
if (to.meta && to.meta.public) {
|
||||
if (isLoggedIn()) {
|
||||
next({ path: '/' })
|
||||
return
|
||||
}
|
||||
next()
|
||||
return
|
||||
}
|
||||
|
||||
if (!isLoggedIn()) {
|
||||
next({ path: '/login' })
|
||||
return
|
||||
}
|
||||
|
||||
if (to.matched.some((record) => record.meta && record.meta.requiresAdmin)) {
|
||||
if (!isAdmin()) {
|
||||
next({ path: '/' })
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
next()
|
||||
})
|
||||
|
||||
router.afterEach((to) => {
|
||||
const title = (to.meta && to.meta.title) || ''
|
||||
document.title = title ? `${title} · 内容风控管理后台` : '内容风控管理后台'
|
||||
// touch store so admin guard re-evaluates when user data changes
|
||||
void store.user
|
||||
})
|
||||
|
||||
export default router
|
||||
Reference in New Issue
Block a user