5294528148
Co-authored-by: Copilot <copilot@github.com>
21 lines
719 B
TypeScript
21 lines
719 B
TypeScript
/**
|
|
* 所有服务端接口的统一响应结构。
|
|
* 前端调用 /api/* 时统一接收这个格式。
|
|
*/
|
|
export interface ICommonResponse<T = any> {
|
|
/** 业务状态码:0 = 成功,其他值为对应错误码 */
|
|
code: number;
|
|
/** 响应数据:成功时为实际数据,无数据或失败时为 null */
|
|
data: T | null;
|
|
/** 提示信息:成功或失败时展示给前端的文案 */
|
|
msg: string;
|
|
}
|
|
|
|
/** 语义化的成功响应类型,code 固定为字面量 0,便于类型收窄 */
|
|
export type ISuccessResponse<T = any> = ICommonResponse<T> & { code: 0 };
|
|
|
|
/** 语义化的错误响应类型 */
|
|
export type IErrorResponse = ICommonResponse<null> & { code: number };
|
|
|
|
export * from "./user";
|