合并代码
This commit is contained in:
@@ -198,7 +198,19 @@ const routes = [
|
||||
name: 'AgentDashboard',
|
||||
component: () => import('@/views/AgentDashboard.vue'),
|
||||
meta: {
|
||||
title: '代理后台'
|
||||
title: '代理后台',
|
||||
requiresAuth: true,
|
||||
isAgent: true
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/agent/withdrawals',
|
||||
name: 'AgentWithdrawals',
|
||||
component: () => import('@/views/AgentWithdrawals.vue'),
|
||||
meta: {
|
||||
title: '佣金提现',
|
||||
requiresAuth: true,
|
||||
isAgent: true
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -252,17 +264,33 @@ router.beforeEach(async (to, from, next) => {
|
||||
|
||||
// 检查是否需要认证
|
||||
if (to.meta.requiresAuth) {
|
||||
if (!userStore.isAuthenticated) {
|
||||
// 尝试从本地存储恢复登录状态
|
||||
await userStore.checkAuth()
|
||||
// 检查是否是代理页面
|
||||
if (to.meta.isAgent) {
|
||||
// 代理页面认证逻辑
|
||||
const agentInfo = localStorage.getItem('agentInfo')
|
||||
const agentToken = localStorage.getItem('token')
|
||||
|
||||
if (!userStore.isAuthenticated) {
|
||||
if (!agentInfo || !agentToken) {
|
||||
next({
|
||||
name: 'MyLogin',
|
||||
path: '/agent/login',
|
||||
query: { redirect: to.fullPath }
|
||||
})
|
||||
return
|
||||
}
|
||||
} else {
|
||||
// 普通用户页面认证逻辑
|
||||
if (!userStore.isAuthenticated) {
|
||||
// 尝试从本地存储恢复登录状态
|
||||
await userStore.checkAuth()
|
||||
|
||||
if (!userStore.isAuthenticated) {
|
||||
next({
|
||||
name: 'MyLogin',
|
||||
query: { redirect: to.fullPath }
|
||||
})
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user