forked from 77media/video-flow
更新剧集处理
This commit is contained in:
parent
f2ba3fa628
commit
724bbc6c8f
@ -1,5 +1,5 @@
|
||||
// import { redirect } from 'next/navigation';
|
||||
import { CreateToVideo2 } from '@/components/pages/create-to-video';
|
||||
import { CreateToVideo2 } from '@/components/pages/create-to-video2';
|
||||
|
||||
export default function CreatePage() {
|
||||
// redirect('/create/video-to-video');
|
||||
|
||||
@ -66,7 +66,7 @@ export function CreateToVideo2() {
|
||||
const [isFocus, setIsFocus] = useState(false);
|
||||
const [selectedMode, setSelectedMode] = useState<ModeEnum>(ModeEnum.AUTOMATIC);
|
||||
const [selectedResolution, setSelectedResolution] = useState<ResolutionEnum>(ResolutionEnum.HD_720P);
|
||||
const [inputText, setInputText] = useState('');
|
||||
const [script, setInputText] = useState('');
|
||||
const editorRef = useRef<HTMLDivElement>(null);
|
||||
const [runTour, setRunTour] = useState(true);
|
||||
|
||||
@ -103,18 +103,18 @@ export function CreateToVideo2() {
|
||||
}
|
||||
|
||||
const handleCreateVideo = async () => {
|
||||
if (videoUrl || inputText) {
|
||||
if (videoUrl || script) {
|
||||
try {
|
||||
let convertResponse;
|
||||
|
||||
// 根据选中的选项卡调用相应的API
|
||||
if (activeTab === 'script') {
|
||||
// 剧本模式:调用convertScriptToScene (第43-56行)
|
||||
if (!inputText.trim()) {
|
||||
if (!script.trim()) {
|
||||
alert('请输入剧本内容');
|
||||
return;
|
||||
}
|
||||
convertResponse = await convertScriptToScene(inputText);
|
||||
convertResponse = await convertScriptToScene(script);
|
||||
} else {
|
||||
// 视频模式:调用convertVideoToScene (第56-69行)
|
||||
if (!videoUrl) {
|
||||
@ -147,6 +147,10 @@ export function CreateToVideo2() {
|
||||
|
||||
// 创建剧集数据
|
||||
const episodeData: CreateScriptEpisodeRequest = {
|
||||
title: "episode 1",
|
||||
script_id: projectId,
|
||||
status: 1,
|
||||
summary: script
|
||||
};
|
||||
|
||||
// 调用创建剧集API
|
||||
@ -272,7 +276,7 @@ export function CreateToVideo2() {
|
||||
// 处理编辑器聚焦
|
||||
const handleEditorFocus = () => {
|
||||
setIsFocus(true);
|
||||
if (editorRef.current && inputText) {
|
||||
if (editorRef.current && script) {
|
||||
// 创建范围对象
|
||||
const range = document.createRange();
|
||||
const selection = window.getSelection();
|
||||
@ -280,11 +284,11 @@ export function CreateToVideo2() {
|
||||
// 获取编辑器内的文本节点
|
||||
const textNode = Array.from(editorRef.current.childNodes).find(
|
||||
node => node.nodeType === Node.TEXT_NODE
|
||||
) || editorRef.current.appendChild(document.createTextNode(inputText));
|
||||
) || editorRef.current.appendChild(document.createTextNode(script));
|
||||
|
||||
// 设置范围到文本末尾
|
||||
range.setStart(textNode, inputText.length);
|
||||
range.setEnd(textNode, inputText.length);
|
||||
range.setStart(textNode, script.length);
|
||||
range.setEnd(textNode, script.length);
|
||||
|
||||
// 应用选择
|
||||
selection?.removeAllRanges();
|
||||
@ -294,8 +298,8 @@ export function CreateToVideo2() {
|
||||
|
||||
// 处理编辑器内容变化
|
||||
const handleEditorChange = (e: React.FormEvent<HTMLDivElement>) => {
|
||||
const newText = e.currentTarget.textContent || '';
|
||||
setInputText(newText);
|
||||
const script = e.currentTarget.textContent || '';
|
||||
setInputText(script);
|
||||
};
|
||||
|
||||
// 引导步骤
|
||||
@ -484,10 +488,10 @@ export function CreateToVideo2() {
|
||||
onInput={handleEditorChange}
|
||||
suppressContentEditableWarning
|
||||
>
|
||||
{inputText}
|
||||
{script}
|
||||
</div>
|
||||
<div
|
||||
className={`custom-placeholder absolute top-[50%] left-[10px] z-10 translate-y-[-50%] flex items-center gap-1 pointer-events-none text-[14px] leading-[26px] text-white/[0.40] ${inputText ? 'opacity-0' : 'opacity-100'}`}
|
||||
className={`custom-placeholder absolute top-[50%] left-[10px] z-10 translate-y-[-50%] flex items-center gap-1 pointer-events-none text-[14px] leading-[26px] text-white/[0.40] ${script ? 'opacity-0' : 'opacity-100'}`}
|
||||
>
|
||||
<span>Describe the content you want to create. Get an </span>
|
||||
<b
|
||||
@ -547,7 +551,7 @@ export function CreateToVideo2() {
|
||||
</div>
|
||||
</div>
|
||||
<div className='flex items-center gap-3'>
|
||||
<div className={`tool-submit-button ${videoUrl || inputText ? '' : 'disabled'}`} onClick={handleCreateVideo}>
|
||||
<div className={`tool-submit-button ${videoUrl || script ? '' : 'disabled'}`} onClick={handleCreateVideo}>
|
||||
<ArrowUp className='w-4 h-4' />Create
|
||||
</div>
|
||||
</div>
|
||||
@ -64,20 +64,6 @@ export function HomePage2() {
|
||||
if (projectResponse.code === 0 && projectResponse.data.id) {
|
||||
const projectId = projectResponse.data.id;
|
||||
setCreatedProjectId(projectId);
|
||||
|
||||
// 创建剧集数据
|
||||
const episodeData: CreateScriptEpisodeRequest = {
|
||||
};
|
||||
|
||||
// 调用创建剧集API
|
||||
const episodeResponse = await createScriptEpisode(episodeData);
|
||||
|
||||
if (episodeResponse.code === 0) {
|
||||
// 成功创建后跳转到create页面
|
||||
router.push("/create");
|
||||
} else {
|
||||
alert(`创建剧集失败: ${episodeResponse.message}`);
|
||||
}
|
||||
} else {
|
||||
alert(`创建项目失败: ${projectResponse.message}`);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user