forked from 77media/video-flow
模版
This commit is contained in:
parent
e506d739e9
commit
f0fbb10fd6
@ -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: {
|
||||
/** 角色名 */
|
||||
|
||||
@ -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') {
|
||||
// templates.forEach(template => {
|
||||
// if (template.id === 'f944abad-f42b-4899-b54a-a6beb9d27805') {
|
||||
// template.freeInputItem = {
|
||||
// user_tips: "Input an English word you wanna learn",
|
||||
// user_tips: "How is coffee made?",
|
||||
// constraints: "",
|
||||
// free_input_text: ""
|
||||
// };
|
||||
template.storyItem = [{
|
||||
...template.storyItem[0],
|
||||
item_name: "Choose an English word you wanna learn"
|
||||
}];
|
||||
}
|
||||
});
|
||||
// // 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(
|
||||
|
||||
@ -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;
|
||||
}[];
|
||||
}
|
||||
|
||||
@ -491,20 +491,20 @@ export const H5TemplateDrawer = ({
|
||||
|
||||
|
||||
<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">
|
||||
<input
|
||||
type="text"
|
||||
value={selectedTemplate.freeInputItem.free_input_text || ""}
|
||||
placeholder={selectedTemplate.freeInputItem.user_tips}
|
||||
value={selectedTemplate.freeInputItem[0].free_input_text || ""}
|
||||
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"
|
||||
onChange={(e) => {
|
||||
const updatedTemplate = {
|
||||
...selectedTemplate!,
|
||||
freeInputItem: {
|
||||
...selectedTemplate!.freeInputItem,
|
||||
freeInputItem: selectedTemplate!.freeInputItem.map((item) => ({
|
||||
...item,
|
||||
free_input_text: e.target.value,
|
||||
},
|
||||
})),
|
||||
} as StoryTemplateEntity;
|
||||
setSelectedTemplate(updatedTemplate);
|
||||
}}
|
||||
|
||||
@ -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 = ({
|
||||
|
||||
<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">
|
||||
<input
|
||||
type="text"
|
||||
value={selectedTemplate?.freeInputItem?.free_input_text || ""}
|
||||
placeholder={selectedTemplate?.freeInputItem.user_tips}
|
||||
value={selectedTemplate?.freeInputItem[0].free_input_text || ""}
|
||||
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"
|
||||
onChange={(e) => {
|
||||
// 更新自由输入文字字段
|
||||
const updatedTemplate = {
|
||||
...selectedTemplate!,
|
||||
freeInputItem: {
|
||||
...selectedTemplate!.freeInputItem,
|
||||
freeInputItem: selectedTemplate!.freeInputItem.map((item) => ({
|
||||
...item,
|
||||
free_input_text: e.target.value
|
||||
})),
|
||||
}
|
||||
};
|
||||
setSelectedTemplate(updatedTemplate as StoryTemplateEntity);
|
||||
}}
|
||||
/>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user