后台界面独立
This commit is contained in:
@@ -3,6 +3,7 @@ import { createRouter, createWebHistory } from 'vue-router'
|
||||
const router = createRouter({
|
||||
history: createWebHistory(),
|
||||
routes: [
|
||||
{ path: '/admin', redirect: '/admin/dashboard' },
|
||||
{ path: '/', name: 'home', component: () => import('@/views/public/HomeView.vue') },
|
||||
{ path: '/login', name: 'login', component: () => import('@/views/account/LoginView.vue') },
|
||||
{ path: '/listings', name: 'listings', component: () => import('@/views/public/ListingsView.vue') },
|
||||
@@ -17,16 +18,39 @@ const router = createRouter({
|
||||
{ path: '/seller/listings/create', name: 'seller-listing-create', component: () => import('@/views/seller/SellerListingCreateView.vue') },
|
||||
{ path: '/seller/handoffs', name: 'seller-handoffs', component: () => import('@/views/seller/SellerHandoffsView.vue') },
|
||||
{ path: '/seller/earnings', name: 'seller-earnings', component: () => import('@/views/seller/SellerEarningsView.vue') },
|
||||
{ path: '/admin/login', name: 'admin-login', component: () => import('@/views/admin/AdminLoginView.vue') },
|
||||
{ path: '/admin/dashboard', name: 'admin-dashboard', component: () => import('@/views/admin/AdminDashboardView.vue') },
|
||||
{ path: '/admin/listings/review', name: 'admin-listing-review', component: () => import('@/views/admin/AdminListingReviewView.vue') },
|
||||
{ path: '/admin/disputes', name: 'admin-disputes', component: () => import('@/views/admin/AdminDisputesView.vue') },
|
||||
{ path: '/admin/system-configs', name: 'admin-system-configs', component: () => import('@/views/admin/AdminSystemConfigsView.vue') },
|
||||
{ path: '/admin/login', name: 'admin-login', component: () => import('@/views/admin/AdminLoginView.vue'), meta: { layout: 'blank' } },
|
||||
{
|
||||
path: '/admin/dashboard',
|
||||
name: 'admin-dashboard',
|
||||
component: () => import('@/views/admin/AdminDashboardView.vue'),
|
||||
meta: { layout: 'admin', requiresAdmin: true },
|
||||
},
|
||||
{
|
||||
path: '/admin/listings/review',
|
||||
name: 'admin-listing-review',
|
||||
component: () => import('@/views/admin/AdminListingReviewView.vue'),
|
||||
meta: { layout: 'admin', requiresAdmin: true },
|
||||
},
|
||||
{
|
||||
path: '/admin/disputes',
|
||||
name: 'admin-disputes',
|
||||
component: () => import('@/views/admin/AdminDisputesView.vue'),
|
||||
meta: { layout: 'admin', requiresAdmin: true },
|
||||
},
|
||||
{
|
||||
path: '/admin/system-configs',
|
||||
name: 'admin-system-configs',
|
||||
component: () => import('@/views/admin/AdminSystemConfigsView.vue'),
|
||||
meta: { layout: 'admin', requiresAdmin: true },
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
router.beforeEach((to) => {
|
||||
if (to.path.startsWith('/admin') && to.path !== '/admin/login') {
|
||||
if (to.path === '/admin/login' && localStorage.getItem('admin_access_token')) {
|
||||
return '/admin/dashboard'
|
||||
}
|
||||
if (to.meta.requiresAdmin) {
|
||||
const token = localStorage.getItem('admin_access_token')
|
||||
if (!token) {
|
||||
return '/admin/login'
|
||||
|
||||
Reference in New Issue
Block a user