li.shaoyi há 2 anos atrás
pai
commit
c611620ca5
1 ficheiros alterados com 10 adições e 8 exclusões
  1. 10 8
      src/services/index.ts

+ 10 - 8
src/services/index.ts

@@ -95,11 +95,18 @@ export default new (class {
         const filePath = './config/appconfig.json'
         if (plus.hasPlus()) {
             const res = await plus.getLocalFileContent(filePath)
-            return JSON.parse(res)
+            this.systemInfo = {
+                ...this.systemInfo,
+                ...JSON.parse(res)
+            }
         } else {
             const res = await axios(filePath)
-            return res.data
+            this.systemInfo = {
+                ...this.systemInfo,
+                ...res.data
+            }
         }
+        return this.systemInfo
     }
 
     /**
@@ -107,12 +114,7 @@ export default new (class {
      */
     private async init(): Promise<typeof this.config> {
         this.isPending = true
-        await this.systemInfoAsync.then((res) => {
-            this.systemInfo = {
-                ...this.systemInfo,
-                ...res
-            }
-        }).catch(() => {
+        await this.systemInfoAsync.catch(() => {
             this.systemInfoAsync = this.getAppConfig()
         })
         return new Promise((resolve, reject) => {