From d3d512edc50ac9a9caf8ddb395997642baf1c3f2 Mon Sep 17 00:00:00 2001 From: Tevin <tingquanren@163.com> Date: Tue, 12 Jan 2021 17:11:27 +0800 Subject: [PATCH] 实现界面锁定功能 --- bases/Fetcher.js | 17 ++++++++++------- 1 files changed, 10 insertions(+), 7 deletions(-) diff --git a/bases/Fetcher.js b/bases/Fetcher.js index f845bae..f0124fe 100644 --- a/bases/Fetcher.js +++ b/bases/Fetcher.js @@ -30,8 +30,9 @@ 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8', 'Ax-Rq-Type': 'separation', }, + credentials: 'same-origin', dataType: 'json', - timeout: 10000, + timeout: 30 * 1000, }; /** @@ -102,8 +103,10 @@ const params = Qs.stringify(data); const data2 = {}; params.split('&').forEach(param => { - const item = param.split('='); - data2[decodeURIComponent(item[0])] = decodeURIComponent(item[1]); + if (param) { + const item = param.split('='); + data2[decodeURIComponent(item[0])] = decodeURIComponent(item[1]); + } }); return this.query('post', url, data2, remap, options); } @@ -117,7 +120,7 @@ * @param {object} [options] * @return {Promise<any>|} */ - query(type, url, data = null, remap, options) { + query(type, url, data = null, remap, options = {}) { return new Promise((resolve, reject) => { Taro.request({ ...this._defaultConfig, @@ -439,7 +442,7 @@ } else { // 修复补齐 if (type === 'fix') { - if (!path || /^\/(upload|static)/.test(path)) { + if (!path || /^(http|\/upload|\/static)/.test(path)) { return path; } else { return '/upload/' + path; @@ -488,11 +491,11 @@ */ static inDevMod = (() => { // 当处于 mock 请求模式,视为本地开发 - if (Tools.getTopUrlParam('query') === 'mock') { + if (Tools.getUrlParam('query') === 'mock') { return true; } // 强制 real 请求,可在本地使用真实请求 - if (Tools.getTopUrlParam('query') === 'real') { + if (Tools.getUrlParam('query') === 'real') { return false; } // 当没有 url 指定时,只有内网 ip 和 33** 的端口号,视为本地开发模式 -- Gitblit v1.9.1