Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
L
learn-online-pc
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
learn-online-pc
Commits
2edf5820
提交
2edf5820
authored
4月 10, 2020
作者:
zyx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
代码标准稳定版,开始把原来系统登录进行接入
上级
78c7476b
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
31 行增加
和
18 行删除
+31
-18
base_api.js
client/src/api/base_api.js
+31
-18
没有找到文件。
client/src/api/base_api.js
浏览文件 @
2edf5820
...
@@ -66,6 +66,17 @@ export default class API {
...
@@ -66,6 +66,17 @@ export default class API {
.
then
(
beforeSuccess
.
bind
(
this
),
beforeFail
.
bind
(
this
))
.
then
(
beforeSuccess
.
bind
(
this
),
beforeFail
.
bind
(
this
))
}
}
setConfirm
(
titleStr
,
btnStr
,
msgStr
)
{
return
MessageBox
.
confirm
(
msgStr
,
titleStr
,
{
confirmButtonText
:
btnStr
,
type
:
'warning'
,
showClose
:
false
,
closeOnPressEscape
:
false
,
closeOnClickModal
:
false
,
showCancelButton
:
false
})
}
/**
/**
* 统一处理request success操作,在实现业务逻辑前进行统一处理。
* 统一处理request success操作,在实现业务逻辑前进行统一处理。
* 注意:如果不能满足需求,可在接口定义处重新实现
* 注意:如果不能满足需求,可在接口定义处重新实现
...
@@ -79,10 +90,7 @@ export default class API {
...
@@ -79,10 +90,7 @@ export default class API {
if
(
data
&&
data
.
code
!==
undefined
)
{
if
(
data
&&
data
.
code
!==
undefined
)
{
if
(
data
.
code
!==
0
)
{
if
(
data
.
code
!==
0
)
{
if
(
!
/account
\/
get-user-info/gi
.
test
(
res
.
config
.
url
))
{
if
(
!
/account
\/
get-user-info/gi
.
test
(
res
.
config
.
url
))
{
Message
({
Message
({
type
:
'error'
,
message
:
data
.
msg
})
type
:
'error'
,
message
:
data
.
msg
})
}
}
return
null
return
null
}
else
if
(
data
.
code
===
0
)
{
}
else
if
(
data
.
code
===
0
)
{
...
@@ -92,21 +100,11 @@ export default class API {
...
@@ -92,21 +100,11 @@ export default class API {
return
data
return
data
}
else
if
(
status
===
403
&&
!
/
\/
getinfo$/gi
.
test
(
res
.
config
.
url
))
{
}
else
if
(
status
===
403
&&
!
/
\/
getinfo$/gi
.
test
(
res
.
config
.
url
))
{
/* 不带 code 参数,老接口模型 */
/* 不带 code 参数,老接口模型 */
MessageBox
.
confirm
(
'登录状态已过期, 请重新登录。'
,
'提示'
,
{
this
.
setConfirm
(
'提示'
,
'确定'
,
'登录状态已过期, 请重新登录。'
).
then
(()
=>
{
confirmButtonText
:
'确定'
,
type
:
'warning'
,
showClose
:
false
,
closeOnPressEscape
:
false
,
closeOnClickModal
:
false
,
showCancelButton
:
false
}).
then
(()
=>
{
/* 重新刷新当前页 */
/* 重新刷新当前页 */
window
.
location
.
reload
()
window
.
location
.
reload
()
}).
catch
(()
=>
{
}).
catch
(()
=>
{
Message
({
Message
({
type
:
'info'
,
message
:
'操作已取消,将不再记录任何数据操作,除非重新登录'
})
type
:
'info'
,
message
:
'操作已取消,将不再记录任何数据操作,除非重新登录'
})
})
})
}
else
if
(
status
!==
200
&&
data
.
message
)
{
}
else
if
(
status
!==
200
&&
data
.
message
)
{
throw
new
Error
(
data
.
message
)
throw
new
Error
(
data
.
message
)
...
@@ -121,12 +119,27 @@ export default class API {
...
@@ -121,12 +119,27 @@ export default class API {
* @param {[object]} res 如果未到达 response 阶段,则无res.response
* @param {[object]} res 如果未到达 response 阶段,则无res.response
*/
*/
_reqFail
(
res
)
{
_reqFail
(
res
)
{
debugger
let
err
=
null
let
err
=
null
if
(
res
.
code
===
'ECONNABORTED'
)
{
if
(
res
.
code
===
'ECONNABORTED'
)
{
err
=
new
Error
(
'网络超时,请稍后重试'
)
err
=
new
Error
(
'网络超时,请稍后重试'
)
}
else
if
(
res
.
response
)
{
}
else
if
(
res
.
response
)
{
err
=
new
Error
(
JSON
.
stringify
(
res
.
response
))
/* 不带 code 参数,老接口模型 */
if
(
res
.
response
.
data
)
{
if
(
!
/
\/
getinfo$/gi
.
test
(
res
.
config
.
url
)
&&
res
.
response
.
data
.
status
===
403
)
{
this
.
setConfirm
(
'提示'
,
'确定'
,
'登录状态已过期, 请重新登录。'
).
then
(()
=>
{
/* 重新刷新当前页 */
window
.
location
.
reload
()
}).
catch
(()
=>
{
Message
({
type
:
'info'
,
message
:
'已取消,将不再记录任何数据操作,除非重新登录'
})
})
}
}
else
if
(
res
.
response
.
data
.
status
===
401
&&
res
.
response
.
data
.
message
)
{
this
.
setConfirm
(
'提示'
,
'关闭'
,
res
.
response
.
data
.
message
).
then
(()
=>
{
/* 重新刷新当前页 */
window
.
location
.
reload
()
})
}
err
=
new
Error
(
JSON
.
stringify
(
res
.
response
.
data
))
}
else
{
}
else
{
err
=
new
Error
(
'msg:'
+
res
.
message
+
'stack:'
+
res
.
stack
)
err
=
new
Error
(
'msg:'
+
res
.
message
+
'stack:'
+
res
.
stack
)
err
.
code
=
500
err
.
code
=
500
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论