auth.ts 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import {SHOP_ID, TOKEN_KEY} from '@/enums/cacheEnums'
  2. import cache from './cache'
  3. export function getToken() {
  4. return cache.get(TOKEN_KEY)
  5. }
  6. export function getBrandId() {
  7. return cache.get("brandId")
  8. }
  9. export function getHouseId() {
  10. return cache.get("houseId")
  11. }
  12. export function getUserId() {
  13. return cache.get("userId")
  14. }
  15. export function getShopId() {
  16. if (cache.get(SHOP_ID))
  17. return JSON.parse(<string>cache.get(SHOP_ID)).value
  18. return ''
  19. }
  20. export function clearAuthInfo() {
  21. cache.remove(TOKEN_KEY)
  22. window.localStorage.removeItem("like_admin_token")
  23. window.localStorage.removeItem("like_admin_brandId")
  24. window.localStorage.removeItem("like_admin_userId")
  25. window.localStorage.removeItem("like_admin_houseId")
  26. cache.remove(SHOP_ID)
  27. // 确认窗体
  28. /*ElMessageBox.confirm("已经在其他地方登录", '温馨提示', {
  29. confirmButtonText: '确定',
  30. cancelButtonText: '取消',
  31. type: 'warning'
  32. }).then(() => {
  33. window.close();
  34. })*/
  35. }