From e1cee96b38805bcccf48e7bcb9d296f2bc54c720 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 24 一月 2025 11:10:32 +0800
Subject: [PATCH] 2025-01-24

---
 src/api/index.js |   35 ++++++++++++++++++++++++++++++++---
 1 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/src/api/index.js b/src/api/index.js
index ebf3f56..e43c5bd 100644
--- a/src/api/index.js
+++ b/src/api/index.js
@@ -15,7 +15,8 @@
 window.GLOB.$error = false
 
 let service = window.GLOB.service ? '-' + window.GLOB.service.replace('/', '') : ''
-let lang = sessionStorage.getItem('lang') !== 'zh-CN' ? sessionStorage.getItem('lang') : ''
+let lang = sessionStorage.getItem('lang') || 'zh-CN'
+lang = lang !== 'zh-CN' ? lang : ''
 let db = `mkdb${service + lang}`
 
 if (window.indexedDB) {
@@ -74,9 +75,31 @@
       placement: 'bottomRight',
       duration: 15
     })
-    if ([404, 500, 504].includes(response.status) && error.config && error.config.url) {
+    if ([500, 504].includes(response.status) && error.config && error.config.url && error.config.data) {
       window.mkInfo(error.config.url)
-      error.config.data && window.mkInfo(error.config.data)
+      window.mkInfo(error.config.data)
+      if (window.GLOB.errorLog && !sessionStorage.getItem('local_error')) {
+        let urlReg = new RegExp('^(' + window.GLOB.baseurl + '|/)webapi/(exstars|dostars)', 'ig')
+        if (urlReg.test(error.config.url) && !/s_special_error_note_log/.test(error.config.url)) {
+          let res = null
+          try {
+            let data = JSON.parse(error.config.data)
+            if (!data.rduri) {
+              res = {
+                api_url: error.config.url,
+                error_code: response.status,
+                error_time: moment().format('YYYY-MM-DD HH:mm:ss'),
+                api_param: error.config.data
+              }
+            }
+          } catch (e) {
+            res = null
+          }
+          if (res) {
+            sessionStorage.setItem('local_error', JSON.stringify(res))
+          }
+        }
+      }
     }
   }
 
@@ -714,6 +737,9 @@
           if (res.mksqls) {
             res.mksqls.forEach(n => {
               n = n.replace(/(UNION ALL\s+)?SELECT obj_name='[\S\s]+sub_field=''\s+/ig, '')
+              if (!res.status && param.data[0] && param.data[0].menuname) {
+                window.mkInfo('%c' + param.data[0].menuname, 'color: #f5222d')
+              }
               window.mkInfo(n)
             })
           }
@@ -1033,6 +1059,9 @@
           if (res.mksqls) {
             res.mksqls.forEach(n => {
               n = n.replace(/(UNION ALL\s+)?SELECT obj_name='[\S\s]+sub_field=''\s+/ig, '')
+              if (!res.status && param.data[0] && param.data[0].menuname) {
+                window.mkInfo('%c' + param.data[0].menuname, 'color: #f5222d')
+              }
               window.mkInfo(n)
             })
           }

--
Gitblit v1.8.0