This commit is contained in:
海龙 2025-08-12 20:08:26 +08:00
commit b6bb65eddb
4 changed files with 39 additions and 21 deletions

View File

@ -14,9 +14,10 @@ interface ScriptRendererProps {
isPauseWorkFlow: boolean; isPauseWorkFlow: boolean;
applyScript: any; applyScript: any;
mode: string; mode: string;
from: string;
} }
export const ScriptRenderer: React.FC<ScriptRendererProps> = ({ data, setIsPauseWorkFlow, setAnyAttribute, isPauseWorkFlow, applyScript, mode }) => { export const ScriptRenderer: React.FC<ScriptRendererProps> = ({ data, setIsPauseWorkFlow, setAnyAttribute, isPauseWorkFlow, applyScript, mode, from }) => {
const [activeBlockId, setActiveBlockId] = useState<string | null>(null); const [activeBlockId, setActiveBlockId] = useState<string | null>(null);
const [hoveredBlockId, setHoveredBlockId] = useState<string | null>(null); const [hoveredBlockId, setHoveredBlockId] = useState<string | null>(null);
const contentRefs = useRef<{ [key: string]: HTMLDivElement | null }>({}); const contentRefs = useRef<{ [key: string]: HTMLDivElement | null }>({});
@ -72,7 +73,7 @@ export const ScriptRenderer: React.FC<ScriptRendererProps> = ({ data, setIsPause
default: default:
return <p className="mb-2"> return <p className="mb-2">
{ {
isInit ? ( (isInit && from !== 'tab') ? (
<TypewriterText text={content.text || ''} stableId={content.type} /> <TypewriterText text={content.text || ''} stableId={content.type} />
) : ( ) : (
<span>{content.text}</span> <span>{content.text}</span>

View File

@ -142,12 +142,6 @@ export function CharacterTabContent({
setIgnoreReplace(true); setIgnoreReplace(true);
}; };
const handleReplaceCharacter = (url: string) => {
setEnableAnimation(true);
// 替换角色
setIsReplacePanelOpen(true);
};
// President Alfred King Samuel Ryan // President Alfred King Samuel Ryan
const handleConfirmReplace = (selectedShots: string[], addToLibrary: boolean) => { const handleConfirmReplace = (selectedShots: string[], addToLibrary: boolean) => {
// 处理替换确认逻辑 // 处理替换确认逻辑
@ -192,7 +186,7 @@ export function CharacterTabContent({
// 使用真实的角色数据 // 使用真实的角色数据
const selectedRole = userRoleLibrary[index]; const selectedRole = userRoleLibrary[index];
if (selectedRole) { if (selectedRole) {
handleReplaceCharacter(selectedRole.imageUrl); handleStartReplaceCharacter();
} }
}; };

View File

@ -43,6 +43,7 @@ export function ScriptTabContent({
isPauseWorkFlow={isPauseWorkFlow} isPauseWorkFlow={isPauseWorkFlow}
applyScript={applyScript} applyScript={applyScript}
mode='manual' mode='manual'
from='tab'
/> />
</motion.div> </motion.div>
</div> </div>

View File

@ -27,17 +27,24 @@ export function ShotTabContent({
shotData, shotData,
setSelectedSegment, setSelectedSegment,
regenerateVideoSegment, regenerateVideoSegment,
filterRole filterRole,
fetchUserRoleLibrary,
userRoleLibrary,
fetchRoleShots,
shotSelectionList,
applyRoleToSelectedShots
} = useEditData('shot'); } = useEditData('shot');
const [selectedIndex, setSelectedIndex] = useState(currentSketchIndex); const [selectedIndex, setSelectedIndex] = useState(currentSketchIndex);
const [detections, setDetections] = useState<PersonDetection[]>([]); const [detections, setDetections] = useState<PersonDetection[]>([]);
const [scanState, setScanState] = useState<'idle' | 'scanning' | 'detected'>('idle'); const [scanState, setScanState] = useState<'idle' | 'scanning' | 'detected'>('idle');
const [isScanFailed, setIsScanFailed] = useState(false); const [isScanFailed, setIsScanFailed] = useState(false);
const [isLoadingLibrary, setIsLoadingLibrary] = useState(false);
const [isReplaceLibraryOpen, setIsReplaceLibraryOpen] = useState(false); const [isReplaceLibraryOpen, setIsReplaceLibraryOpen] = useState(false);
const [isReplacePanelOpen, setIsReplacePanelOpen] = useState(false); const [isReplacePanelOpen, setIsReplacePanelOpen] = useState(false);
const [selectedCharacter, setSelectedCharacter] = useState<any>(null);
const [selectedLibaryRole, setSelectedLibaryRole] = useState<any>(null);
const [isLoadingShots, setIsLoadingShots] = useState(false);
const shotsEditorRef = useRef<any>(null); const shotsEditorRef = useRef<any>(null);
const videoRef = useRef<HTMLVideoElement>(null); const videoRef = useRef<HTMLVideoElement>(null);
@ -91,24 +98,36 @@ export function ShotTabContent({
}; };
// 处理人物点击 打开角色库 // 处理人物点击 打开角色库
const handlePersonClick = (person: PersonDetection) => { const handlePersonClick = async (person: PersonDetection) => {
console.log('person', person); console.log('person', person);
setSelectedCharacter(person);
setIsLoadingLibrary(true);
setIsReplaceLibraryOpen(true); setIsReplaceLibraryOpen(true);
await fetchUserRoleLibrary();
setIsLoadingLibrary(false);
}; };
// 从角色库中选择角色 // 从角色库中选择角色
const handleSelectCharacter = (index: number) => { const handleSelectCharacter = (index: number) => {
console.log('index', index); console.log('index', index);
setSelectedLibaryRole(userRoleLibrary[index]);
setIsReplaceLibraryOpen(false); setIsReplaceLibraryOpen(false);
// 模拟打开替换面板 handleStartReplaceCharacter();
setTimeout(() => { };
setIsReplacePanelOpen(true);
}, 1000); const handleStartReplaceCharacter = async () => {
setIsLoadingShots(true);
setIsReplacePanelOpen(true);
// 获取当前角色对应的视频片段
await fetchRoleShots(selectedCharacter?.name || '');
// 打开替换角色面板
setIsLoadingShots(false);
}; };
// 确认替换角色 // 确认替换角色
const handleConfirmReplace = (selectedShots: string[], addToLibrary: boolean) => { const handleConfirmReplace = () => {
applyRoleToSelectedShots(selectedLibaryRole);
setIsReplacePanelOpen(false);
}; };
// 点击按钮重新生成 // 点击按钮重新生成
@ -373,8 +392,9 @@ export function ShotTabContent({
onClose={() => setIsReplacePanelOpen(false)} onClose={() => setIsReplacePanelOpen(false)}
> >
<ReplaceCharacterPanel <ReplaceCharacterPanel
shots={mockShots} isLoading={isLoadingShots}
character={mockCharacter} shots={shotSelectionList}
role={selectedLibaryRole}
showAddToLibrary={false} showAddToLibrary={false}
onClose={() => setIsReplacePanelOpen(false)} onClose={() => setIsReplacePanelOpen(false)}
onConfirm={handleConfirmReplace} onConfirm={handleConfirmReplace}
@ -382,6 +402,8 @@ export function ShotTabContent({
</FloatingGlassPanel> </FloatingGlassPanel>
<CharacterLibrarySelector <CharacterLibrarySelector
isLoading={isLoadingLibrary}
userRoleLibrary={userRoleLibrary}
isReplaceLibraryOpen={isReplaceLibraryOpen} isReplaceLibraryOpen={isReplaceLibraryOpen}
setIsReplaceLibraryOpen={setIsReplaceLibraryOpen} setIsReplaceLibraryOpen={setIsReplaceLibraryOpen}
onSelect={handleSelectCharacter} onSelect={handleSelectCharacter}