feat: 使用mitt库
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import axios, { type AxiosInstance, type CreateAxiosDefaults } from 'axios'
|
||||
import { useAccountStore } from '@/stores'
|
||||
import { eventBus, AppEvents } from '@/utils'
|
||||
import type { ApiResponse, InternalRequestConfig, RequestErrorEvent } from './types'
|
||||
import type { ApiResponse, InternalRequestConfig } from './types'
|
||||
import { createRefreshTokenInterceptor } from './refreshInterceptor'
|
||||
|
||||
/**
|
||||
@@ -106,7 +106,7 @@ class RequestClient {
|
||||
type: 'business',
|
||||
code: data.code,
|
||||
message: data.message || '请求失败'
|
||||
} satisfies RequestErrorEvent)
|
||||
})
|
||||
return Promise.reject(data)
|
||||
},
|
||||
(error) => {
|
||||
@@ -121,7 +121,7 @@ class RequestClient {
|
||||
message: error.response
|
||||
? `请求错误 (${error.response.status})`
|
||||
: '网络异常,请检查网络连接'
|
||||
} satisfies RequestErrorEvent)
|
||||
})
|
||||
return Promise.reject(error)
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user