Merge pull request #126 from hotlcc/develop-20240516-页面优化

This commit is contained in:
jxxghp
2024-05-16 10:57:33 +08:00
committed by GitHub
2 changed files with 4 additions and 2 deletions

View File

@@ -23,7 +23,8 @@ const progressDialog = ref(false)
function logout() {
// 清除登录状态信息
store.dispatch('auth/clearToken')
// 主动登出时清除路由标记
store.state.auth.originalPath = null
// 重定向到登录页面或其他适当的页面
router.push('/login')
}

View File

@@ -159,10 +159,11 @@ const router = createRouter({
// 路由导航守卫
router.beforeEach((to, from, next) => {
// 总是记录非login路由
if (to.fullPath != '/login') store.state.auth.originalPath = to.fullPath
const isAuthenticated = store.state.auth.token !== null
if (to.meta.requiresAuth && !isAuthenticated) {
store.state.auth.originalPath = to.fullPath
next('/login')
}
else {