Files
aiartstudio/shared/types/index.ts
T
2026-04-25 19:14:58 +08:00

22 lines
745 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 "./openai";
export * from "./user";