This commit is contained in:
zlwu committed 2026-05-21 11:09:29 +08:00
1 parent ee73f69759
commit 74f751d0d1
70 files changed
+9340 -6930

No files matched your search

+8 -2
View File
@@ -22,6 +22,7 @@ import { setPageTitle } from '@/utils/router'
import { resetRouterState } from '@/router/guards/beforeEach'
import { useMenuStore } from './menu'
import { StorageConfig } from '@/utils/storage/storage-config'
import { fetchLogout } from '@/api/auth'
/**
* 用户状态管理
@@ -101,9 +102,14 @@ export const useUserStore = defineStore(
/**
* 退出登录
* 清空所有用户相关状态并跳转到登录页
* 通知后端撤销 Redis 会话,然后清空所有用户相关状态并跳转到登录页
*/
const logOut = () => {
const logOut = async () => {
// 先通知后端撤销 Redis 会话(不等待结果,失败也不阻塞退出)
if (accessToken.value) {
fetchLogout().catch(() => {})
}
// 保存当前用户 ID,用于下次登录时判断是否为同一用户
const currentUserId = info.value.userId
if (currentUserId) {