From 37b936ec52141fec0afba6c125952bf07b7ca68c Mon Sep 17 00:00:00 2001 From: Wang Zhuoxuan Date: Sun, 12 Apr 2026 00:34:09 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AF=B9=E6=8E=A5=E9=A2=98=E7=9B=AE?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E6=8E=A5=E5=8F=A3=EF=BC=8C=E7=BB=9F=E4=B8=80?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=A8=A1=E5=9E=8B=E4=B8=8E=20API=20=E8=A7=84?= =?UTF-8?q?=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Question.stem 从 string 改为 { text: string } 对象,匹配 API 多语言题干格式 - 新增 contentType 字段(text/image/video/audio) - knowledgeCard 从扁平字段重组为嵌套对象 { summary, deepDive?, sourceRef? } - source/stats 改为可选字段,UI 添加空值回退 - 查询参数对齐:search→keyword, sort→sortBy, order→sortOrder - QuestionForm 接入 createQuestion/updateQuestion API - KnowledgeCardFields 组件重命名 props 匹配新结构 --- .../question/KnowledgeCardFields.tsx | 80 ++++++++-------- src/components/question/QuestionForm.tsx | 96 +++++++++++++------ .../question/StatusTransitionDialog.tsx | 2 +- src/components/question/UgcReviewDialog.tsx | 65 ++++++++----- src/components/question/columns.tsx | 15 +-- src/lib/api/question-api.ts | 12 +-- src/routes/questions/index.tsx | 12 +-- src/types/question.ts | 45 ++++++--- 8 files changed, 201 insertions(+), 126 deletions(-) diff --git a/src/components/question/KnowledgeCardFields.tsx b/src/components/question/KnowledgeCardFields.tsx index 6551ae7..ab1c853 100644 --- a/src/components/question/KnowledgeCardFields.tsx +++ b/src/components/question/KnowledgeCardFields.tsx @@ -13,42 +13,42 @@ import { } from "@/components/ui/card" import { Badge } from "@/components/ui/badge" -const BASIC_MAX = 100 -const DEEP_MAX = 300 +const SUMMARY_MAX = 2000 +const DEEP_DIVE_MAX = 300 interface KnowledgeCardFieldsProps { - basicRegister: UseFormRegisterReturn - deepRegister: UseFormRegisterReturn + summaryRegister: UseFormRegisterReturn + deepDiveRegister: UseFormRegisterReturn sourceRefRegister: UseFormRegisterReturn - basicError?: string - deepError?: string - watchBasic: string - watchDeep: string + summaryError?: string + deepDiveError?: string + watchSummary: string + watchDeepDive: string } export function KnowledgeCardFields({ - basicRegister, - deepRegister, + summaryRegister, + deepDiveRegister, sourceRefRegister, - basicError, - deepError, - watchBasic, - watchDeep, + summaryError, + deepDiveError, + watchSummary, + watchDeepDive, }: KnowledgeCardFieldsProps) { const [showPreview, setShowPreview] = useState(false) - const [deepExpanded, setDeepExpanded] = useState(!!watchDeep) + const [deepExpanded, setDeepExpanded] = useState(!!watchDeepDive) - const basicCount = watchBasic.length - const deepCount = watchDeep.length - const basicOver = basicCount > BASIC_MAX - const deepOver = deepCount > DEEP_MAX + const summaryCount = watchSummary.length + const deepCount = watchDeepDive.length + const summaryOver = summaryCount > SUMMARY_MAX + const deepOver = deepCount > DEEP_DIVE_MAX return (
- {/* 基础版 */} + {/* 摘要 */}
- + 所有用户可见 @@ -57,31 +57,31 @@ export function KnowledgeCardFields({ 2-3 句趣味解读,让用户答完题后学到新知识