feat: 视频问题
This commit is contained in:
@@ -100,10 +100,10 @@ router.beforeEach(async (to, from, next) => {
|
||||
}
|
||||
|
||||
// 检查是否已登录(通过 token 是否有效)
|
||||
const isAuthenticated = tokenManager.isLoggedIn()
|
||||
const authenToken = tokenManager.getToken()
|
||||
|
||||
// 路由访问控制
|
||||
if (to.meta.requiresAuth && !isAuthenticated) {
|
||||
if (to.meta.requiresAuth && !authenToken) {
|
||||
// 需要认证但未登录,跳转到登录页并记录当前路径
|
||||
next({
|
||||
path: '/login',
|
||||
@@ -113,13 +113,13 @@ router.beforeEach(async (to, from, next) => {
|
||||
}
|
||||
|
||||
// 已登录用户访问登录页,重定向到首页
|
||||
if (to.path === '/login' && isAuthenticated) {
|
||||
if (to.path === '/login' && authenToken) {
|
||||
next({ path: '/content-style/benchmark', replace: true })
|
||||
return
|
||||
}
|
||||
|
||||
// 首次访问且已登录时,同步用户信息到 store
|
||||
if (isAuthenticated && !userStore.isLoggedIn) {
|
||||
if (authenToken) {
|
||||
userStore.isLoggedIn = true
|
||||
userStore.fetchUserInfo().catch(error => {
|
||||
console.error('初始化用户信息失败:', error)
|
||||
|
||||
Reference in New Issue
Block a user