Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
W
WebPublic
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
前端开发小组
WebPublic
Commits
462f7276
提交
462f7276
authored
1月 24, 2022
作者:
钟是志
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
演示环境开发
上级
039c862d
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
32 行增加
和
13 行删除
+32
-13
request.js
one_stop_public/utils/request.js
+32
-13
没有找到文件。
one_stop_public/utils/request.js
浏览文件 @
462f7276
...
@@ -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
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论