Pārlūkot izejas kodu

Merge branch 'dev_1.1.3' of https://git.yishihui.com/DeNet/de-net into dev_1.1.3

zhangwei 2 gadi atpakaļ
vecāks
revīzija
fb618875f9
3 mainītis faili ar 19 papildinājumiem un 6 dzēšanām
  1. 6 5
      src/http/fetch.js
  2. 7 0
      src/http/logApi.js
  3. 6 1
      src/log-center/logger.js

+ 6 - 5
src/http/fetch.js

@@ -21,16 +21,17 @@ export async function commonFetch({ url = '', method = 'POST' , params = {}, bas
         if(url.includes('http')){
             _url = url
         }
+        let bodyObj = {
+            "baseInfo": baseInfo,
+            "params": params
+        };
         fetch(_url, {
             method: method, // or 'PUT'
             cache: 'no-cache',
             headers: {
                 'Content-Type': 'application/json',
             },
-            body: JSON.stringify({
-                "baseInfo": baseInfo,
-                "params": params
-            }),
+            body: JSON.stringify(bodyObj),
         })
             .then(response => response.json())
             .then(data => {
@@ -60,7 +61,7 @@ export async function commonFetch({ url = '', method = 'POST' , params = {}, bas
                 resolve(data);
             })
             .catch((error) => {
-                reject(error);
+                reject({url: _url, error: error, requestParams: bodyObj});
             });
     })
 }

+ 7 - 0
src/http/logApi.js

@@ -19,4 +19,11 @@ export function logApi(params = {}) {
         },
         params: params.params
     })
+}
+
+export function reportFrontLogApi(params = {}) {
+    return commonFetch({
+        url: `/log/reportFrontLog`,
+        params: params
+    })
 }

+ 6 - 1
src/log-center/logger.js

@@ -1,4 +1,4 @@
-import { logApi } from '@/http/logApi'
+import { logApi, reportFrontLogApi } from '@/http/logApi'
 import { getBrowser } from '@/uilts/help.js';
 import { logType } from './logEnum.js';
 import { getChromeStorage } from '@/uilts/chromeExtension'
@@ -55,6 +55,11 @@ function paramsPretreatmentAndRequest(logType, eventData, extParams) {
             pageSource,
             ...obj
         }
+    }).then(res => {
+    }).catch(err => {
+        reportFrontLogApi({
+            logData: JSON.stringify(err)
+        })
     })
 }