immunityStore.ts 693 B

1234567891011121314151617181920212223242526
  1. import {defineStore} from 'pinia'
  2. import ImmunityApi from '@/api/ImmunityApi'
  3. import {useUserStore} from '@/store/userStore'
  4. import type AjaxResult from '@/mode/AjaxResult'
  5. import type Immunity from '@/mode/Immunity'
  6. /**
  7. * @description 免打扰库
  8. */
  9. export const useImmunityStore = defineStore({
  10. id: 'immunity_store',
  11. state: () => ({
  12. immunityList: new Array<string>()
  13. }),
  14. actions: {
  15. loadData() {
  16. const userId = useUserStore().getUser()?.id
  17. if (userId) {
  18. ImmunityApi.list(userId).then((res:AjaxResult<Immunity[]>) => {
  19. //console.log('ImmunityApi',res)
  20. this.immunityList = res.data.map((item) => item.chatId)
  21. })
  22. }
  23. }
  24. }
  25. })