From f0fbb10fd66bc2c89feb76180074e1322c12495c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8C=97=E6=9E=B3?= <7854742+wang_rumeng@user.noreply.gitee.com> Date: Tue, 16 Sep 2025 19:19:54 +0800 Subject: [PATCH 01/21] =?UTF-8?q?=E6=A8=A1=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/DTO/movie_start_dto.ts | 13 +++++ .../Interaction/templateStoryService.ts | 49 ++++++++++--------- app/service/domain/Entities.ts | 6 ++- components/ChatInputBox/H5TemplateDrawer.tsx | 12 ++--- components/ChatInputBox/PcTemplateModal.tsx | 30 +++--------- 5 files changed, 57 insertions(+), 53 deletions(-) diff --git a/api/DTO/movie_start_dto.ts b/api/DTO/movie_start_dto.ts index a72e4ff..a5e0e7f 100644 --- a/api/DTO/movie_start_dto.ts +++ b/api/DTO/movie_start_dto.ts @@ -210,6 +210,19 @@ export interface CreateMovieProjectV3Request { language: string; /**模板id */ template_id: string; + /** 单次查询模式 */ + one_query_mode: boolean; + /** 自由输入 */ + freeInput?: { + /** 用户提示,提示给用户需要输入什么内容 */ + user_tips: string; + /** 约束,可选,用于传给ai,让ai去拦截用户不符合约束的输入内容 */ + constraints: string; + /** 自由输入文字 */ + free_input_text: string; + /** 输入名称 */ + input_name: string; + }[]; /** 故事角色 */ storyRole: { /** 角色名 */ diff --git a/app/service/Interaction/templateStoryService.ts b/app/service/Interaction/templateStoryService.ts index 8fa1dc4..c42764d 100644 --- a/app/service/Interaction/templateStoryService.ts +++ b/app/service/Interaction/templateStoryService.ts @@ -68,27 +68,27 @@ export const useTemplateStoryServiceHook = (): UseTemplateStoryService => { setIsLoading(true); const templates = await templateStoryUseCase.getTemplateStoryList(); - templates.forEach(template => { - if (template.id === 'f944abad-f42b-4899-b54a-a6beb9d27805') { - template.freeInputItem = { - user_tips: "How is coffee made?", - constraints: "", - free_input_text: "" - }; - // template.storyRole = []; - } - if (template.id === 'e7438cd8-a23d-4974-8cde-13b5671b410c') { - // template.freeInputItem = { - // user_tips: "Input an English word you wanna learn", - // constraints: "", - // free_input_text: "" - // }; - template.storyItem = [{ - ...template.storyItem[0], - item_name: "Choose an English word you wanna learn" - }]; - } - }); + // templates.forEach(template => { + // if (template.id === 'f944abad-f42b-4899-b54a-a6beb9d27805') { + // template.freeInputItem = { + // user_tips: "How is coffee made?", + // constraints: "", + // free_input_text: "" + // }; + // // template.storyRole = []; + // } + // if (template.id === 'e7438cd8-a23d-4974-8cde-13b5671b410c') { + // // template.freeInputItem = { + // // user_tips: "Input an English word you wanna learn", + // // constraints: "", + // // free_input_text: "" + // // }; + // template.storyItem = [{ + // ...template.storyItem[0], + // item_name: "Choose an English word you wanna learn" + // }]; + // } + // }); setTemplateStoryList(templates); setSelectedTemplate(templates[0]); @@ -256,17 +256,22 @@ export const useTemplateStoryServiceHook = (): UseTemplateStoryService => { try { // 设置 loading 状态 setIsLoading(true); + // 没有角色以及道具 时,需要设置为true + const one_query_mode = selectedTemplate?.storyRole?.length === 0 && selectedTemplate?.storyItem?.length === 0; + const script = selectedTemplate?.freeInputItem && selectedTemplate.freeInputItem.length > 0 ? selectedTemplate.freeInputItem[0].free_input_text : selectedTemplate?.generateText || ""; const params: CreateMovieProjectV3Request = { - script: selectedTemplate?.freeInputItem?.free_input_text || selectedTemplate?.generateText || "", + script: script, category: selectedTemplate?.category || "", user_id, mode, resolution, storyRole: selectedTemplate?.storyRole || [], storyItem: selectedTemplate?.storyItem || [], + freeInput: selectedTemplate?.freeInputItem || [], language, template_id: selectedTemplate?.template_id || "", + one_query_mode: one_query_mode }; console.log("params", params); const result = await MovieProjectService.createProject( diff --git a/app/service/domain/Entities.ts b/app/service/domain/Entities.ts index 0f26ff8..bd39596 100644 --- a/app/service/domain/Entities.ts +++ b/app/service/domain/Entities.ts @@ -173,12 +173,14 @@ export interface StoryTemplateEntity { photo_url: string; }[]; /** 自由输入文字 */ - freeInputItem?: { + freeInputItem: { /** 用户提示,提示给用户需要输入什么内容 */ user_tips: string; /** 约束,可选,用于传给ai,让ai去拦截用户不符合约束的输入内容 */ constraints: string; /** 自由输入文字 */ free_input_text: string; - } + /** 输入名称 */ + input_name: string; + }[]; } diff --git a/components/ChatInputBox/H5TemplateDrawer.tsx b/components/ChatInputBox/H5TemplateDrawer.tsx index 693fc3c..a0ca6c4 100644 --- a/components/ChatInputBox/H5TemplateDrawer.tsx +++ b/components/ChatInputBox/H5TemplateDrawer.tsx @@ -491,20 +491,20 @@ export const H5TemplateDrawer = ({
- {selectedTemplate?.freeInputItem && ( + {selectedTemplate?.freeInputItem && selectedTemplate.freeInputItem.length > 0 && (
{ const updatedTemplate = { ...selectedTemplate!, - freeInputItem: { - ...selectedTemplate!.freeInputItem, + freeInputItem: selectedTemplate!.freeInputItem.map((item) => ({ + ...item, free_input_text: e.target.value, - }, + })), } as StoryTemplateEntity; setSelectedTemplate(updatedTemplate); }} diff --git a/components/ChatInputBox/PcTemplateModal.tsx b/components/ChatInputBox/PcTemplateModal.tsx index ee2ebbe..0a70507 100644 --- a/components/ChatInputBox/PcTemplateModal.tsx +++ b/components/ChatInputBox/PcTemplateModal.tsx @@ -91,22 +91,6 @@ export const PcTemplateModal = ({ clearData, } = useTemplateStoryServiceHook(); - // 防抖处理的输入更新函数 - const debouncedUpdateInput = debounce((value: string) => { - // 过滤特殊字符 - const sanitizedValue = value.replace(/[<>]/g, ''); - // 更新输入值 - if (!selectedTemplate?.freeInputItem) return; - const updatedTemplate: StoryTemplateEntity = { - ...selectedTemplate, - freeInputItem: { - ...selectedTemplate.freeInputItem, - free_input_text: sanitizedValue - } - }; - setSelectedTemplate(updatedTemplate); - }, 300); // 300ms 的防抖延迟 - // 使用上传文件hook const { uploadFile, isUploading } = useUploadFile(); // 本地加载状态,用于 UI 反馈 @@ -657,22 +641,22 @@ export const PcTemplateModal = ({
{/** 自由输入文字 */} - {(selectedTemplate?.freeInputItem) && ( + {(selectedTemplate?.freeInputItem) && selectedTemplate.freeInputItem.length > 0 && (
{ // 更新自由输入文字字段 const updatedTemplate = { ...selectedTemplate!, - freeInputItem: { - ...selectedTemplate!.freeInputItem, + freeInputItem: selectedTemplate!.freeInputItem.map((item) => ({ + ...item, free_input_text: e.target.value - } - }; + })), + } setSelectedTemplate(updatedTemplate as StoryTemplateEntity); }} /> From 2e9864625932198cdb62485bcb13e24e6c4e9e4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8C=97=E6=9E=B3?= <7854742+wang_rumeng@user.noreply.gitee.com> Date: Tue, 16 Sep 2025 19:38:02 +0800 Subject: [PATCH 02/21] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=B1=9E=E6=80=A7?= =?UTF-8?q?=E5=90=8DfreeInput?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/service/Interaction/templateStoryService.ts | 8 ++++---- app/service/domain/Entities.ts | 2 +- components/ChatInputBox/H5TemplateDrawer.tsx | 8 ++++---- components/ChatInputBox/PcTemplateModal.tsx | 8 ++++---- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/app/service/Interaction/templateStoryService.ts b/app/service/Interaction/templateStoryService.ts index c42764d..ffdc61a 100644 --- a/app/service/Interaction/templateStoryService.ts +++ b/app/service/Interaction/templateStoryService.ts @@ -70,7 +70,7 @@ export const useTemplateStoryServiceHook = (): UseTemplateStoryService => { const templates = await templateStoryUseCase.getTemplateStoryList(); // templates.forEach(template => { // if (template.id === 'f944abad-f42b-4899-b54a-a6beb9d27805') { - // template.freeInputItem = { + // template.freeInput = { // user_tips: "How is coffee made?", // constraints: "", // free_input_text: "" @@ -78,7 +78,7 @@ export const useTemplateStoryServiceHook = (): UseTemplateStoryService => { // // template.storyRole = []; // } // if (template.id === 'e7438cd8-a23d-4974-8cde-13b5671b410c') { - // // template.freeInputItem = { + // // template.freeInput = { // // user_tips: "Input an English word you wanna learn", // // constraints: "", // // free_input_text: "" @@ -258,7 +258,7 @@ export const useTemplateStoryServiceHook = (): UseTemplateStoryService => { setIsLoading(true); // 没有角色以及道具 时,需要设置为true const one_query_mode = selectedTemplate?.storyRole?.length === 0 && selectedTemplate?.storyItem?.length === 0; - const script = selectedTemplate?.freeInputItem && selectedTemplate.freeInputItem.length > 0 ? selectedTemplate.freeInputItem[0].free_input_text : selectedTemplate?.generateText || ""; + const script = selectedTemplate?.freeInput && selectedTemplate.freeInput.length > 0 ? selectedTemplate.freeInput[0].free_input_text : selectedTemplate?.generateText || ""; const params: CreateMovieProjectV3Request = { script: script, @@ -268,7 +268,7 @@ export const useTemplateStoryServiceHook = (): UseTemplateStoryService => { resolution, storyRole: selectedTemplate?.storyRole || [], storyItem: selectedTemplate?.storyItem || [], - freeInput: selectedTemplate?.freeInputItem || [], + freeInput: selectedTemplate?.freeInput || [], language, template_id: selectedTemplate?.template_id || "", one_query_mode: one_query_mode diff --git a/app/service/domain/Entities.ts b/app/service/domain/Entities.ts index bd39596..f1f70eb 100644 --- a/app/service/domain/Entities.ts +++ b/app/service/domain/Entities.ts @@ -173,7 +173,7 @@ export interface StoryTemplateEntity { photo_url: string; }[]; /** 自由输入文字 */ - freeInputItem: { + freeInput: { /** 用户提示,提示给用户需要输入什么内容 */ user_tips: string; /** 约束,可选,用于传给ai,让ai去拦截用户不符合约束的输入内容 */ diff --git a/components/ChatInputBox/H5TemplateDrawer.tsx b/components/ChatInputBox/H5TemplateDrawer.tsx index a0ca6c4..dab09b5 100644 --- a/components/ChatInputBox/H5TemplateDrawer.tsx +++ b/components/ChatInputBox/H5TemplateDrawer.tsx @@ -491,17 +491,17 @@ export const H5TemplateDrawer = ({
- {selectedTemplate?.freeInputItem && selectedTemplate.freeInputItem.length > 0 && ( + {selectedTemplate?.freeInput && selectedTemplate.freeInput.length > 0 && (
{ const updatedTemplate = { ...selectedTemplate!, - freeInputItem: selectedTemplate!.freeInputItem.map((item) => ({ + freeInput: selectedTemplate!.freeInput.map((item) => ({ ...item, free_input_text: e.target.value, })), diff --git a/components/ChatInputBox/PcTemplateModal.tsx b/components/ChatInputBox/PcTemplateModal.tsx index 0a70507..52265b5 100644 --- a/components/ChatInputBox/PcTemplateModal.tsx +++ b/components/ChatInputBox/PcTemplateModal.tsx @@ -641,18 +641,18 @@ export const PcTemplateModal = ({
{/** 自由输入文字 */} - {(selectedTemplate?.freeInputItem) && selectedTemplate.freeInputItem.length > 0 && ( + {(selectedTemplate?.freeInput) && selectedTemplate.freeInput.length > 0 && (
{ // 更新自由输入文字字段 const updatedTemplate = { ...selectedTemplate!, - freeInputItem: selectedTemplate!.freeInputItem.map((item) => ({ + freeInput: selectedTemplate!.freeInput.map((item) => ({ ...item, free_input_text: e.target.value })), From 8b697c4152496cae6a75983290c02a997fc19078 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8C=97=E6=9E=B3?= <7854742+wang_rumeng@user.noreply.gitee.com> Date: Tue, 16 Sep 2025 20:07:08 +0800 Subject: [PATCH 03/21] =?UTF-8?q?=E6=A8=A1=E7=89=88=E8=87=AA=E7=94=B1?= =?UTF-8?q?=E8=BE=93=E5=85=A5=E6=A1=86=E5=B8=83=E5=B1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/ChatInputBox/H5TemplateDrawer.tsx | 42 +++++++++++++++++- components/ChatInputBox/PcTemplateModal.tsx | 45 +++++++++++++++++++- 2 files changed, 85 insertions(+), 2 deletions(-) diff --git a/components/ChatInputBox/H5TemplateDrawer.tsx b/components/ChatInputBox/H5TemplateDrawer.tsx index dab09b5..b51b3a4 100644 --- a/components/ChatInputBox/H5TemplateDrawer.tsx +++ b/components/ChatInputBox/H5TemplateDrawer.tsx @@ -71,6 +71,19 @@ export const H5TemplateDrawer = ({ const [inputVisible, setInputVisible] = useState<{ [key: string]: boolean }>({}); const [isBottomExpanded, setIsBottomExpanded] = useState(true); const [isDescExpanded, setIsDescExpanded] = useState(false); + // 自由输入框布局 + const [freeInputLayout, setFreeInputLayout] = useState('bottom'); + + // 自由输入框布局 + useEffect(() => { + if (selectedTemplate?.storyRole && selectedTemplate.storyRole.length > 0 || + selectedTemplate?.storyItem && selectedTemplate.storyItem.length > 0 + ) { + setFreeInputLayout('bottom'); + } else { + setFreeInputLayout('top'); + } + }, [selectedTemplate]) useEffect(() => { if (isOpen) { @@ -488,10 +501,37 @@ export const H5TemplateDrawer = ({ {renderRoles()} {renderItems()} + {/** 自由输入文字 */} + {freeInputLayout === 'top' && selectedTemplate?.freeInput && selectedTemplate.freeInput.length > 0 && ( +
+

+ input Configuration +

+