feat: 使用mitt库

This commit is contained in:
2026-06-22 14:36:20 +08:00
parent fe8918c06f
commit 70c4bab3f6
4 changed files with 22 additions and 79 deletions

View File

@@ -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)
}
)