From 4adb8b8868aeed1f5f3b89ae269a7724c6b451ad Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 11 八月 2023 16:58:31 +0800 Subject: [PATCH] 2023-08-11 --- src/api/index.js | 52 ++++++++++++++++++++++++---------------------------- 1 files changed, 24 insertions(+), 28 deletions(-) diff --git a/src/api/index.js b/src/api/index.js index cd5b4fb..eb138b3 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -5,9 +5,9 @@ import CryptoJS from 'crypto-js' import jsSHA from 'jssha' import moment from 'moment' + import Utils from '@/utils/utils.js' import CacheUtils from './cacheutils' -import options from '@/store/options.js' window.GLOB.IndexDB = null window.GLOB.OuterToken = {} @@ -61,7 +61,7 @@ }, (error) => { let response = error.response || '' - if (response && (!response.data || !response.data.errors)) { // 杩囨护鏃疯鎶ラ敊淇℃伅 + if (response && response.status) { notification.error({ className: 'notification-custom-error', bottom: 0, @@ -241,7 +241,7 @@ Password: '', check_code: checkcode, way_no: 'sms_vcode', - systemType: options.sysType, + systemType: window.GLOB.sysType, login_city: sessionStorage.getItem('city') || '', login_id_address: sessionStorage.getItem('ipAddress') || '', kei_id: window.btoa(window.encodeURIComponent(window.GLOB.host)), @@ -252,11 +252,11 @@ let url = '/webapi/dologon' if (isCloud) { param.debug = 'Y' - if (options.cloudServiceApi) { - param.rduri = options.cloudServiceApi.replace(/\/webapi(.*)/, '/webapi/dologon') + if (window.GLOB.cloudServiceApi) { + param.rduri = window.GLOB.cloudServiceApi.replace(/\/webapi(.*)/, '/webapi/dologon') } } else if (window.GLOB.mainSystemApi) { - if (options.sysType !== 'cloud' && window.GLOB.systemType !== 'production') { + if (window.GLOB.sysType !== 'cloud' && window.GLOB.systemType !== 'production') { param.linkurl = window.GLOB.linkurl } param.rduri = window.GLOB.mainSystemApi.replace(/\/webapi(.*)/, '/webapi/dologon') @@ -277,7 +277,7 @@ let param = { // func: 'webapi_login', UserName: username, - systemType: options.sysType, + systemType: window.GLOB.sysType, Type: 'S', login_city: sessionStorage.getItem('city') || '', login_id_address: sessionStorage.getItem('ipAddress') || '', @@ -307,11 +307,11 @@ if (isCloud) { param.debug = 'Y' - if (options.cloudServiceApi) { - param.rduri = options.cloudServiceApi.replace(/\/webapi(.*)/, '/webapi/dologon') + if (window.GLOB.cloudServiceApi) { + param.rduri = window.GLOB.cloudServiceApi.replace(/\/webapi(.*)/, '/webapi/dologon') } } else if (window.GLOB.mainSystemApi) { - if (options.sysType !== 'cloud' && window.GLOB.systemType !== 'production') { + if (window.GLOB.sysType !== 'cloud' && window.GLOB.systemType !== 'production') { param.linkurl = window.GLOB.linkurl } param.rduri = window.GLOB.mainSystemApi.replace(/\/webapi(.*)/, '/webapi/dologon') @@ -339,18 +339,14 @@ getLCacheConfig (menuid, minutes) { return new Promise((resolve, reject) => { - if (window.GLOB.IndexDB) { - let limit = minutes ? moment().subtract(minutes, 'minutes').format('YYYY-MM-DD HH:mm:ss') : '' - CacheUtils.getIndexDBCacheConfig(menuid).then(res => { - if (res && res.LongParam) { - resolve({data: JSON.parse(res.LongParam), valid: !limit || res.CreateDate > limit}) - } else { - resolve({data: null, valid: false}) - } - }) - } else { - resolve({data: null, valid: false}) - } + let limit = minutes ? moment().subtract(minutes, 'minutes').format('YYYY-MM-DD HH:mm:ss') : '' + CacheUtils.getIndexDBCacheConfig(menuid).then(res => { + if (res && res.LongParam) { + resolve({data: JSON.parse(res.LongParam), valid: !limit || res.CreateDate > limit}) + } else { + resolve({data: null, valid: false}) + } + }) }) } @@ -465,7 +461,7 @@ param = this.encryptParam(param) - let url = options.cloudServiceApi ? options.cloudServiceApi : '/webapi/dostars' + let url = window.GLOB.cloudServiceApi ? window.GLOB.cloudServiceApi : '/webapi/dostars' if (param.func) { url = url + '/' + param.func } @@ -512,8 +508,8 @@ param.appkey = param.appkey || window.GLOB.appkey let url = '/webapi/dostars' - if (window.GLOB.mkHS && options.cloudServiceApi) { // HS涓嬶紝涓斿瓨鍦ㄤ簯绔湴鍧� - url = options.cloudServiceApi + if (window.GLOB.mkHS && window.GLOB.cloudServiceApi) { // HS涓嬶紝涓斿瓨鍦ㄤ簯绔湴鍧� + url = window.GLOB.cloudServiceApi param.userid = sessionStorage.getItem('CloudUserID') || '' param.LoginUID = sessionStorage.getItem('CloudLoginUID') || '' } else if (window.GLOB.mainSystemApi) { @@ -545,8 +541,8 @@ let url = '/webapi/dostars' if (window.GLOB.mkHS) { // HS涓嬶紝鍗曠偣鐧诲綍鏈嶅姟鍣ㄤ负浜戠 - if (options.cloudServiceApi) { // 瀛樺湪浜戠鍦板潃鏃讹紝浣跨敤浜戠绯荤粺鍙傛暟 - url = options.cloudServiceApi + if (window.GLOB.cloudServiceApi) { // 瀛樺湪浜戠鍦板潃鏃讹紝浣跨敤浜戠绯荤粺鍙傛暟 + url = window.GLOB.cloudServiceApi param.userid = sessionStorage.getItem('CloudUserID') || '' param.LoginUID = sessionStorage.getItem('CloudLoginUID') || '' } @@ -765,7 +761,7 @@ } else { let _param = { UserName: token.username, - systemType: options.sysType, + systemType: window.GLOB.sysType, login_city: sessionStorage.getItem('city') || '', device_id: token.appkey || '', timestamp: moment().format('YYYY-MM-DD HH:mm:ss'), -- Gitblit v1.8.0