| | |
| | | import options from '@/store/options.js' |
| | | |
| | | let mkDataBase = null |
| | | let storUsable = false |
| | | |
| | | if (window.openDatabase) { |
| | | let service = window.GLOB.service ? '-' + window.GLOB.service.replace('/', '') : '' |
| | |
| | | mkDataBase = openDatabase(`mkdb${service}`, '1', 'mk-pc-database', 50 * 1024 * 1024) |
| | | mkDataBase.transaction(tx => { |
| | | tx.executeSql('CREATE TABLE IF NOT EXISTS VERSIONS (version varchar(50), createDate varchar(50), CDefine1 varchar(50), CDefine2 varchar(50), CDefine3 varchar(50))', [], () => { |
| | | |
| | | |
| | | }, () => { |
| | | // eslint-disable-next-line |
| | | throw 'CREATE TABLE ERROR' |
| | |
| | | return Promise.reject(error) |
| | | }) |
| | | |
| | | const setCurrentUrl = () => { |
| | | const setCurrentUrl = (res) => { |
| | | if (!!(window.history && window.history.pushState)) { |
| | | if (window.location.href.indexOf('paramsmain') > -1) { |
| | | let _href = window.location.href.split('#') |
| | |
| | | } |
| | | |
| | | sessionStorage.clear() |
| | | sessionStorage.setItem('loginError', JSON.stringify({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() |
| | | } |
| | | } |
| | | |
| | | window.GLOB.CacheMap = new Map() |
| | | |
| | | axios.interceptors.response.use((response) => { |
| | | if (response.data.ErrCode === 'LoginError') { |
| | |
| | | response.data.ErrCode = 'E' |
| | | return Promise.resolve(response.data) |
| | | } else { |
| | | setCurrentUrl() |
| | | setCurrentUrl(response) |
| | | } |
| | | } else { |
| | | return Promise.resolve(response.data) |
| | | } |
| | | }, (error) => { |
| | | notification.error({ |
| | | className: 'notification-custom-error', |
| | | bottom: 0, |
| | | message: '状态码-' + error.response.status + ',请联系管理员', |
| | | placement: 'bottomRight', |
| | | duration: 15 |
| | | }) |
| | | if (error && error.response) { |
| | | notification.error({ |
| | | className: 'notification-custom-error', |
| | | bottom: 0, |
| | | message: '状态码-' + error.response.status + ',请联系管理员', |
| | | placement: 'bottomRight', |
| | | duration: 15 |
| | | }) |
| | | } |
| | | return Promise.reject(error) |
| | | }) |
| | | |
| | |
| | | }) |
| | | }) |
| | | }, () => { |
| | | _reject() |
| | | mkDataBase = null |
| | | _reject() |
| | | return Promise.reject() |
| | | }).then(() => { |
| | | storUsable = true |
| | | _resolve(appVersion) |
| | | }, () => { |
| | | mkDataBase = null |
| | | _reject() |
| | | }) |
| | | } |
| | | |
| | |
| | | _param = JSON.stringify(_param) |
| | | _param = md5(_param) |
| | | |
| | | if (mkDataBase && storUsable) { |
| | | if (mkDataBase) { |
| | | param = this.encryptParam(param) |
| | | |
| | | return new Promise(resolve => { |
| | |
| | | }) |
| | | } |
| | | }, (tx, results) => { |
| | | mkDataBase = null |
| | | console.warn(results) |
| | | |
| | | axios({ |
| | | url: `/webapi/dostars${param.func ? '/' + param.func : ''}`, |
| | | data: param |
| | |
| | | } |
| | | resolve(res) |
| | | }) |
| | | mkDataBase = null |
| | | storUsable = false |
| | | console.warn(results) |
| | | }) |
| | | }) |
| | | }) |
| | |
| | | } |
| | | |
| | | /** |
| | | * @description 获取本地系统配置 |
| | | * @param {Object} param 请求参数 |
| | | */ |
| | | getLocalCacheConfig (param) { |
| | | param.userid = sessionStorage.getItem('UserID') || '' |
| | | param.lang = localStorage.getItem('lang') || '' |
| | | param.SessionUid = localStorage.getItem('SessionUid') || '' |
| | | param.LoginUID = sessionStorage.getItem('LoginUID') || '' |
| | | param.appkey = window.GLOB.appkey || '' |
| | | |
| | | if (window.GLOB.mainSystemApi) { |
| | | param.rduri = window.GLOB.mainSystemApi |
| | | } |
| | | |
| | | let _param = md5(JSON.stringify(param)) |
| | | |
| | | if (mkDataBase) { |
| | | return new Promise(resolve => { |
| | | mkDataBase.transaction(tx => { |
| | | tx.executeSql(`SELECT * FROM CONFIGS WHERE menuid='${param.MenuID}' and userid='${param.userid}'`, [], (tx, results) => { |
| | | let paramItem = results.rows[0] |
| | | if (paramItem) { |
| | | resolve({ ErrCode: 'S', ErrMesg: '', LongParam: paramItem.LongParam, message: '', status: true }) |
| | | } else { |
| | | resolve({ ErrCode: 'S', ErrMesg: '', LongParam: '', message: '', status: false }) |
| | | } |
| | | }, (tx, results) => { |
| | | mkDataBase = null |
| | | resolve({ErrCode: 'S', ErrMesg: '', LongParam: '', message: '', status: false}) |
| | | }) |
| | | }) |
| | | }) |
| | | } else 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}) |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @description 将数据写入websql |
| | | */ |
| | | writeInWebSql (data) { |