From 227db5450d7a0caf0f8edbddf7883acc95984421 Mon Sep 17 00:00:00 2001 From: GJ Date: Mon, 21 Sep 2026 14:32:59 +0800 Subject: [PATCH] =?UTF-8?q?feat(short-drama-agent-front):=20=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E9=A1=B9=E7=9B=AE=E6=A0=87=E9=A2=98=E8=BE=93=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/CreateProjectDialog.vue | 27 ++++++++++++++++--- src/features/projects/types.ts | 7 ++++- tests/components/ui/form.test.ts | 22 +++++++++++++++ tests/features/workflows/pages.test.ts | 4 +++ tests/lib/http.test.ts | 3 ++- 5 files changed, 58 insertions(+), 5 deletions(-) diff --git a/src/features/projects/components/CreateProjectDialog.vue b/src/features/projects/components/CreateProjectDialog.vue index 6ccd850..678c87d 100644 --- a/src/features/projects/components/CreateProjectDialog.vue +++ b/src/features/projects/components/CreateProjectDialog.vue @@ -11,12 +11,16 @@ import { errorMessage } from '../../../lib/http' /** 新建剧本表单,202 成功后交由父级跳转,不在前端模拟生成。 */ const emit = defineEmits<{ created: [projectId: string] }>() +/** 新建剧本弹窗是否打开。 */ const open = ref(false) +/** 创建请求是否正在提交。 */ const busy = ref(false) +/** 创建请求的错误提示。 */ const error = ref('') -const form = reactive({ topic: '', style: '', episodeCount: 1 }) +/** 与后端 POST /projects 入参一致的创建表单。 */ +const form = reactive({ title: '', topic: '', style: '', episodeCount: 1 }) -/** 校验正整数集数和主题,禁止双击产生重复项目。 */ +/** 校验项目标题、主题与正整数集数,禁止双击产生重复项目。 */ async function submit() { if (busy.value) return error.value = '' @@ -24,10 +28,12 @@ async function submit() { try { const result = await projectsApi.create({ ...form, + title: form.title.trim(), topic: form.topic.trim(), style: form.style.trim() }) open.value = false + form.title = '' form.topic = '' emit('created', result.projectId) } catch (cause) { @@ -36,7 +42,12 @@ async function submit() { busy.value = false } } -const rules = { topic: requiredTextRule('故事主题'), episodeCount: integerRule('计划集数') } +/** 创建项目表单校验规则。 */ +const rules = { + title: requiredTextRule('项目标题'), + topic: requiredTextRule('故事主题'), + episodeCount: integerRule('计划集数') +}