From 0519dcda8b6fb2914987f8d4d58e1d14bcf98dc3 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 30 六月 2023 14:33:06 +0800
Subject: [PATCH] 2023-06-30

---
 src/tabviews/zshare/actionList/exceloutbutton/index.jsx               |   24 ++-
 src/views/basedesign/index.jsx                                        |   15 ++
 src/views/login/loginform.jsx                                         |   25 ++++
 src/api/index.js                                                      |   75 ++++++------
 src/components/resetPassword/resetpwd/index.jsx                       |   25 ++++
 src/views/appmanage/index.jsx                                         |   15 ++
 src/tabviews/zshare/mutilform/mkVercode/index.jsx                     |   50 ++++++++
 src/tabviews/zshare/actionList/normalbutton/index.jsx                 |   48 ++++++-
 src/tabviews/custom/components/table/edit-table/normalTable/index.jsx |    8 +
 src/tabviews/zshare/actionList/excelInbutton/index.jsx                |   16 +-
 src/tabviews/zshare/actionList/printbutton/index.jsx                  |    6 
 src/views/login/index.jsx                                             |   48 ++++---
 12 files changed, 263 insertions(+), 92 deletions(-)

diff --git a/src/api/index.js b/src/api/index.js
index 781daf3..1d2ed22 100644
--- a/src/api/index.js
+++ b/src/api/index.js
@@ -1,6 +1,6 @@
 import axios from 'axios'
 import qs from 'qs'
-import { notification } from 'antd'
+import { notification, Modal } from 'antd'
 import md5 from 'md5'
 import CryptoJS from 'crypto-js'
 import jsSHA from 'jssha'
@@ -11,6 +11,7 @@
 
 window.GLOB.IndexDB = null
 window.GLOB.OuterToken = {}
+window.GLOB.$error = false
 
 let service = window.GLOB.service ? '-' + window.GLOB.service.replace('/', '') : ''
 let db = `mkdb${service}`
@@ -23,55 +24,53 @@
 axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8'
 axios.defaults.withCredentials = false
 
-// Modal.destroyAll()
-// Modal.error({
-//   title: response.data.message,
-//   onOk: () => {
-//     sessionStorage.clear()
-//   }
-// })
-
-const setCurrentUrl = (res) => {
-  if (!!(window.history && window.history.pushState)) {
-    sessionStorage.clear()
-    sessionStorage.setItem('loginError', JSON.stringify({url: res.config ? res.config.url : '', request: res.config ? res.config.data : '', response: JSON.stringify(res.data)}))
-    window.history.replaceState(null, null, window.location.href.split('#')[0] + '#/login')
-    window.location.reload()
-  }
-}
-
 axios.interceptors.response.use((response) => {
   if (response.data.ErrCode === 'LoginError') {
-    if (window.debugger === true) {
-      response.data.ErrCode = 'E'
-      return Promise.resolve(response.data)
-    } else if (window.GLOB.developing) {
+    if (window.GLOB.developing) {
       sessionStorage.setItem('devError', 'true')
       response.data.ErrCode = 'E'
       return Promise.resolve(response.data)
-    } else if (!sessionStorage.getItem('loginError')) {
-      setCurrentUrl(response)
+    } else if (response.config.url.indexOf('https://sso.mk9h.cn/webapi/dostars') > -1) {
+      return Promise.reject(response.data)
+    } else if (response.config.url.indexOf('https://epc.mk9h.cn/webapi/dostars') > -1) {
+      return Promise.reject(response.data)
     }
+
+    if (!window.GLOB.$error) {
+      window.GLOB.$error = true
+
+      Modal.destroyAll()
+      Modal.error({
+        title: response.data.message,
+        onOk: () => {
+          window.GLOB.$error = false
+          sessionStorage.clear()
+          if (!!(window.history && window.history.pushState)) {
+            window.history.replaceState(null, null, window.location.href.split('#')[0] + '#/login')
+            window.location.reload()
+          }
+        }
+      })
+    }
+
+    return Promise.reject(response.data)
   } else {
     return Promise.resolve(response.data)
   }
 }, (error) => {
-  let response = error.response
+  let response = error.response || ''
 
-  if (response) {
-    if (!response.data || !response.data.errors) { // 杩囨护鏃疯鎶ラ敊淇℃伅
-      notification.error({
-        className: 'notification-custom-error',
-        bottom: 0,
-        message: '鐘舵�佺爜-' + response.status + '锛岃鑱旂郴绠$悊鍛�',
-        placement: 'bottomRight',
-        duration: 15
-      })
-    }
-    return Promise.reject(response)
-  } else {
-    return Promise.reject()
+  if (response && (!response.data || !response.data.errors)) { // 杩囨护鏃疯鎶ラ敊淇℃伅
+    notification.error({
+      className: 'notification-custom-error',
+      bottom: 0,
+      message: '鐘舵�佺爜-' + response.status + '锛岃鑱旂郴绠$悊鍛�',
+      placement: 'bottomRight',
+      duration: 15
+    })
   }
+
+  return Promise.reject(response)
 })
 
 class Api {
diff --git a/src/components/resetPassword/resetpwd/index.jsx b/src/components/resetPassword/resetpwd/index.jsx
index ee7a60a..514bab5 100644
--- a/src/components/resetPassword/resetpwd/index.jsx
+++ b/src/components/resetPassword/resetpwd/index.jsx
@@ -142,7 +142,30 @@
           })
           message.warning(res.message)
         }
-      }, () => {
+      }, (error) => {
+        if (error && error.ErrCode === 'LoginError') {
+          let param = {
+            func: 's_visitor_login',
+            timestamp: moment().format('YYYY-MM-DD HH:mm:ss'), 
+            SessionUid: 'bh0bapabtd45epsgra79segbch6c1ibk',
+            TypeCharOne: 'pc',
+            appkey: '202004041613277377A6A2456D34A4948AE84'
+          }
+          
+          param.LText = md5(window.btoa('bh0bapabtd45epsgra79segbch6c1ibk' + param.timestamp))
+          param.secretkey = md5(param.LText + 'mingke' + param.timestamp)
+  
+          let params = {
+            url: 'https://sso.mk9h.cn/webapi/dologon',
+            method: 'post',
+            data: JSON.stringify(param)
+          }
+
+          Api.directRequest(params)
+
+          return
+        }
+
         clearTimeout(this.LoginTimer)
         this.setState({
           verdisabled: false,
diff --git a/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx b/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx
index a38bb09..2260a2d 100644
--- a/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx
+++ b/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx
@@ -1671,7 +1671,9 @@
         } else {
           this.execError(res)
         }
-      }, () => {
+      }, (error) => {
+        if (error && error.ErrCode === 'LoginError') return
+
         this.execError({})
       })
     } else if (submit.intertype === 'inner' && submit.innerFunc) { // 鑷畾涔夊瓨鍌ㄨ繃绋�
@@ -1683,7 +1685,9 @@
         } else {
           this.execError(res)
         }
-      }, () => {
+      }, (error) => {
+        if (error && error.ErrCode === 'LoginError') return
+
         this.execError({})
       })
     }
diff --git a/src/tabviews/zshare/actionList/excelInbutton/index.jsx b/src/tabviews/zshare/actionList/excelInbutton/index.jsx
index 2abe56f..c25df22 100644
--- a/src/tabviews/zshare/actionList/excelInbutton/index.jsx
+++ b/src/tabviews/zshare/actionList/excelInbutton/index.jsx
@@ -408,7 +408,8 @@
           } else {
             this.execError(res)
           }
-        }, () => {
+        }, (error) => {
+          if (error && error.ErrCode === 'LoginError') return
           this.execError({})
         })
       } else {
@@ -418,7 +419,8 @@
           } else {
             this.execError(res)
           }
-        }, () => {
+        }, (error) => {
+          if (error && error.ErrCode === 'LoginError') return
           this.execError({})
         })
       }
@@ -431,7 +433,8 @@
         } else {
           this.execError(res)
         }
-      }, () => {
+      }, (error) => {
+        if (error && error.ErrCode === 'LoginError') return
         this.execError({})
       })
     } else if (btn.intertype === 'outer') { // 澶栭儴鎺ュ彛
@@ -460,7 +463,8 @@
               this.execError(res)
               resolve(false)
             }
-          }, () => {
+          }, (error) => {
+            if (error && error.ErrCode === 'LoginError') return
             this.execError({})
           })
         } else {
@@ -521,7 +525,7 @@
 
         return Api.genericInterface(res)
       }).then(response => {
-        if (!response) return
+        if (!response || response.ErrCode === 'LoginError') return
         // 鍥炶皟璇锋眰
         if (ver_token && response.ErrMesg === 'token_error') {
           this.execError(response)
@@ -542,7 +546,7 @@
           }
         }
       }).then(res => {
-        if (!res) return
+        if (!res || res.ErrCode === 'LoginError') return
 
         if (res.status) {
           this.execSuccess(res)
diff --git a/src/tabviews/zshare/actionList/exceloutbutton/index.jsx b/src/tabviews/zshare/actionList/exceloutbutton/index.jsx
index 78fc739..a31ae6b 100644
--- a/src/tabviews/zshare/actionList/exceloutbutton/index.jsx
+++ b/src/tabviews/zshare/actionList/exceloutbutton/index.jsx
@@ -220,7 +220,8 @@
           } else {
             this.execError(result)
           }
-        }, () => {
+        }, (error) => {
+          if (error && error.ErrCode === 'LoginError') return
           this.execError({})
         })
       } else if (btn.intertype === 'inner') { // 浣跨敤鍐呴儴鍑芥暟
@@ -233,7 +234,8 @@
           } else {
             this.execError(result)
           }
-        }, () => {
+        }, (error) => {
+          if (error && error.ErrCode === 'LoginError') return
           this.execError({})
         })
       } else if (btn.intertype === 'outer' && !btn.innerFunc) { // 浣跨敤澶栭儴鍑芥暟
@@ -285,7 +287,8 @@
           } else {
             this.execError(result)
           }
-        }, () => {
+        }, (error) => {
+          if (error && error.ErrCode === 'LoginError') return
           this.execError({})
         })
       } else if (btn.intertype === 'outer' && btn.innerFunc) {
@@ -349,7 +352,8 @@
           } else {
             this.execError(res)
           }
-        }, () => {
+        }, (error) => {
+          if (error && error.ErrCode === 'LoginError') return
           this.execError({})
         })
       } else {
@@ -437,13 +441,15 @@
           } else {
             this.execError(result)
           }
-        }, () => {
+        }, (error) => {
+          if (error && error.ErrCode === 'LoginError') return
           this.execError({})
         })
       } else {
         this.execError(res)
       }
-    }, () => {
+    }, (error) => {
+      if (error && error.ErrCode === 'LoginError') return
       this.execError({})
     })
   }
@@ -525,7 +531,8 @@
       } else {
         this.execError(result)
       }
-    }, () => {
+    }, (error) => {
+      if (error && error.ErrCode === 'LoginError') return
       this.execError({})
     })
   }
@@ -842,7 +849,8 @@
       } else {
         this.execError(res)
       }
-    }, () => {
+    }, (error) => {
+      if (error && error.ErrCode === 'LoginError') return
       this.updateStatus('over')
     })
   }
diff --git a/src/tabviews/zshare/actionList/normalbutton/index.jsx b/src/tabviews/zshare/actionList/normalbutton/index.jsx
index f49846b..84aeadd 100644
--- a/src/tabviews/zshare/actionList/normalbutton/index.jsx
+++ b/src/tabviews/zshare/actionList/normalbutton/index.jsx
@@ -4,6 +4,7 @@
 import qs from 'qs'
 import { is, fromJS } from 'immutable'
 import { Button, Modal, notification, message, Drawer, Switch, Checkbox, Progress } from 'antd'
+import md5 from 'md5'
 
 import Api from '@/api'
 import Utils, { getSysDefaultSql } from '@/utils/utils.js'
@@ -1103,7 +1104,8 @@
             this.execError(res)
           }
           _resolve()
-        }, () => {
+        }, (error) => {
+          if (error && error.ErrCode === 'LoginError') return
           this.updateStatus()
           _resolve()
         })
@@ -1116,7 +1118,8 @@
                   this.triggerNote(res) // 娑堟伅
                 }
                 resolve(res)
-              }, () => {
+              }, (error) => {
+                if (error && error.ErrCode === 'LoginError') return
                 this.updateStatus()
                 _resolve()
               })
@@ -1232,7 +1235,8 @@
         this.execError(res)
         _resolve()
       }
-    }, () => {
+    }, (error) => {
+      if (error && error.ErrCode === 'LoginError') return
       this.updateStatus()
       _resolve()
     })
@@ -1424,7 +1428,8 @@
         this.execError(res)
         _resolve()
       }
-    }, () => {
+    }, (error) => {
+      if (error && error.ErrCode === 'LoginError') return
       this.updateStatus()
       _resolve()
     })
@@ -1639,7 +1644,8 @@
         this.execError(res)
         _resolve()
       }
-    }, () => {
+    }, (error) => {
+      if (error && error.ErrCode === 'LoginError') return
       this.updateStatus()
       _resolve()
     })
@@ -1702,7 +1708,8 @@
         this.execError(res)
         _resolve()
       }
-    }, () => {
+    }, (error) => {
+      if (error && error.ErrCode === 'LoginError') return
       this.updateStatus()
       _resolve()
     })
@@ -1764,7 +1771,8 @@
         this.execError(res)
         _resolve()
       }
-    }, () => {
+    }, (error) => {
+      if (error && error.ErrCode === 'LoginError') return
       this.updateStatus()
       _resolve()
     })
@@ -1834,7 +1842,8 @@
         return
       }
       this.outerCallbackRequest(params, res, record, outParam, _resolve)
-    }, () => {
+    }, (error) => {
+      if (error && error.ErrCode === 'LoginError') return
       this.outerCallbackRequest(params, {status: false, message: 500, ErrCode: 'E', ErrMesg: 500}, record, outParam, _resolve)
     })
   }
@@ -2426,6 +2435,29 @@
             duration: 5
           })
         }
+      }, (error) => {
+        if (error && error.ErrCode === 'LoginError') {
+          let param = {
+            func: 's_visitor_login',
+            timestamp: moment().format('YYYY-MM-DD HH:mm:ss'), 
+            SessionUid: 'bh0bapabtd45epsgra79segbch6c1ibk',
+            TypeCharOne: 'pc',
+            appkey: '202004041613277377A6A2456D34A4948AE84'
+          }
+
+          param.LText = md5(window.btoa('bh0bapabtd45epsgra79segbch6c1ibk' + param.timestamp))
+          param.secretkey = md5(param.LText + 'mingke' + param.timestamp)
+
+          let params = {
+            url: 'https://sso.mk9h.cn/webapi/dologon',
+            method: 'post',
+            data: JSON.stringify(param)
+          }
+
+          Api.directRequest(params)
+
+          return
+        }
       })
     })
   }
diff --git a/src/tabviews/zshare/actionList/printbutton/index.jsx b/src/tabviews/zshare/actionList/printbutton/index.jsx
index 2bbfe85..4c1f0bc 100644
--- a/src/tabviews/zshare/actionList/printbutton/index.jsx
+++ b/src/tabviews/zshare/actionList/printbutton/index.jsx
@@ -533,7 +533,7 @@
 
       return Api.getSystemCacheConfig(param)
     }).then(result => {
-      if (!result) {
+      if (!result || result.ErrCode === 'LoginError') {
         this.setState({ loading: false })
         return
       }
@@ -1262,7 +1262,7 @@
 
       return Api.genericInterface(res)
     }).then(response => {
-      if (!response) return
+      if (!response || response.ErrCode === 'LoginError') return
 
       if (ver_token && response.ErrMesg === 'token_error') {
         this.execError(response)
@@ -1291,7 +1291,7 @@
         _resolve({next: false, list: []})
       }
     }).then(response => {
-      if (!response) return
+      if (!response || response.ErrCode === 'LoginError') return
 
       if (response.status) {
         _list.push(response)
diff --git a/src/tabviews/zshare/mutilform/mkVercode/index.jsx b/src/tabviews/zshare/mutilform/mkVercode/index.jsx
index dfa614b..c0569d0 100644
--- a/src/tabviews/zshare/mutilform/mkVercode/index.jsx
+++ b/src/tabviews/zshare/mutilform/mkVercode/index.jsx
@@ -146,7 +146,30 @@
           } else {
             this.props.onSend(send_type, timestamp, n_id)
           }
-        }, () => {
+        }, (error) => {
+          if (error && error.ErrCode === 'LoginError') {
+            let param = {
+              func: 's_visitor_login',
+              timestamp: moment().format('YYYY-MM-DD HH:mm:ss'), 
+              SessionUid: 'bh0bapabtd45epsgra79segbch6c1ibk',
+              TypeCharOne: 'pc',
+              appkey: '202004041613277377A6A2456D34A4948AE84'
+            }
+            
+            param.LText = md5(window.btoa('bh0bapabtd45epsgra79segbch6c1ibk' + param.timestamp))
+            param.secretkey = md5(param.LText + 'mingke' + param.timestamp)
+    
+            let params = {
+              url: 'https://sso.mk9h.cn/webapi/dologon',
+              method: 'post',
+              data: JSON.stringify(param)
+            }
+  
+            Api.directRequest(params)
+  
+            return
+          }
+
           clearTimeout(this.timer)
           this.setState({
             verdisabled: false,
@@ -182,7 +205,30 @@
         } else {
           this.props.onSend(send_type, timestamp, n_id)
         }
-      }, () => {
+      }, (error) => {
+        if (error && error.ErrCode === 'LoginError') {
+          let param = {
+            func: 's_visitor_login',
+            timestamp: moment().format('YYYY-MM-DD HH:mm:ss'), 
+            SessionUid: 'bh0bapabtd45epsgra79segbch6c1ibk',
+            TypeCharOne: 'pc',
+            appkey: '202004041613277377A6A2456D34A4948AE84'
+          }
+          
+          param.LText = md5(window.btoa('bh0bapabtd45epsgra79segbch6c1ibk' + param.timestamp))
+          param.secretkey = md5(param.LText + 'mingke' + param.timestamp)
+  
+          let params = {
+            url: 'https://sso.mk9h.cn/webapi/dologon',
+            method: 'post',
+            data: JSON.stringify(param)
+          }
+
+          Api.directRequest(params)
+
+          return
+        }
+        
         clearTimeout(this.timer)
         this.setState({
           verdisabled: false,
diff --git a/src/views/appmanage/index.jsx b/src/views/appmanage/index.jsx
index ff500da..2433125 100644
--- a/src/views/appmanage/index.jsx
+++ b/src/views/appmanage/index.jsx
@@ -112,6 +112,21 @@
   forbid = false
 
   UNSAFE_componentWillMount() {
+    if (sessionStorage.getItem('devError') === 'true') {
+      sessionStorage.clear()
+      window.history.replaceState(null, null, window.location.href.split('#')[0] + '#/login')
+      window.location.reload()
+      return
+    }
+
+    if (!sessionStorage.getItem('UserID')) {
+      sessionStorage.removeItem('isEditState')
+      this.props.history.replace('/login')
+      return
+    }
+
+    window.GLOB.developing = true
+
     document.body.className = ''
     this.getAppList()
     this.getSmStemp()
diff --git a/src/views/basedesign/index.jsx b/src/views/basedesign/index.jsx
index b89d9cc..bc036a1 100644
--- a/src/views/basedesign/index.jsx
+++ b/src/views/basedesign/index.jsx
@@ -40,6 +40,21 @@
   }
 
   UNSAFE_componentWillMount() {
+    if (sessionStorage.getItem('devError') === 'true') {
+      sessionStorage.clear()
+      window.history.replaceState(null, null, window.location.href.split('#')[0] + '#/login')
+      window.location.reload()
+      return
+    }
+
+    if (!sessionStorage.getItem('UserID')) {
+      sessionStorage.removeItem('isEditState')
+      this.props.history.replace('/login')
+      return
+    }
+
+    window.GLOB.developing = true
+
     try {
       let param = JSON.parse(window.decodeURIComponent(window.atob(this.props.match.params.param)))
 
diff --git a/src/views/login/index.jsx b/src/views/login/index.jsx
index 9cce0f9..c160a08 100644
--- a/src/views/login/index.jsx
+++ b/src/views/login/index.jsx
@@ -1,5 +1,5 @@
 import React, { Component } from 'react'
-import { message, Modal, notification } from 'antd'
+import { message, Modal } from 'antd'
 import md5 from 'md5'
 import moment from 'moment'
 
@@ -311,27 +311,6 @@
       }
     }
 
-    if (sessionStorage.getItem('loginError')) {
-      try {
-        let res = JSON.parse(sessionStorage.getItem('loginError'))
-        console.info(res.url)
-        console.info(res.request)
-        console.info(res.response)
-
-        let result = JSON.parse(res.response)
-
-        notification.warning({
-          top: 92,
-          message: result.message,
-          duration: 5
-        })
-      } catch (e) {}
-      
-      setTimeout(() => {
-        sessionStorage.removeItem('loginError')
-      }, 2000)
-    }
-
     const _addressUrl = _href + 'queryAddress'
 
     if (localStorage.getItem(_addressUrl) === 'true') {
@@ -509,7 +488,30 @@
             authError: res.message
           })
         }
-      }, () => {
+      }, (error) => {
+        if (error && error.ErrCode === 'LoginError') {
+          let param = {
+            func: 's_visitor_login',
+            timestamp: moment().format('YYYY-MM-DD HH:mm:ss'), 
+            SessionUid: _id,
+            TypeCharOne: 'pc',
+            appkey: '202004041613277377A6A2456D34A4948AE84'
+          }
+
+          param.LText = md5(window.btoa(_id + param.timestamp))
+          param.secretkey = md5(param.LText + 'mingke' + param.timestamp)
+
+          let params = {
+            url: _rduri.replace('dostars', 'dologon'),
+            method: 'post',
+            data: JSON.stringify(param)
+          }
+
+          Api.directRequest(params)
+
+          return
+        }
+
         if (index === -1 || index > 10) {
           this.setState({
             auth: false,
diff --git a/src/views/login/loginform.jsx b/src/views/login/loginform.jsx
index eda2530..fe22bd9 100644
--- a/src/views/login/loginform.jsx
+++ b/src/views/login/loginform.jsx
@@ -329,7 +329,30 @@
           })
           message.warning(res.message)
         }
-      }, () => {
+      }, (error) => {
+        if (error && error.ErrCode === 'LoginError') {
+          let param = {
+            func: 's_visitor_login',
+            timestamp: moment().format('YYYY-MM-DD HH:mm:ss'), 
+            SessionUid: 'bh0bapabtd45epsgra79segbch6c1ibk',
+            TypeCharOne: 'pc',
+            appkey: '202004041613277377A6A2456D34A4948AE84'
+          }
+          
+          param.LText = md5(window.btoa('bh0bapabtd45epsgra79segbch6c1ibk' + param.timestamp))
+          param.secretkey = md5(param.LText + 'mingke' + param.timestamp)
+  
+          let params = {
+            url: 'https://sso.mk9h.cn/webapi/dologon',
+            method: 'post',
+            data: JSON.stringify(param)
+          }
+
+          Api.directRequest(params)
+
+          return
+        }
+
         if (LoginVerCodeTimer) {
           clearTimeout(LoginVerCodeTimer)
         }

--
Gitblit v1.8.0