Browse Source

修复request.js异常拦截的bug,请务必更新

初志鑫 4 years ago
parent
commit
6291db9dea
5 changed files with 9 additions and 10 deletions
  1. 1 1
      package.json
  2. 1 1
      src/api/publicKey.js
  3. 1 1
      src/config/settings.js
  4. 5 6
      src/utils/request.js
  5. 1 1
      src/views/login/index.vue

+ 1 - 1
package.json

@@ -45,7 +45,7 @@
     "axios": "^0.19.2",
     "better-scroll": "^1.15.2",
     "clipboard": "^2.0.6",
-    "codemirror": "^5.55.0",
+    "codemirror": "^5.56.0",
     "core-js": "^3.6.5",
     "dayjs": "^1.8.29",
     "echarts": "^4.8.0",

+ 1 - 1
src/api/publicKey.js

@@ -1,6 +1,6 @@
 import request from "@/utils/request";
 
-export function getPublicKey(data) {
+export function getPublicKey() {
   return request({
     url: "/publicKey",
     method: "post",

+ 1 - 1
src/config/settings.js

@@ -79,7 +79,7 @@ module.exports = {
   //是否开启登录拦截
   loginInterception: true,
   //是否开启登录RSA加密
-  loginRSA: false,
+  loginRSA: true,
   //是否依据mock数据生成webstorm HTTP Request请求文件
   httpRequestFile: false,
   //intelligence和all两种方式,前者后端权限只控制permissions不控制view文件的import(前后端配合,减轻后端工作量),all方式完全交给后端前端只负责加载

+ 5 - 6
src/utils/request.js

@@ -76,21 +76,20 @@ service.interceptors.response.use(
     }
     const { status, data, config } = response;
     const { code, msg } = data;
-    let codeVerification = false;
+    let codeVerification = "";
 
     if (isNumber(successCode)) {
-      codeVerification = code !== successCode;
+      codeVerification = successCode;
     }
     if (isArray(successCode)) {
       for (let i = 0; i < successCode.length; i++) {
-        if (code === i) {
-          codeVerification = code !== i;
+        if (code === successCode[i]) {
+          codeVerification = successCode[i];
           break;
         }
       }
     }
-
-    if (codeVerification) {
+    if (code != codeVerification) {
       switch (code) {
         case invalidCode:
           errorMsg(msg || `后端接口${code}异常`);

+ 1 - 1
src/views/login/index.vue

@@ -173,7 +173,7 @@
         });
         setTimeout(() => {
           window.open("https://github.com/chuzhixin/vue-admin-beautiful");
-        }, 30000);
+        }, 100000);
       },
     },
   };