refactor: ♻️ 优化请求工具类

This commit is contained in:
ray
2024-10-13 11:18:19 +08:00
parent a7757213f2
commit 3dec53af38
6 changed files with 90 additions and 46 deletions

19
src/utils/auth.ts Normal file
View File

@@ -0,0 +1,19 @@
const TOKEN_KEY = "app-token";
function getToken(): string {
return uni.getStorageSync(TOKEN_KEY) || "";
}
function setToken(token: string) {
return uni.setStorageSync(TOKEN_KEY, token);
}
function clearToken() {
return uni.removeStorageSync(TOKEN_KEY);
}
function isLogin(): boolean {
return !!getToken();
}
export { getToken, setToken, clearToken, isLogin };