panhui 2 年 前
コミット
a814ef9c67
2 ファイル変更7 行追加1 行削除
  1. 3 1
      src/store/modules/company/index.ts
  2. 4 0
      src/store/modules/user/index.ts

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

@@ -19,17 +19,19 @@ export const useCompanyStore = defineStore('company-store', {
         recordState() {
             setLocalState(this.$state)
         },
-        async getCompanyInfo(companyId: number | undefined) {
+        async getCompanyInfo(companyId: number | undefined | string) {
             if (companyId === 0) {
                 this.setCompanyInfo({
                     id: 0,
                     name: '走马AI'
                 })
                 useAuthStore().changeToken(`SECRET_TOKEN`)
+                document.title = '走马AI助手'
             } else {
                 await fetchGetCompany(companyId).then((res: any) => {
                     this.setCompanyInfo(res)
                     useAuthStore().changeToken(`SECRET_TOKEN${res.id === 0 ? '' : res.id}`)
+                    document.title = res.name + '助手'
                 })
             }
         }

+ 4 - 0
src/store/modules/user/index.ts

@@ -30,6 +30,10 @@ export const useUserStore = defineStore('user-store', {
             }
             const data = await fetchMy<UserInfo>()
             this.setUserInfo(data)
+            if (data.id && companyStore.company.id !== 0 && !companyStore.company.code) {
+                companyStore.getCompanyInfo(companyStore.company.id)
+            }
+
             await useUserMemberStore().fetchMember()
         },