20260819101952
This commit is contained in:
1 parent
e91fd1d8de
commit
1ffc8e1ac9
14 files changed
+258
-886
No files matched your search
@@ -2,6 +2,7 @@ import { computed, ref } from 'vue'
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
const AUTH_STORAGE_KEY = 'fms-auth'
|
||||
const LAST_LOGIN_KEY = 'fms-last-login'
|
||||
|
||||
// 兼容旧版 sessionStorage 会话:将历史会话迁移到 localStorage
|
||||
try {
|
||||
@@ -25,10 +26,20 @@ export const useAuthStore = defineStore(
|
||||
token.value = session.token ?? session.access_token ?? ''
|
||||
orgId.value = session.orgid ?? organizationId ?? ''
|
||||
user.value = session.user ?? session.user_info ?? null
|
||||
|
||||
// 单独保存最近登录信息,供登录页回填(与认证状态分离)
|
||||
try {
|
||||
const last = { orgId: orgId.value, account: user.value?.account ?? '' }
|
||||
localStorage.setItem(LAST_LOGIN_KEY, JSON.stringify(last))
|
||||
} catch {
|
||||
// Storage 不可用时静默忽略
|
||||
}
|
||||
}
|
||||
|
||||
function clearSession() {
|
||||
token.value = ''
|
||||
orgId.value = ''
|
||||
user.value = null
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
Reference in new issue
Block a user