fix: 存入ukeyPasswordKey, 用于保活与监测 ukey 是否拔出

develop
时启龙 2024-08-22 17:11:25 +08:00
parent 1359fe4f99
commit ea7094ba50
1 changed files with 11 additions and 8 deletions

View File

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