fix: $message

This commit is contained in:
zclzone 2022-11-24 21:05:42 +08:00
parent 4c1c77821f
commit 264119a142

View File

@ -35,7 +35,7 @@ export function resResolve(response) {
const message = resolveResError(code, data?.message ?? statusText)
/** 需要错误提醒 */
!config.noNeedTip && $message.error(message)
!config.noNeedTip && window.$message?.error(message)
return Promise.reject({ code, message, error: data || response })
}
return Promise.resolve(data)
@ -46,13 +46,13 @@ export function resReject(error) {
const code = error?.code
/** 根据code处理对应的操作并返回处理后的message */
const message = resolveResError(code, error.message)
$message?.error(message)
window.$message?.error(message)
return Promise.reject({ code, message, error })
}
const { data, status, config } = error.response
const code = data?.code ?? status
const message = resolveResError(code, data?.message ?? error.message)
/** 需要错误提醒 */
!config?.noNeedTip && $message.error(message)
!config?.noNeedTip && window.$message?.error(message)
return Promise.reject({ code, message, error: error.response?.data || error.response })
}