Explorar o código

fix: 修改Bug

bill %!s(int64=2) %!d(string=hai) anos
pai
achega
a012a68537

+ 2 - 12
src/api/instance.ts

@@ -28,19 +28,9 @@ export const gotoLogin = () => {
   router.push({ name: RoutesName.login })
 }
 
-let firstNow = 0
-const tokenInvalid = () => {
-  const currentNow = Date.now()
-  if (currentNow - firstNow > 5000) {
-    firstNow = Date.now()
-    message.error(ResCodeDesc[ResCode.TOKEN_INVALID])
-  }
-  gotoLogin()
-}
-
 addReqErrorHandler(err => {
   // showLoading()
-  tokenInvalid()
+  gotoLogin()
 })
 
 addResErrorHandler((response, data) => {
@@ -52,7 +42,7 @@ addResErrorHandler((response, data) => {
         ? ResCodeDesc[data.code]
         : data?.message || data?.msg
     if (data.code === ResCode.TOKEN_INVALID) {
-      tokenInvalid()
+      gotoLogin()
     } else {
       message.error(msg)
     }

+ 3 - 3
src/api/project.ts

@@ -51,9 +51,9 @@ export enum BimStatus {
 export const BimStatusDesc = {
   [BimStatus.error]: '错误',
   [BimStatus.done]: '完成',
-  [BimStatus.upload]: '上传',
-  [BimStatus.transfrom]: '转换',
-  [BimStatus.offline]: '离线包生成'
+  [BimStatus.upload]: '上传',
+  [BimStatus.transfrom]: '转换',
+  [BimStatus.offline]: '离线包生成'
 }
 
 export type Bim = {

+ 7 - 0
src/store/project.ts

@@ -1,4 +1,5 @@
 import { defineStore } from 'pinia'
+import { useUserStore } from './user'
 import {
   fetchProject,
   uploadProjectBimScene,
@@ -44,6 +45,7 @@ export type SelectTypeScenes = {
 }
 
 type CurrentState = null | Project
+
 export const useProject = defineStore('project', {
   state: () => ({
     current: null as CurrentState
@@ -86,6 +88,7 @@ export const useProject = defineStore('project', {
     async delete(id?: Project['projectId']) {
       if ((id = id || this.current?.projectId)) {
         await deleteProject(id)
+        await useUserStore().fetchMeta()
         this.current = null
       }
     },
@@ -112,6 +115,7 @@ export const useProject = defineStore('project', {
     async addBim(data: BimUploadData, id?: Project['projectId']) {
       if ((id = id || this.current?.projectId)) {
         await uploadProjectBimScene(id, data)
+        await useUserStore().fetchMeta()
         await this.updateCurrent(id)
       }
     },
@@ -124,6 +128,7 @@ export const useProject = defineStore('project', {
     async deleteBim(bimId?: Bim['bimId']) {
       if ((bimId = bimId || this.current?.bimData?.bimId)) {
         await deleteProjectBimScene(bimId)
+        await useUserStore().fetchMeta()
         this.current?.bimData?.bimId === bimId && (await this.updateCurrent())
       }
     },
@@ -139,12 +144,14 @@ export const useProject = defineStore('project', {
           })
         )
         await relaceProjectScenes({ id, sceneNumParam })
+        await useUserStore().fetchMeta()
         await this.updateCurrent(id)
       }
     },
     async deleteScene(num: Scene['num'], id?: Project['projectId']) {
       if ((id = id || this.current?.projectId)) {
         await deleteProjectScene({ projectId: id, num })
+        await useUserStore().fetchMeta()
         await this.updateCurrent(id)
       }
     }

+ 0 - 1
src/store/user.ts

@@ -33,7 +33,6 @@ export const useUserStore = defineStore('user', {
     },
     async fetchMeta() {
       this.meta = await fetchUserMeta()
-      console.log(this.$state)
     },
     fetch() {
       return Promise.all([this.fetchUser(), this.fetchMeta()])

+ 2 - 2
src/views/personal/index.vue

@@ -42,9 +42,9 @@ const getGreet = () => {
   const hours = new Date().getHours()
   return hours > 5 && hours < 11
     ? '早上'
-    : hours >= 11 && hours < 3
+    : hours >= 11 && hours < 15
     ? '中午'
-    : hours >= 3 && hours <= 6
+    : hours >= 15 && hours <= 18
     ? '下午'
     : '晚上'
 }

+ 4 - 3
src/views/project/list.vue

@@ -43,8 +43,8 @@
             :key="option.value"
             :value="option.value"
           >
-            {{ option.label }}</a-select-option
-          >
+            {{ option.label }}
+          </a-select-option>
         </a-select>
       </a-form-item>
 
@@ -75,7 +75,7 @@ import { projectColumns } from './columns'
 import { computed, reactive, ref } from 'vue'
 import { usePaging } from '@/hook'
 import { renderModal } from '@/helper'
-import { useProject } from '@/store'
+import { useProject, useUserStore } from '@/store'
 import {
   ProjectStatus,
   ProjectStatusDesc,
@@ -149,6 +149,7 @@ const createProject = () => {
           project.projectId
         )
       }
+      await useUserStore().fetchMeta()
       await updateList()
     }
   })

+ 1 - 1
src/views/scene/insert.vue

@@ -38,8 +38,8 @@
     <a-form name="basic" label-align="left" autocomplete="off">
       <a-form-item v-if="showBim" label="场景类型" required>
         <a-radio-group v-model:value="currentType" name="radioGroup">
-          <a-radio :value="Type.bim">{{ Type.bim }}</a-radio>
           <a-radio :value="Type.scene">{{ Type.scene }}</a-radio>
+          <a-radio :value="Type.bim">{{ Type.bim }}</a-radio>
         </a-radio-group>
       </a-form-item>
       <UploadBim v-if="currentType === Type.bim" v-model:data="bim" />

+ 5 - 5
src/views/system/shared/cache.ts

@@ -4,8 +4,8 @@ import type { LoginState } from '@/api'
 const cacheKey = '__loginState__'
 
 export const useCacheState = () => {
-  const initial = { phone: '', password: '', remember: false }
-  const state = ref<LoginState & { remember: boolean }>(initial)
+  const getInitial = () => ({ phone: '', password: '', remember: false })
+  const state = ref<LoginState & { remember: boolean }>(getInitial())
   const updateCacheState = () => {
     try {
       const stateStr = localStorage.getItem(cacheKey)
@@ -14,12 +14,12 @@ export const useCacheState = () => {
         if (value.remember) {
           state.value = value
         } else {
-          state.value = initial
+          state.value = getInitial()
         }
       } else {
-        state.value = initial
+        state.value = getInitial()
       }
-      console.log(state.value)
+      console.error(state.value)
     } catch {}
   }
   updateCacheState()