Browse Source

不强制登录

liudan 3 months ago
parent
commit
9cc5e8dec0
1 changed files with 13 additions and 2 deletions
  1. 13 2
      src/config/https.js

+ 13 - 2
src/config/https.js

@@ -4,6 +4,16 @@ import Cache from '../utils/cache.js';
 
 var noSessionCode = '03100014^03100149^03100150^1001^1011^03100013^01040043^03100143^03100112^03100102^03100102^03100102^01010013^03100099^01020008^08010034^12100046^';
 
+// 当前页面是否在 pages/staticPages 目录下(该目录下的静态页面不跳转登录)
+function isStaticPage() {
+  try {
+    const href = location.href;
+    return href.indexOf('pages/staticPages') > -1;
+  } catch (e) {
+    return false;
+  }
+}
+
 export const $http = {
   post: (type, Nothis, Objson, callBack) => {
     let fetchUrl = httpConfig.urlAddress;
@@ -24,7 +34,8 @@ export const $http = {
     } else {
       session.push({});
     }
-    if (noSessionCode.indexOf(formData.code) < 0 && !isLogin) {
+    console.log(isStaticPage(), '11111');
+    if (noSessionCode.indexOf(formData.code) < 0 && !isLogin && !isStaticPage()) {
       // 单点登录进行中时,不跳登录页,等待 SSO 完成后页面会自动刷新
       let ssoPending = false;
       try {
@@ -75,7 +86,7 @@ export const $http = {
           if (data.errorCode == '0') {
             Objson.success.call(Nothis, data);
           } else {
-            if (data.errorCode == '01040053' || data.errorCode == '01040054' || data.errorCode == '01040055') {
+            if ((data.errorCode == '01040053' || data.errorCode == '01040054' || data.errorCode == '01040055') && !isStaticPage()) {
               Cache.remove('userData');
               let object = {};
               object.index = 1;