feat: 对接题目状态转换接口,补全转换路径和错误处理

- 补全 draft→archived、reviewing→archived 转换路径,与 API 规范对齐
- 添加 draft→archived、reviewing→archived 状态流转描述文案
- 为 confirmStatusChange、handleApproveUgc、handleRejectUgc 添加 try/catch 错误处理
This commit is contained in:
Wang Zhuoxuan 2026-04-11 21:56:59 +08:00
parent 8e3d4ed190
commit d1af1dbe11
4 changed files with 36 additions and 18 deletions

View File

@ -14,7 +14,8 @@
"Bash(bunx:*)", "Bash(bunx:*)",
"Bash(bun run:*)", "Bash(bun run:*)",
"Bash(git add:*)", "Bash(git add:*)",
"Bash(git commit:*)" "Bash(git commit:*)",
"mcp__plugin_ecc_sequential-thinking__sequentialthinking"
] ]
} }
} }

View File

@ -65,8 +65,10 @@ export function StatusTransitionDialog({
function getDescription(from: QuestionStatus, to: QuestionStatus): string { function getDescription(from: QuestionStatus, to: QuestionStatus): string {
const descriptions: Record<string, string> = { const descriptions: Record<string, string> = {
"draft→reviewing": "提交后题目将进入审核队列,等待审核通过后才能发布。", "draft→reviewing": "提交后题目将进入审核队列,等待审核通过后才能发布。",
"draft→archived": "直接将草稿题目归档,题目将不会出现在任何列表中。可随时恢复为草稿。",
"reviewing→published": "审核通过后题目将对所有用户可见,请确认题目内容无误。", "reviewing→published": "审核通过后题目将对所有用户可见,请确认题目内容无误。",
"reviewing→draft": "将题目退回草稿状态,可以继续修改后重新提交。", "reviewing→draft": "将题目退回草稿状态,可以继续修改后重新提交。",
"reviewing→archived": "将审核中的题目直接归档,不再继续审核流程。可随时恢复为草稿。",
"published→archived": "下架后题目将对用户不可见,但数据会保留。可随时恢复为草稿。", "published→archived": "下架后题目将对用户不可见,但数据会保留。可随时恢复为草稿。",
"archived→draft": "恢复为草稿后可以重新编辑并提交审核。", "archived→draft": "恢复为草稿后可以重新编辑并提交审核。",
} }

View File

@ -28,9 +28,9 @@ interface ColumnContext {
function getQuestionStatusesForTransition(current: QuestionStatus): QuestionStatus[] { function getQuestionStatusesForTransition(current: QuestionStatus): QuestionStatus[] {
switch (current) { switch (current) {
case "draft": case "draft":
return ["reviewing"] return ["reviewing", "archived"]
case "reviewing": case "reviewing":
return ["published", "draft"] return ["published", "draft", "archived"]
case "published": case "published":
return ["archived"] return ["archived"]
case "archived": case "archived":

View File

@ -161,11 +161,16 @@ export default function QuestionsPage() {
async function confirmStatusChange() { async function confirmStatusChange() {
if (!statusTarget || !statusTargetState) return if (!statusTarget || !statusTargetState) return
await updateQuestionStatus(statusTarget.id, statusTargetState) try {
setStatusDialogOpen(false) await updateQuestionStatus(statusTarget.id, statusTargetState)
setStatusTarget(null) setStatusDialogOpen(false)
setStatusTargetState(null) setStatusTarget(null)
await loadQuestions() setStatusTargetState(null)
await loadQuestions()
} catch (err) {
const message = err instanceof Error ? err.message : "状态变更失败"
alert(message)
}
} }
function openDelete(question: Question) { function openDelete(question: Question) {
@ -201,20 +206,30 @@ export default function QuestionsPage() {
async function handleApproveUgc(_note?: string) { async function handleApproveUgc(_note?: string) {
if (!ugcReviewQuestion) return if (!ugcReviewQuestion) return
await updateQuestionStatus(ugcReviewQuestion.id, "published") try {
setUgcReviewOpen(false) await updateQuestionStatus(ugcReviewQuestion.id, "published")
setUgcReviewQuestion(null) setUgcReviewOpen(false)
await loadQuestions() setUgcReviewQuestion(null)
await loadQuestions()
} catch (err) {
const message = err instanceof Error ? err.message : "审核操作失败"
alert(message)
}
} }
async function handleRejectUgc(_note: string) { async function handleRejectUgc(_note: string) {
if (!ugcReviewQuestion) return if (!ugcReviewQuestion) return
// TODO: 这里可以添加 API 调用来保存审核备注 try {
// 暂时只更新状态 // TODO: 这里可以添加 API 调用来保存审核备注
await updateQuestionStatus(ugcReviewQuestion.id, "draft") // 暂时只更新状态
setUgcReviewOpen(false) await updateQuestionStatus(ugcReviewQuestion.id, "draft")
setUgcReviewQuestion(null) setUgcReviewOpen(false)
await loadQuestions() setUgcReviewQuestion(null)
await loadQuestions()
} catch (err) {
const message = err instanceof Error ? err.message : "审核操作失败"
alert(message)
}
} }
const columns = getColumns({ const columns = getColumns({