修复一些问题,个人账号功能完善,注册功能完善,收藏,购物车功能完善,初版基本完成,投入测试

This commit is contained in:
xiaowang
2026-03-03 17:50:10 +08:00
parent b301e37468
commit b0470b8f86
23 changed files with 804 additions and 129 deletions
+13
View File
@@ -271,6 +271,19 @@ router.beforeEach((to, _from, next) => {
} else if (to.path === '/home' && !token) {
next('/')
} else {
// 对于需要认证的页面,验证token的有效性
if (requiresAuth && token) {
// 检查userInfo是否存在
const userInfo = localStorage.getItem('userInfo')
if (!userInfo) {
console.log('Token存在但userInfo不存在,清除token并跳转到登录页')
localStorage.removeItem('accessToken')
localStorage.removeItem('refreshToken')
sessionStorage.removeItem('accessToken')
next('/')
return
}
}
next()
}
}