创建token统一管理类,包括增加删除和获取token
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user