helpers.ts 611 B

12345678910111213141516171819202122232425262728
  1. import { localStg } from '@/utils';
  2. /** 获取token */
  3. export function getToken() {
  4. return localStorage.getItem('token');
  5. }
  6. /** 获取用户信息 */
  7. export function getUserInfo() {
  8. const emptyInfo: Auth.UserInfo = {
  9. id: null,
  10. username: '',
  11. phone: null,
  12. email: '',
  13. permissions: [],
  14. departments: [],
  15. userType: ''
  16. };
  17. const userInfo: Auth.UserInfo = localStg.get('userInfo') || emptyInfo;
  18. return userInfo;
  19. }
  20. /** 去除用户相关缓存 */
  21. export function clearAuthStorage() {
  22. localStg.remove('token');
  23. localStg.remove('refreshToken');
  24. localStg.remove('userInfo');
  25. }