This commit is contained in:
2026-09-13 02:28:46 +08:00
parent df5492a48a
commit 42f9530a59
27 changed files with 979 additions and 149 deletions
+7
View File
@@ -1,4 +1,8 @@
import { STORAGE_KEYS } from './config'
import { logger } from './logger'
// 日志模块名
const LOG = 'auth'
export interface TokenData {
accessToken: string
@@ -22,12 +26,15 @@ export function setTokens(data: TokenData): void {
wx.setStorageSync(STORAGE_KEYS.ACCESS_TOKEN, data.accessToken)
wx.setStorageSync(STORAGE_KEYS.REFRESH_TOKEN, data.refreshToken)
wx.setStorageSync(STORAGE_KEYS.EXPIRE_TIME, data.expireTime)
// 不打印 token 明文,只记录过期时间便于核对单位(秒/毫秒)
logger.debug(LOG, 'token 已写入, expireTime=', data.expireTime)
}
export function clearTokens(): void {
wx.removeStorageSync(STORAGE_KEYS.ACCESS_TOKEN)
wx.removeStorageSync(STORAGE_KEYS.REFRESH_TOKEN)
wx.removeStorageSync(STORAGE_KEYS.EXPIRE_TIME)
logger.info(LOG, 'token 已清理')
}
export function isLoggedIn(): boolean {