From c741169b351b066738d86e080d11c488ac85d38c 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, 12 Aug 2025 19:08:02 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=A7=92=E8=89=B2?= =?UTF-8?q?=E5=BA=93=E5=8A=A0=E8=BD=BD=E7=8A=B6=E6=80=81=E7=AE=A1=E7=90=86?= =?UTF-8?q?=EF=BC=8C=E4=BC=98=E5=8C=96=E8=A7=92=E8=89=B2=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E5=92=8C=E6=9B=BF=E6=8D=A2=E9=80=BB=E8=BE=91=E3=80=82=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E8=A7=92=E8=89=B2=E5=BA=93=E9=80=89=E6=8B=A9=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E4=BB=A5=E6=94=AF=E6=8C=81=E5=8A=A0=E8=BD=BD=E7=8A=B6?= =?UTF-8?q?=E6=80=81=EF=BC=8C=E8=B0=83=E6=95=B4=E8=A7=92=E8=89=B2=E6=9B=BF?= =?UTF-8?q?=E6=8D=A2=E9=9D=A2=E6=9D=BF=E4=BB=A5=E7=A1=AE=E4=BF=9D=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E4=BD=93=E9=AA=8C=E6=B5=81=E7=95=85=E3=80=82=E5=90=8C?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E4=BF=AE=E5=A4=8D=E8=A7=92=E8=89=B2=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E6=97=B6=E7=9A=84=E7=8A=B6=E6=80=81=E7=AE=A1=E7=90=86?= =?UTF-8?q?=EF=BC=8C=E5=A2=9E=E5=BC=BA=E5=8A=9F=E8=83=BD=E7=9A=84=E5=AE=8C?= =?UTF-8?q?=E6=95=B4=E6=80=A7=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/ui/shot-tab-content.tsx | 46 ++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/components/ui/shot-tab-content.tsx b/components/ui/shot-tab-content.tsx index 56f1358..52e419d 100644 --- a/components/ui/shot-tab-content.tsx +++ b/components/ui/shot-tab-content.tsx @@ -27,17 +27,24 @@ export function ShotTabContent({ shotData, setSelectedSegment, regenerateVideoSegment, - filterRole + filterRole, + fetchUserRoleLibrary, + userRoleLibrary, + fetchRoleShots, + shotSelectionList, + applyRoleToSelectedShots } = useEditData('shot'); const [selectedIndex, setSelectedIndex] = useState(currentSketchIndex); const [detections, setDetections] = useState([]); const [scanState, setScanState] = useState<'idle' | 'scanning' | 'detected'>('idle'); const [isScanFailed, setIsScanFailed] = useState(false); - + const [isLoadingLibrary, setIsLoadingLibrary] = useState(false); const [isReplaceLibraryOpen, setIsReplaceLibraryOpen] = useState(false); const [isReplacePanelOpen, setIsReplacePanelOpen] = useState(false); - + const [selectedCharacter, setSelectedCharacter] = useState(null); + const [selectedLibaryRole, setSelectedLibaryRole] = useState(null); + const [isLoadingShots, setIsLoadingShots] = useState(false); const shotsEditorRef = useRef(null); const videoRef = useRef(null); @@ -91,24 +98,36 @@ export function ShotTabContent({ }; // 处理人物点击 打开角色库 - const handlePersonClick = (person: PersonDetection) => { + const handlePersonClick = async (person: PersonDetection) => { console.log('person', person); + setSelectedCharacter(person); + setIsLoadingLibrary(true); setIsReplaceLibraryOpen(true); + await fetchUserRoleLibrary(); + setIsLoadingLibrary(false); }; // 从角色库中选择角色 const handleSelectCharacter = (index: number) => { console.log('index', index); + setSelectedLibaryRole(userRoleLibrary[index]); setIsReplaceLibraryOpen(false); - // 模拟打开替换面板 - setTimeout(() => { - setIsReplacePanelOpen(true); - }, 1000); + handleStartReplaceCharacter(); + }; + + 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)} > setIsReplacePanelOpen(false)} onConfirm={handleConfirmReplace} @@ -382,6 +402,8 @@ export function ShotTabContent({ Date: Tue, 12 Aug 2025 19:18:04 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=9B=B4=E6=96=B0ScriptRenderer=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=EF=BC=8C=E6=96=B0=E5=A2=9Efrom=E5=B1=9E=E6=80=A7?= =?UTF-8?q?=E4=BB=A5=E6=94=AF=E6=8C=81=E4=B8=8D=E5=90=8C=E6=9D=A5=E6=BA=90?= =?UTF-8?q?=E7=9A=84=E6=B8=B2=E6=9F=93=E9=80=BB=E8=BE=91=E3=80=82=E5=90=8C?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E5=9C=A8ScriptTabContent=E4=B8=AD=E8=AE=BE?= =?UTF-8?q?=E7=BD=AEfrom=E5=B1=9E=E6=80=A7=E4=B8=BA'tab'=EF=BC=8C=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E7=BB=84=E4=BB=B6=E9=97=B4=E7=9A=84=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E4=BC=A0=E9=80=92=E5=92=8C=E6=B8=B2=E6=9F=93=E6=9D=A1=E4=BB=B6?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/script-renderer/ScriptRenderer.tsx | 5 +++-- components/ui/script-tab-content.tsx | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/components/script-renderer/ScriptRenderer.tsx b/components/script-renderer/ScriptRenderer.tsx index 3ae72ad..b4d63df 100644 --- a/components/script-renderer/ScriptRenderer.tsx +++ b/components/script-renderer/ScriptRenderer.tsx @@ -14,9 +14,10 @@ interface ScriptRendererProps { isPauseWorkFlow: boolean; applyScript: any; mode: string; + from: string; } -export const ScriptRenderer: React.FC = ({ data, setIsPauseWorkFlow, setAnyAttribute, isPauseWorkFlow, applyScript, mode }) => { +export const ScriptRenderer: React.FC = ({ data, setIsPauseWorkFlow, setAnyAttribute, isPauseWorkFlow, applyScript, mode, from }) => { const [activeBlockId, setActiveBlockId] = useState(null); const [hoveredBlockId, setHoveredBlockId] = useState(null); const contentRefs = useRef<{ [key: string]: HTMLDivElement | null }>({}); @@ -72,7 +73,7 @@ export const ScriptRenderer: React.FC = ({ data, setIsPause default: return

{ - isInit ? ( + (isInit && from !== 'tab') ? ( ) : ( {content.text} diff --git a/components/ui/script-tab-content.tsx b/components/ui/script-tab-content.tsx index 887c4c8..1cb1e71 100644 --- a/components/ui/script-tab-content.tsx +++ b/components/ui/script-tab-content.tsx @@ -43,6 +43,7 @@ export function ScriptTabContent({ isPauseWorkFlow={isPauseWorkFlow} applyScript={applyScript} mode='manual' + from='tab' /> From 1de2eb3dd1e66f54fe126b818624b72bbd53d21e 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, 12 Aug 2025 19:20:38 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E8=A7=92=E8=89=B2?= =?UTF-8?q?=E6=9B=BF=E6=8D=A2=E5=A4=84=E7=90=86=E5=87=BD=E6=95=B0handleRep?= =?UTF-8?q?laceCharacter=EF=BC=8C=E6=94=B9=E4=B8=BA=E8=B0=83=E7=94=A8handl?= =?UTF-8?q?eStartReplaceCharacter=E4=BB=A5=E7=AE=80=E5=8C=96=E8=A7=92?= =?UTF-8?q?=E8=89=B2=E6=9B=BF=E6=8D=A2=E9=80=BB=E8=BE=91=EF=BC=8C=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E4=BB=A3=E7=A0=81=E7=BB=93=E6=9E=84=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/ui/character-tab-content.tsx | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/components/ui/character-tab-content.tsx b/components/ui/character-tab-content.tsx index e4055f3..ea1d9aa 100644 --- a/components/ui/character-tab-content.tsx +++ b/components/ui/character-tab-content.tsx @@ -142,12 +142,6 @@ export function CharacterTabContent({ setIgnoreReplace(true); }; - const handleReplaceCharacter = (url: string) => { - setEnableAnimation(true); - // 替换角色 - - setIsReplacePanelOpen(true); - }; // President Alfred King Samuel Ryan const handleConfirmReplace = (selectedShots: string[], addToLibrary: boolean) => { // 处理替换确认逻辑 @@ -192,7 +186,7 @@ export function CharacterTabContent({ // 使用真实的角色数据 const selectedRole = userRoleLibrary[index]; if (selectedRole) { - handleReplaceCharacter(selectedRole.imageUrl); + handleStartReplaceCharacter(); } };