创建token统一管理类,包括增加删除和获取token

This commit is contained in:
2026-06-07 11:02:29 +08:00
parent 704e9650f9
commit 069948b749
+26
View File
@@ -0,0 +1,26 @@
export class Auth {
static readonly TokenKey : string = "Admin-Token"
/**
* 获取Token
*/
static getToken() : string {
const token = uni.getStorageSync(Auth.TokenKey)
return token == null ? "" : token as string
}
/**
* 设置Token
*/
static setToken(token : string) : void {
uni.setStorageSync(Auth.TokenKey, token)
}
/**
* 删除Token
*/
static removeToken() : void {
uni.removeStorageSync(Auth.TokenKey)
}
}