app.ts 806 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { defineStore } from 'pinia'
  2. import { userInfo } from '@/api/modules/global/login'
  3. export const useAppStore = defineStore('app', {
  4. state: () => ({
  5. userInfo: null,
  6. tenantInfo: {
  7. id: 0,
  8. },
  9. }),
  10. getters: {},
  11. actions: {
  12. initUserInfo() {
  13. return new Promise((resolve, reject) => {
  14. userInfo()
  15. .then(({ data }: any) => {
  16. this.userInfo = data
  17. resolve(this.userInfo)
  18. })
  19. .catch((e) => {
  20. reject(e)
  21. })
  22. })
  23. },
  24. loadingStart() {
  25. const l = document.getElementById('loader')
  26. if (l) {
  27. l.style.display = 'flex'
  28. }
  29. },
  30. loadingEnd() {
  31. const l = document.getElementById('loader')
  32. if (l) {
  33. l.style.display = 'none'
  34. }
  35. },
  36. },
  37. })