|
@@ -13,8 +13,9 @@ export interface SearchInitParams {
|
|
|
|
|
|
const request = extend({
|
|
|
// requestType: 'form',
|
|
|
+ hideLoading: true, // 默认都不显示加载
|
|
|
timeout: 20000,
|
|
|
- timeoutMessage: '请求超时'
|
|
|
+ timeoutMessage: '请求超时',
|
|
|
})
|
|
|
|
|
|
// request.use(async (ctx, next) => {
|
|
@@ -35,9 +36,10 @@ let toast: ReturnType<typeof setTimeout>
|
|
|
request.interceptors.request.use(
|
|
|
(url, options: any) => {
|
|
|
// openLoading();
|
|
|
+ // console.log(options, 'request')
|
|
|
if (!options.hideLoading) {
|
|
|
clearTimeout(toast)
|
|
|
- baseEvent.emit('toastShow')
|
|
|
+ baseEvent.emit('toastShow', 'center')
|
|
|
// clearTimeout(toast)
|
|
|
// showLoadingToast({
|
|
|
// message: '加载中...',
|
|
@@ -93,7 +95,7 @@ request.interceptors.request.use(
|
|
|
request.interceptors.response.use(
|
|
|
async (res) => {
|
|
|
toast = setTimeout(() => {
|
|
|
- baseEvent.emit('toastClose')
|
|
|
+ baseEvent.emit('toastClose', 'center')
|
|
|
// closeToast()
|
|
|
}, 100)
|
|
|
|
|
@@ -101,7 +103,7 @@ request.interceptors.response.use(
|
|
|
if (res.status > 299 || res.status < 200) {
|
|
|
clearTimeout(toast)
|
|
|
const msg = '服务器错误,状态码' + res.status
|
|
|
- baseEvent.emit('toastClose')
|
|
|
+ baseEvent.emit('toastClose', 'center')
|
|
|
showToast(msg)
|
|
|
throw new Error(msg)
|
|
|
}
|
|
@@ -119,7 +121,7 @@ request.interceptors.response.use(
|
|
|
console.log(data.code, '5104')
|
|
|
if (!(data.code === 403 || data.code === 5000)) {
|
|
|
clearTimeout(toast)
|
|
|
- baseEvent.emit('toastClose')
|
|
|
+ baseEvent.emit('toastClose', 'center')
|
|
|
showToast(msg)
|
|
|
}
|
|
|
const browserInfo = browser()
|