mirror of
https://github.com/chansee97/nova-admin.git
synced 2025-04-06 03:57:54 +08:00
36 lines
855 B
TypeScript
36 lines
855 B
TypeScript
import { setLocal, getLocal, removeLocal } from './storage';
|
|
import { EnumStorageKey } from '@/enum';
|
|
const DURATION = 6 * 60 * 60;
|
|
|
|
/* 获取当前token */
|
|
export function getToken() {
|
|
return getLocal(EnumStorageKey.token);
|
|
}
|
|
/* 设置token */
|
|
export function setToken(data: string) {
|
|
setLocal(EnumStorageKey.token, data, DURATION);
|
|
}
|
|
/* 移除token */
|
|
export function removeToken() {
|
|
removeLocal(EnumStorageKey.token);
|
|
}
|
|
|
|
/* 获取用户详情 */
|
|
export function getUserInfo() {
|
|
return getLocal(EnumStorageKey.userInfo);
|
|
}
|
|
/* 设置用户详情 */
|
|
export function setUserInfo(data: any) {
|
|
setLocal(EnumStorageKey.userInfo, data);
|
|
}
|
|
/* 移除用户详情 */
|
|
export function removeUserInfo() {
|
|
removeLocal(EnumStorageKey.userInfo);
|
|
}
|
|
|
|
/** 去除用户相关缓存 */
|
|
export function clearAuthStorage() {
|
|
removeToken();
|
|
removeUserInfo();
|
|
}
|