Bladeren bron

聊天记录分开

panhui 2 jaren geleden
bovenliggende
commit
c5786c6140
3 gewijzigde bestanden met toevoegingen van 11 en 5 verwijderingen
  1. 3 2
      src/router/permission.ts
  2. 1 2
      src/store/modules/company/index.ts
  3. 7 1
      src/store/modules/user/index.ts

+ 3 - 2
src/router/permission.ts

@@ -5,12 +5,13 @@ import { useBasicLayout } from '@/hooks/useBasicLayout'
 
 export function setupPageGuard(router: Router) {
     router.beforeEach(async (to, from, next) => {
+        const userStore = useUserStore()
         if (to.params.companyId) {
             const companyStore = useCompanyStore()
-            companyStore.getCompanyInfo(Number(to.params.companyId))
+            await companyStore.getCompanyInfo(Number(to.params.companyId))
+            await userStore.fetch()
         }
         const { isMobile } = useBasicLayout()
-        const userStore = useUserStore()
         const userMemberStore = useUserMemberStore()
         if (!userStore.userInfo.id) {
             try {

+ 1 - 2
src/store/modules/company/index.ts

@@ -21,7 +21,6 @@ export const useCompanyStore = defineStore('company-store', {
             setLocalState(this.$state)
         },
         async getCompanyInfo(companyId: number | undefined | string) {
-            console.log('2873')
             if (companyId === 0) {
                 this.setCompanyInfo({
                     id: 0,
@@ -40,7 +39,7 @@ export const useCompanyStore = defineStore('company-store', {
                         code: res.code || undefined
                     })
                     useAuthStore().changeToken(`SECRET_TOKEN${res.id === 0 ? '' : res.id}`)
-                    useChatStore().changeChatLocal(`chatStorage${res.id}`)
+                    // useChatStore().changeChatLocal(`chatStorage${res.id}`)
                     document.title = res.companyName
                 })
             }

+ 7 - 1
src/store/modules/user/index.ts

@@ -28,7 +28,6 @@ export const useUserStore = defineStore('user-store', {
             const companyStore = useCompanyStore()
             if (companyStore.company.id !== 0) {
                 useAuthStore().changeToken(`SECRET_TOKEN${companyStore.company.id}`)
-                useChatStore().changeChatLocal(`chatStorage${companyStore.company.id}`)
             }
             const data = await fetchMy<UserInfo>()
             this.setUserInfo(data)
@@ -36,6 +35,13 @@ export const useUserStore = defineStore('user-store', {
                 companyStore.getCompanyInfo(companyStore.company.id)
             }
 
+            if (companyStore.company.id !== 0) {
+                useChatStore().changeChatLocal(`chatStorage${companyStore.company.id}_${data.id}`)
+            }
+            else{
+                useChatStore().changeChatLocal(`chatStorage_${data.id}`)
+            }
+
             await useUserMemberStore().fetchMember()
         },