// server/utils/response.ts - 统一 API 响应工具函数(非 OCS 接口专用) // OCS 搜题接口 /api/search 有固定的兼容格式,不使用此工具 /** 成功响应:code 0,data 为业务数据,msg 固定为"请求成功" */ export const apiOk = (data: T) => ({ code: 0 as const, data, msg: "请求成功" }); /** 错误响应:data 固定为 null,msg 为本地安全文案,不暴露上游细节 */ export const apiErr = (code: number, msg: string) => ({ code, data: null, msg });