From dfdcdcb3dbd0b711bc0b77bb00fd1d39af91bd0b Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 10 一月 2025 17:43:34 +0800 Subject: [PATCH] 2025-01-10 --- src/api/index.js | 56 +++++++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 45 insertions(+), 11 deletions(-) diff --git a/src/api/index.js b/src/api/index.js index 1633765..426e70a 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,6 +75,32 @@ placement: 'bottomRight', duration: 15 }) + if ([500, 504].includes(response.status) && error.config && error.config.url && error.config.data) { + window.mkInfo(error.config.url) + 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)) + } + } + } + } } return Promise.reject(response) @@ -175,12 +202,7 @@ * @description 娓稿鐧诲綍 */ getTouristMsg (binding_type, appid, openid, memberid, scanId) { - let _SessionUid = localStorage.getItem('SessionUid') - - if (!_SessionUid) { // 鎵嬪姩娓呴櫎SessionUid鏃讹紝瀹炴椂鐢熸垚 - _SessionUid = Utils.getuuid() - localStorage.setItem('SessionUid', _SessionUid) - } + let _SessionUid = localStorage.getItem('SessionUid') || '' let param = { func: 's_visitor_login', @@ -434,7 +456,7 @@ CacheUtils.delIndexDBConfig(list) this.delCacheConfig('all') - if (reHome) { + if (reHome && reload !== 'home_page_id') { MKEmitter.emit('reloadMenuView', 'home_page_id') } } @@ -715,9 +737,14 @@ if (res.mksqls) { res.mksqls.forEach(n => { n = n.replace(/(UNION ALL\s+)?SELECT obj_name='[\S\s]+sub_field=''\s+/ig, '') - window.mkInfo(n) + if (!res.status) { + window.mkInfo('%c' + n, 'color: #f5222d') + } else { + window.mkInfo(n) + } }) } + delete res.mksqls if (res.ErrCode === 'version_error') { res.ErrCode = '-2' MKEmitter.emit('reloadTabs') @@ -1033,9 +1060,14 @@ if (res.mksqls) { res.mksqls.forEach(n => { n = n.replace(/(UNION ALL\s+)?SELECT obj_name='[\S\s]+sub_field=''\s+/ig, '') - window.mkInfo(n) + if (!res.status) { + window.mkInfo('%c' + n, 'color: #f5222d') + } else { + window.mkInfo(n) + } }) } + delete res.mksqls if (!res.status) { if (res.ErrCode === 'version_error') { res.ErrCode = '-2' @@ -1228,7 +1260,7 @@ /** * @description sql妫�楠� */ - sDebug (sql) { + sDebug (sql, skip = false) { let param = { func: 's_debug_sql', exec_type: window.GLOB.execType || 'y', @@ -1256,6 +1288,8 @@ window.mkInfo(`/* sql 楠岃瘉 */\n${sql.replace(/\n\s{6,20}/ig, '\n')}`) + if (skip) return + sql = sql.replace(/\n/ig, ' ') param.LText = Utils.formatOptions(sql, param.exec_type) -- Gitblit v1.8.0