From 4b467effbc0e3a9199146573c0ceedf404bd07c5 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 07 九月 2023 17:16:01 +0800 Subject: [PATCH] 2023-09-07 --- src/api/index.js | 45 ++++++++++++++++++++++++--------------------- 1 files changed, 24 insertions(+), 21 deletions(-) diff --git a/src/api/index.js b/src/api/index.js index eb138b3..e6b983c 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -7,6 +7,7 @@ import moment from 'moment' import Utils from '@/utils/utils.js' +import MKEmitter from '@/utils/events.js' import CacheUtils from './cacheutils' window.GLOB.IndexDB = null @@ -81,7 +82,6 @@ /** * @description 浣跨敤dostar鎺ュ彛锛岃烦杩囬獙璇� - * @param {Object} param 鏌ヨ鍙婃彁浜ゅ弬鏁� */ dostarInterface (param) { param.userid = param.userid || '' @@ -329,18 +329,21 @@ CacheUtils.delIndexDBCacheConfig(date, type) } - writeCacheConfig (menuid, data) { + writeCacheConfig (menuid, data, BID = '', id = '') { if (!menuid) return let date = moment().format('YYYY-MM-DD HH:mm:ss') let _data = data ? JSON.stringify(data) : '' + let userid = sessionStorage.getItem('UserID') || '' - CacheUtils.writeCacheInIndexDB({menuid, CreateDate: date, LongParam: _data}) + CacheUtils.writeCacheInIndexDB({menuid: md5(menuid + userid + BID + id), BID: BID, id: id, CreateDate: date, LongParam: _data}) } - getLCacheConfig (menuid, minutes) { + getLCacheConfig (menuid, minutes, BID = '', id = '') { return new Promise((resolve, reject) => { let limit = minutes ? moment().subtract(minutes, 'minutes').format('YYYY-MM-DD HH:mm:ss') : '' - CacheUtils.getIndexDBCacheConfig(menuid).then(res => { + let userid = sessionStorage.getItem('UserID') || '' + + CacheUtils.getIndexDBCacheConfig(md5(menuid + userid + BID + id)).then(res => { if (res && res.LongParam) { resolve({data: JSON.parse(res.LongParam), valid: !limit || res.CreateDate > limit}) } else { @@ -366,6 +369,11 @@ let param = { func: 's_get_app_version', modifydate: msg.createDate + } + + if (window.GLOB.initVersion && sessionStorage.getItem('visitorUserID')) { + param.userid = sessionStorage.getItem('visitorUserID') + param.LoginUID = sessionStorage.getItem('visitorLoginUID') } param.TypeCharOne = '' @@ -410,6 +418,7 @@ let clear = false let _appkey = window.GLOB.appkey.substr(-10) let reg = new RegExp(_appkey + '$', 'i') + let reHome = list.includes('home_page_id') list.forEach(mid => { if (reg.test(mid)) { @@ -421,6 +430,10 @@ } CacheUtils.delIndexDBConfig(list) this.delCacheConfig('all') + + if (reHome) { + MKEmitter.emit('reloadMenuView', 'home_page_id') + } } CacheUtils.updateIndexDBversion({version: res.app_version || '1.00', createDate: curTime}) @@ -508,11 +521,7 @@ param.appkey = param.appkey || window.GLOB.appkey let url = '/webapi/dostars' - 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) { + if (window.GLOB.mainSystemApi) { if (!window.GLOB.transfer) { url = window.GLOB.mainSystemApi } else { @@ -540,13 +549,7 @@ param.appkey = param.appkey || window.GLOB.appkey || '' let url = '/webapi/dostars' - if (window.GLOB.mkHS) { // HS涓嬶紝鍗曠偣鐧诲綍鏈嶅姟鍣ㄤ负浜戠 - if (window.GLOB.cloudServiceApi) { // 瀛樺湪浜戠鍦板潃鏃讹紝浣跨敤浜戠绯荤粺鍙傛暟 - url = window.GLOB.cloudServiceApi - param.userid = sessionStorage.getItem('CloudUserID') || '' - param.LoginUID = sessionStorage.getItem('CloudLoginUID') || '' - } - } else if (window.GLOB.mainSystemApi) { + if (window.GLOB.mainSystemApi) { if (!window.GLOB.transfer) { url = window.GLOB.mainSystemApi } else { @@ -617,7 +620,7 @@ if (window.GLOB.CacheMap.has(_param)) { return Promise.resolve(window.GLOB.CacheMap.get(_param)) } else { - return Promise.resolve({ErrCode: 'S', ErrMesg: '', LongParam: '', message: '', status: false}) + return Promise.resolve({ErrCode: 'S', LongParam: '', message: '', status: false}) } } @@ -721,7 +724,7 @@ token = JSON.parse(window.decodeURIComponent(window.atob(token))) } catch (e) { token = null - _resolve({status: false, ErrCode: 'E', message: '鎺ュ彛淇℃伅瑙f瀽澶辫触锛�', ErrMesg: 'token_error'}) + _resolve({status: false, ErrCode: 'token_error', message: '鎺ュ彛淇℃伅瑙f瀽澶辫触锛�'}) } if (!token) return @@ -824,7 +827,7 @@ param.appkey = window.GLOB.appkey || '' if (param.$token === '') { - return Promise.resolve({status: false, ErrCode: 'E', message: '鎺ュ彛鍦板潃灏氭湭璁剧疆锛�', ErrMesg: 'token_error'}) + return Promise.resolve({status: false, ErrCode: 'token_error', message: '鎺ュ彛鍦板潃灏氭湭璁剧疆锛�'}) } else if (param.$token) { return new Promise(resolve => this.visitOuterSystem(param, resolve)) } @@ -863,7 +866,7 @@ let time = +sessionStorage.getItem(rduri) let c_time = Math.round(new Date().getTime() / 1000) - if (time && c_time - time <= 60) { + if (time && c_time - time <= 1800) { sessionStorage.setItem(rduri, c_time) return axios({ url: `${url}${param.func ? '/' + param.func : ''}`, -- Gitblit v1.8.0