刘洋 vor 2 Jahren
Ursprung
Commit
e0aa2773e7
2 geänderte Dateien mit 8 neuen und 8 gelöschten Zeilen
  1. 2 2
      server.config.ts
  2. 6 6
      src/hooks/useFetch.ts

+ 2 - 2
server.config.ts

@@ -4,10 +4,10 @@ const server: ServerOptions = {
   proxy: {
     '^/?(api|file)/': {
       // target: 'http://192.168.10.41:8200',
-      // target: 'http://192.168.10.178:8200',
+      target: 'http://192.168.10.178:8200',
       // target: 'http://192.168.10.107:8200',
       // target: 'http://cet-test.markingtool.cn',
-      target: 'http://192.168.10.136:80',
+      // target: 'http://192.168.10.136:80',
       // target: 'http://cet-dev.markingtool.cn:8200',
     },
   },

+ 6 - 6
src/hooks/useFetch.ts

@@ -21,7 +21,6 @@ function isConfig(x?: string | AxiosRequestConfig): x is AxiosRequestConfig {
   return typeof x === 'object'
 }
 const needLoadingApiList: any[] = [
-  '/api/statistic/monitor/list',
   '/api/statistic/monitor/list',
   '/api/statistic/monitor/list/by/group',
   '/api/statistic/marker/compare/list',
@@ -56,10 +55,9 @@ function useFetch<K extends ApiKeys>(k: K, ...args: any[]) {
 
   const fetch = async (data?: ExtractApiParams<K>, fetchConfig: AxiosRequestConfig = {}) => {
     const mainStore = useMainStore()
-
+    const apiConfig = api[k]
+    const apiConfigUrl = typeof apiConfig === 'string' ? apiConfig : apiConfig?.url
     try {
-      const apiConfig = api[k]
-      console.log('apiConfig:', apiConfig)
       if (unref(loading)) {
         cancel()
       }
@@ -67,7 +65,7 @@ function useFetch<K extends ApiKeys>(k: K, ...args: any[]) {
       abortcontroller = new AbortController()
 
       loading.value = true
-      if (needLoadingApiList.indexOf(apiConfig) > -1) {
+      if (needLoadingApiList.indexOf(apiConfigUrl) > -1) {
         mainStore.setGlobalLoading(true)
       }
       // const apiConfig = api[k]
@@ -91,7 +89,9 @@ function useFetch<K extends ApiKeys>(k: K, ...args: any[]) {
       return Promise.reject(failed)
     } finally {
       loading.value = false
-      mainStore.setGlobalLoading(false)
+      if (needLoadingApiList.indexOf(apiConfigUrl) > -1) {
+        mainStore.setGlobalLoading(false)
+      }
     }
   }