This commit is contained in:
北枳 2025-09-16 19:19:54 +08:00
parent e506d739e9
commit f0fbb10fd6
5 changed files with 57 additions and 53 deletions

View File

@ -210,6 +210,19 @@ export interface CreateMovieProjectV3Request {
language: string; language: string;
/**模板id */ /**模板id */
template_id: string; template_id: string;
/** 单次查询模式 */
one_query_mode: boolean;
/** 自由输入 */
freeInput?: {
/** 用户提示,提示给用户需要输入什么内容 */
user_tips: string;
/** 约束,可选,用于传给ai让ai去拦截用户不符合约束的输入内容 */
constraints: string;
/** 自由输入文字 */
free_input_text: string;
/** 输入名称 */
input_name: string;
}[];
/** 故事角色 */ /** 故事角色 */
storyRole: { storyRole: {
/** 角色名 */ /** 角色名 */

View File

@ -68,27 +68,27 @@ export const useTemplateStoryServiceHook = (): UseTemplateStoryService => {
setIsLoading(true); setIsLoading(true);
const templates = await templateStoryUseCase.getTemplateStoryList(); const templates = await templateStoryUseCase.getTemplateStoryList();
templates.forEach(template => { // templates.forEach(template => {
if (template.id === 'f944abad-f42b-4899-b54a-a6beb9d27805') { // if (template.id === 'f944abad-f42b-4899-b54a-a6beb9d27805') {
template.freeInputItem = { // template.freeInputItem = {
user_tips: "How is coffee made?", // user_tips: "How is coffee made?",
constraints: "", // constraints: "",
free_input_text: "" // free_input_text: ""
}; // };
// template.storyRole = []; // // template.storyRole = [];
} // }
if (template.id === 'e7438cd8-a23d-4974-8cde-13b5671b410c') { // if (template.id === 'e7438cd8-a23d-4974-8cde-13b5671b410c') {
// template.freeInputItem = { // // template.freeInputItem = {
// user_tips: "Input an English word you wanna learn", // // user_tips: "Input an English word you wanna learn",
// constraints: "", // // constraints: "",
// free_input_text: "" // // free_input_text: ""
// }; // // };
template.storyItem = [{ // template.storyItem = [{
...template.storyItem[0], // ...template.storyItem[0],
item_name: "Choose an English word you wanna learn" // item_name: "Choose an English word you wanna learn"
}]; // }];
} // }
}); // });
setTemplateStoryList(templates); setTemplateStoryList(templates);
setSelectedTemplate(templates[0]); setSelectedTemplate(templates[0]);
@ -256,17 +256,22 @@ export const useTemplateStoryServiceHook = (): UseTemplateStoryService => {
try { try {
// 设置 loading 状态 // 设置 loading 状态
setIsLoading(true); 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 = { const params: CreateMovieProjectV3Request = {
script: selectedTemplate?.freeInputItem?.free_input_text || selectedTemplate?.generateText || "", script: script,
category: selectedTemplate?.category || "", category: selectedTemplate?.category || "",
user_id, user_id,
mode, mode,
resolution, resolution,
storyRole: selectedTemplate?.storyRole || [], storyRole: selectedTemplate?.storyRole || [],
storyItem: selectedTemplate?.storyItem || [], storyItem: selectedTemplate?.storyItem || [],
freeInput: selectedTemplate?.freeInputItem || [],
language, language,
template_id: selectedTemplate?.template_id || "", template_id: selectedTemplate?.template_id || "",
one_query_mode: one_query_mode
}; };
console.log("params", params); console.log("params", params);
const result = await MovieProjectService.createProject( const result = await MovieProjectService.createProject(

View File

@ -173,12 +173,14 @@ export interface StoryTemplateEntity {
photo_url: string; photo_url: string;
}[]; }[];
/** 自由输入文字 */ /** 自由输入文字 */
freeInputItem?: { freeInputItem: {
/** 用户提示,提示给用户需要输入什么内容 */ /** 用户提示,提示给用户需要输入什么内容 */
user_tips: string; user_tips: string;
/** 约束,可选,用于传给ai让ai去拦截用户不符合约束的输入内容 */ /** 约束,可选,用于传给ai让ai去拦截用户不符合约束的输入内容 */
constraints: string; constraints: string;
/** 自由输入文字 */ /** 自由输入文字 */
free_input_text: string; free_input_text: string;
} /** 输入名称 */
input_name: string;
}[];
} }

View File

@ -491,20 +491,20 @@ export const H5TemplateDrawer = ({
<div className="w-full flex items-center justify-end gap-2"> <div className="w-full flex items-center justify-end gap-2">
{selectedTemplate?.freeInputItem && ( {selectedTemplate?.freeInputItem && selectedTemplate.freeInputItem.length > 0 && (
<div data-alt="free-input" className="flex-1"> <div data-alt="free-input" className="flex-1">
<input <input
type="text" type="text"
value={selectedTemplate.freeInputItem.free_input_text || ""} value={selectedTemplate.freeInputItem[0].free_input_text || ""}
placeholder={selectedTemplate.freeInputItem.user_tips} placeholder={selectedTemplate.freeInputItem[0].user_tips}
className="w-full px-3 py-2 pr-12 bg-white/0 border border-white/10 rounded-lg text-white placeholder-gray-400 focus:outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500/30 transition-all duration-200 text-sm" className="w-full px-3 py-2 pr-12 bg-white/0 border border-white/10 rounded-lg text-white placeholder-gray-400 focus:outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500/30 transition-all duration-200 text-sm"
onChange={(e) => { onChange={(e) => {
const updatedTemplate = { const updatedTemplate = {
...selectedTemplate!, ...selectedTemplate!,
freeInputItem: { freeInputItem: selectedTemplate!.freeInputItem.map((item) => ({
...selectedTemplate!.freeInputItem, ...item,
free_input_text: e.target.value, free_input_text: e.target.value,
}, })),
} as StoryTemplateEntity; } as StoryTemplateEntity;
setSelectedTemplate(updatedTemplate); setSelectedTemplate(updatedTemplate);
}} }}

View File

@ -91,22 +91,6 @@ export const PcTemplateModal = ({
clearData, clearData,
} = useTemplateStoryServiceHook(); } = 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 // 使用上传文件hook
const { uploadFile, isUploading } = useUploadFile(); const { uploadFile, isUploading } = useUploadFile();
// 本地加载状态,用于 UI 反馈 // 本地加载状态,用于 UI 反馈
@ -657,22 +641,22 @@ export const PcTemplateModal = ({
<div className=" absolute -bottom-8 right-0 w-full flex items-center justify-end gap-2"> <div className=" absolute -bottom-8 right-0 w-full flex items-center justify-end gap-2">
{/** 自由输入文字 */} {/** 自由输入文字 */}
{(selectedTemplate?.freeInputItem) && ( {(selectedTemplate?.freeInputItem) && selectedTemplate.freeInputItem.length > 0 && (
<div className="py-2 flex-1"> <div className="py-2 flex-1">
<input <input
type="text" type="text"
value={selectedTemplate?.freeInputItem?.free_input_text || ""} value={selectedTemplate?.freeInputItem[0].free_input_text || ""}
placeholder={selectedTemplate?.freeInputItem.user_tips} placeholder={selectedTemplate?.freeInputItem[0].user_tips}
className="w-full px-3 py-2 pr-16 bg-white/0 border border-white/10 rounded-lg text-white placeholder-gray-400 focus:outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500/30 transition-all duration-200 text-sm" className="w-full px-3 py-2 pr-16 bg-white/0 border border-white/10 rounded-lg text-white placeholder-gray-400 focus:outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500/30 transition-all duration-200 text-sm"
onChange={(e) => { onChange={(e) => {
// 更新自由输入文字字段 // 更新自由输入文字字段
const updatedTemplate = { const updatedTemplate = {
...selectedTemplate!, ...selectedTemplate!,
freeInputItem: { freeInputItem: selectedTemplate!.freeInputItem.map((item) => ({
...selectedTemplate!.freeInputItem, ...item,
free_input_text: e.target.value free_input_text: e.target.value
} })),
}; }
setSelectedTemplate(updatedTemplate as StoryTemplateEntity); setSelectedTemplate(updatedTemplate as StoryTemplateEntity);
}} }}
/> />