From ea7094ba50e3b4ea8c4aeb588784ce229791b516 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=97=B6=E5=90=AF=E9=BE=99?= Date: Thu, 22 Aug 2024 17:11:25 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AD=98=E5=85=A5ukeyPasswordKey,=20?= =?UTF-8?q?=E7=94=A8=E4=BA=8E=E4=BF=9D=E6=B4=BB=E4=B8=8E=E7=9B=91=E6=B5=8B?= =?UTF-8?q?=20ukey=20=E6=98=AF=E5=90=A6=E6=8B=94=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/auth.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) 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) +}