diff --git a/src/utils/auth.ts b/src/utils/auth.ts index bda2328..2d96ffb 100644 --- a/src/utils/auth.ts +++ b/src/utils/auth.ts @@ -15,24 +15,27 @@ export function setToken(token: string) { export function removeToken() { return sessionStorage.removeItem(tokenKey) } - +// 为什么这里使用 localStorage, 防止刷新后丢失 export function getTrxToken() { - return sessionStorage.getItem(trxTokenKey) + return localStorage.getItem(trxTokenKey) } export function setTrxToken(token: string) { - return sessionStorage.setItem(trxTokenKey, token) + return localStorage.setItem(trxTokenKey, token) } export function removeTrxToken() { - localStorage.removeItem(ukeyPasswordKey) - return sessionStorage.removeItem(trxTokenKey) + removeUkeyPassword() + return localStorage.removeItem(trxTokenKey) } -export function getUkeyPassword() { - return decrypt(sessionStorage.getItem(ukeyPasswordKey)) -} // 用于保活与监测 ukey 是否拔出 export function setUkeyPassword(password: string) { return localStorage.setItem(ukeyPasswordKey, encrypt(password)) } +export function getUkeyPassword() { + return decrypt(localStorage.getItem(ukeyPasswordKey)) +} +export function removeUkeyPassword() { + return localStorage.removeItem(ukeyPasswordKey) +}