refactor(projects): new storage system [新的本地数据存储系统]

This commit is contained in:
Soybean
2022-11-17 01:47:06 +08:00
parent 7a58035514
commit 971915948b
23 changed files with 166 additions and 191 deletions

View File

@ -0,0 +1,25 @@
import { localStg } from '@/utils';
/** 获取token */
export function getToken() {
return localStg.get('token') || '';
}
/** 获取用户信息 */
export function getUserInfo() {
const emptyInfo: Auth.UserInfo = {
userId: '',
userName: '',
userRole: 'user'
};
const userInfo: Auth.UserInfo = localStg.get('userInfo') || emptyInfo;
return userInfo;
}
/** 去除用户相关缓存 */
export function clearAuthStorage() {
localStg.remove('token');
localStg.remove('refreshToken');
localStg.remove('userInfo');
}