gtsoft-snail-job-admin/src/store/modules/auth/shared.ts

28 lines
549 B
TypeScript
Raw Normal View History

2024-03-08 17:59:45 +08:00
import { localStg } from '@/utils/storage';
/** Get token */
export function getToken() {
return localStg.get('token') || '';
}
/** Get user info */
export function getUserInfo() {
const emptyInfo: Api.Auth.UserInfo = {
id: '',
mode: '',
username: '',
role: '',
namespaceIds: []
2024-03-08 17:59:45 +08:00
};
const userInfo = localStg.get('userInfo') || emptyInfo;
return userInfo;
}
/** Clear auth storage */
export function clearAuthStorage() {
localStg.remove('token');
localStg.remove('namespaceId');
2024-03-08 17:59:45 +08:00
localStg.remove('userInfo');
}