zhengnaiwen_citu преди 4 месеца
родител
ревизия
766f80087f
променени са 2 файла, в които са добавени 16 реда и са изтрити 12 реда
  1. 7 7
      src/config/axios/service.js
  2. 9 5
      src/utils/openEncryption.js

+ 7 - 7
src/config/axios/service.js

@@ -117,19 +117,19 @@ service.interceptors.request.use(
        * params: { data, params, raw }
        * content
        */
-      const header = encryptionFun({raw, body, appId: 'web_client', AppSecret: 'fa0fc0b5098b974b'})
+      const { noSign, ...header} = encryptionFun({raw, body, appId: 'web_client', AppSecret: 'fa0fc0b5098b974b'})
       const content = {
         data: config.data,
         params: config.params,
         body,
         raw,
+        noSign,
         config,
         browserInfo: getBrowserInfo()
       }
       errorData.push({
         time: header.timestamp,
         url: config.url,
-        mark: generateUUID(),
         content
       })
       Object.assign(config.headers, header)
@@ -257,7 +257,7 @@ service.interceptors.response.use(
       } else {
         if (_index > -1) {
           // 保存错误信息
-          sendError({ content: JSON.stringify(errorData[_index].content), mark: errorData[_index].mark })
+          sendError({ content: JSON.stringify(errorData[_index].content), mark: errorData[_index].time + '' })
           // 移除
           errorData.splice(_index, 1)
         }
@@ -349,14 +349,14 @@ function getBrowserInfo() {
 
   if (ua.includes("edge")) {
     // edge 浏览器  
-    browserName = "edge";  
-    fullVersion = ua.split("edge/")[1].split(" ")[0];  
+    browserName = "Edg";  
+    fullVersion = ua.split("Edg/")[1].split(" ")[0];  
   } else if (ua.includes("qqbrowser")) { 
     browserName = 'QQ浏览器';
-    fullVersion = ua.split("qqbrowser/")[1].split(" ")[0];  
+    fullVersion = ua.split("QQbrowser/")[1].split(" ")[0];  
   } else if (ua.includes("ubrowser")) { 
     browserName = 'UC浏览器';
-    fullVersion = ua.split("ubrowser/")[1].split(" ")[0];  
+    fullVersion = ua.split("Ubrowser/")[1].split(" ")[0];  
   } else if (ua.includes("Firefox")) {  
       // Firefox 浏览器  
       browserName = "Firefox";  

+ 9 - 5
src/utils/openEncryption.js

@@ -25,8 +25,12 @@ export const encryptionFun = ({raw, body, appId, AppSecret}) => {
     nonce: generateUUID(),
     timestamp: new Date().getTime() + 3000,
   }
-  const _initSign = Object.keys(initSign).reduce((str, key) => str += `&${key}=${initSign[key]}`, '')
-  const paramsStr = _initSign.slice(1, _initSign.length) + AppSecret
+  const _initSignArr = Object.keys(initSign).map(key => {
+    return `${key}=${initSign[key]}`
+  })
+  const _initSign = _initSignArr.join('&')
+
+  const paramsStr = _initSign + AppSecret
   let str = ''
   if (raw) {
     str += decodeURIComponent(raw)
@@ -34,10 +38,10 @@ export const encryptionFun = ({raw, body, appId, AppSecret}) => {
   if (body && Object.keys(body).length) {
     str += decodeURIComponent(JSON.stringify(body))
   }
-  // console.log('str:', str, 'paramsStr:', paramsStr)
-  // console.log(sha256(str + paramsStr))
+  const noSign = str + paramsStr
   return {
     ...initSign,
-    sign: sha256(str + paramsStr)
+    noSign: noSign,
+    sign: sha256(noSign)
   }
 }