feat: 接口统一优化

This commit is contained in:
2026-05-23 13:45:58 +08:00
parent a3b1fba3ea
commit 7d68db723b
20 changed files with 302 additions and 302 deletions
+7 -15
View File
@@ -1,4 +1,8 @@
// server/utils/answer.ts - OCS 答题提示词构建、答案清洗和响应格式化
import type {
ISearchErrorResponse,
ISearchSuccessResponse
} from "~~/shared/types/answer";
/** `/api/search` 从 OCS 请求中最终抽取出的标准参数 */
export interface SearchParams {
@@ -10,21 +14,9 @@ export interface SearchParams {
options: string;
}
/** OCS AnswererWrapper handler 期望的成功响应结构 */
export interface OcsSuccessResponse {
code: 1;
/** 返回原题,handler 会将它作为匹配题目展示 */
question: string;
/** 返回最终答案;多选题必须是 `#` 分隔字符串,而不是数组 */
answer: string;
}
/** OCS AnswererWrapper handler 期望的失败响应结构 */
export interface OcsErrorResponse {
code: 0;
/** 只放本地业务文案,不暴露上游或内部异常详情 */
msg: string;
}
/** OCS 兼容响应类型别名,与 shared/types/answer.ts 保持一致 */
export type OcsSuccessResponse = ISearchSuccessResponse;
export type OcsErrorResponse = ISearchErrorResponse;
/**
* 不同题型对应的补充说明