提交 462f7276 authored 作者: 钟是志's avatar 钟是志

演示环境开发

上级 039c862d
...@@ -68,7 +68,7 @@ const objectToQuery = function(param, key, encode) { ...@@ -68,7 +68,7 @@ const objectToQuery = function(param, key, encode) {
* 异常处理程序 * 异常处理程序
*/ */
var canReportError = true; var canReportError = true;
const errorHandler = (error) => { const errorHandler = error => {
const { response } = error; const { response } = error;
if (response && response.status) { if (response && response.status) {
...@@ -105,7 +105,6 @@ const umiRequest = extend({ ...@@ -105,7 +105,6 @@ const umiRequest = extend({
errorHandler, // 默认错误处理 errorHandler, // 默认错误处理
credentials: 'omit', // 默认请求是否带上cookie credentials: 'omit', // 默认请求是否带上cookie
mode: 'cors', mode: 'cors',
}); });
const loginUmiRequest = extend({ const loginUmiRequest = extend({
...@@ -114,7 +113,7 @@ const loginUmiRequest = extend({ ...@@ -114,7 +113,7 @@ const loginUmiRequest = extend({
// mode: 'cors', // mode: 'cors',
}); });
const getUrl = (url) => (url.startsWith('/') ? url : '/' + url); const getUrl = url => (url.startsWith('/') ? url : '/' + url);
export const request = (url, data, options = {}) => { export const request = (url, data, options = {}) => {
let version = let version =
...@@ -123,7 +122,10 @@ export const request = (url, data, options = {}) => { ...@@ -123,7 +122,10 @@ export const request = (url, data, options = {}) => {
: null; : null;
if (options.method === 'GET') { if (options.method === 'GET') {
const pp = { ...data, version_: version }; const pp = {
...data,
version_: version,
};
for (let i in pp) { for (let i in pp) {
if (pp[i] == null) { if (pp[i] == null) {
delete pp[i]; delete pp[i];
...@@ -143,7 +145,7 @@ export const request = (url, data, options = {}) => { ...@@ -143,7 +145,7 @@ export const request = (url, data, options = {}) => {
requestType: 'form', requestType: 'form',
...options, ...options,
}).then((response) => { }).then(response => {
if (response.errCode && response.errCode == '10000') { if (response.errCode && response.errCode == '10000') {
const ul = window.location.href; const ul = window.location.href;
if (ul.indexOf('timeVersion=') == -1) { if (ul.indexOf('timeVersion=') == -1) {
...@@ -218,7 +220,12 @@ export const request = (url, data, options = {}) => { ...@@ -218,7 +220,12 @@ export const request = (url, data, options = {}) => {
// 由于自动添加前缀 这里暂时修改getUrl(url) // 由于自动添加前缀 这里暂时修改getUrl(url)
let fetchRequest = url.indexOf('UserApi/login') > -1 ? loginUmiRequest : umiRequest; let fetchRequest = url.indexOf('UserApi/login') > -1 ? loginUmiRequest : umiRequest;
if(window.location.href.indexOf('localhost') > -1 && url.indexOf('UserApi/login') > -1) { // 开发环境直接免密登录 2021年11月25日 if (
(window.location.href.indexOf('localhost') > -1 ||
window.location.href.indexOf('172.32.2') > -1) &&
url.indexOf('UserApi/login') > -1
) {
// 开发环境直接免密登录 2021年11月25日
fetchRequest = umiRequest; fetchRequest = umiRequest;
url = '/UserApi/loginByCount'; url = '/UserApi/loginByCount';
} }
...@@ -228,7 +235,7 @@ export const request = (url, data, options = {}) => { ...@@ -228,7 +235,7 @@ export const request = (url, data, options = {}) => {
requestType: 'form', requestType: 'form',
...options, ...options,
}).then((response) => { }).then(response => {
if (response && response.errCode && response.errCode == '10000') { if (response && response.errCode && response.errCode == '10000') {
const ul = window.location.href; const ul = window.location.href;
if (ul.indexOf('timeVersion=') == -1) { if (ul.indexOf('timeVersion=') == -1) {
...@@ -287,11 +294,11 @@ export const request = (url, data, options = {}) => { ...@@ -287,11 +294,11 @@ export const request = (url, data, options = {}) => {
} }
}; };
const setRequestConfig = (config) => { const setRequestConfig = config => {
return (url, data, options = {}) => { return (url, data, options = {}) => {
if (Array.isArray(url)) { if (Array.isArray(url)) {
return Promise.all( return Promise.all(
url.map((ags) => { url.map(ags => {
return request(ags[0], ags[1], Object.assign({}, ags[2], config)); return request(ags[0], ags[1], Object.assign({}, ags[2], config));
}), }),
); );
...@@ -310,12 +317,24 @@ export const dynamicRequest = createServerRequest({ ...@@ -310,12 +317,24 @@ export const dynamicRequest = createServerRequest({
prefix: queryDynamicActionPath(), prefix: queryDynamicActionPath(),
}); });
export const uaaRequest = createServerRequest({ method: 'POST', prefix: queryOauthActionPath() }); export const uaaRequest = createServerRequest({
method: 'POST',
prefix: queryOauthActionPath(),
});
export const permRequest = createServerRequest({ method: 'POST', prefix: queryPermActionPath() }); export const permRequest = createServerRequest({
method: 'POST',
prefix: queryPermActionPath(),
});
export const apiRequest = createServerRequest({ method: 'POST', prefix: queryApiActionPath() }); export const apiRequest = createServerRequest({
method: 'POST',
prefix: queryApiActionPath(),
});
export const getRequest = createServerRequest({ method: 'GET', prefix: queryApiActionPath() }); export const getRequest = createServerRequest({
method: 'GET',
prefix: queryApiActionPath(),
});
export default request; export default request;
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论