refactor(http): 改进响应类型兼容性并处理多种消息字段

修改 IResponse 接口为联合类型以兼容不同后端返回格式(message/msg)
在错误处理中同时检查 message 和 msg 字段
This commit is contained in:
feige996
2025-09-23 14:56:45 +08:00
parent ad83f8d9d2
commit 08a81e433b
2 changed files with 11 additions and 6 deletions

View File

@@ -12,12 +12,17 @@ export interface HttpRequestResult<T> {
requestTask: UniApp.RequestTask
}
// 通用响应格式
export interface IResponse<T = any> {
code: number | string
// 通用响应格式(兼容 msg + message 字段)
export type IResponse<T = any> = {
code: number
data: T
message: string
status: string | number
[key: string]: any // 允许额外属性
} | {
code: number
data: T
msg: string
[key: string]: any // 允许额外属性
}
// 分页请求参数