更新若干
This commit is contained in:
1 parent
54c90072fb
commit
5682069553
59 files changed
+3813
-1617
No files matched your search
@@ -61,7 +61,7 @@ async function replayRequest(options) {
|
||||
}
|
||||
|
||||
export function request(options = {}) {
|
||||
const { url, method = 'GET', data, header = {}, silent = false, timeout = 30000 } = options
|
||||
const { url, method = 'GET', data, header = {}, silent = false, timeout = 30000, skipAuthRedirect = false } = options
|
||||
const headers = {
|
||||
'Content-Type': 'application/json',
|
||||
...header
|
||||
@@ -82,6 +82,14 @@ export function request(options = {}) {
|
||||
const body = res.data || {}
|
||||
|
||||
if (status === 401 || body.code === 401) {
|
||||
if (skipAuthRedirect) {
|
||||
const msg = body.msg || '登录失败'
|
||||
const err = new Error(msg)
|
||||
err.code = 401
|
||||
err.response = body
|
||||
reject(err)
|
||||
return
|
||||
}
|
||||
if (!isLoggedIn() && getGuestToken()) {
|
||||
clearGuestToken()
|
||||
if (!silent) {
|
||||
|
||||
Reference in new issue
Block a user