From 7112de9ac1c48381b3e74c47162895e2bc1df7f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B5=B7=E9=BE=99?= Date: Tue, 12 Aug 2025 18:55:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=AE=BE=E7=BD=AE=E9=80=89?= =?UTF-8?q?=E4=B8=AD=E7=9A=84=E8=A7=92=E8=89=B2=E5=8A=9F=E8=83=BD=EF=BC=8C?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=A7=92=E8=89=B2=E9=80=89=E6=8B=A9=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E4=BB=A5=E6=94=AF=E6=8C=81=E6=9C=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E8=A7=92=E8=89=B2=E7=9A=84=E6=83=85=E5=86=B5=EF=BC=8C=E5=90=8C?= =?UTF-8?q?=E6=97=B6=E6=9B=B4=E6=96=B0=E8=A7=92=E8=89=B2=E8=A7=86=E9=A2=91?= =?UTF-8?q?=E7=89=87=E6=AE=B5=E6=9C=8D=E5=8A=A1=E5=92=8C=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=80=BB=E8=BE=91=EF=BC=8C=E7=A1=AE=E4=BF=9D?= =?UTF-8?q?=E8=A7=92=E8=89=B2=E5=BA=93=E4=BF=9D=E5=AD=98=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E7=9A=84=E5=AE=8C=E6=95=B4=E6=80=A7=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/service/Interaction/RoleShotService.ts | 7 +++++-- components/pages/work-flow/use-edit-data.tsx | 10 ++++++---- components/ui/character-tab-content.tsx | 6 +++++- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/app/service/Interaction/RoleShotService.ts b/app/service/Interaction/RoleShotService.ts index 0a54946..9954297 100644 --- a/app/service/Interaction/RoleShotService.ts +++ b/app/service/Interaction/RoleShotService.ts @@ -39,17 +39,19 @@ interface UseRoleShotService { applyRoleToSelectedShots: (newRole: RoleEntity) => Promise; /** 清空选择列表 */ clearShotSelection: () => void; + /** 设置选中的角色 */ + setSelectedRole: (role: RoleEntity) => void; } /** * 角色视频片段服务Hook * 提供角色与视频片段交互的所有响应式功能和业务逻辑 */ -export const useRoleShotServiceHook = (projectId: string,selectRole:RoleEntity): UseRoleShotService => { +export const useRoleShotServiceHook = (projectId: string,selectRole?:RoleEntity): UseRoleShotService => { // 响应式状态 const [shotSelectionList, setShotSelectionList] = useState([]); const [selectedRoleId, setSelectedRoleId] = useState(null); - const [selectedRole, setSelectedRole] = useState(selectRole); + const [selectedRole, setSelectedRole] = useState(selectRole || null); const [isReplacing, setIsReplacing] = useState(false); // 全局替换状态 // 计算属性 @@ -238,5 +240,6 @@ export const useRoleShotServiceHook = (projectId: string,selectRole:RoleEntity): toggleShotSelection, applyRoleToSelectedShots, clearShotSelection, + setSelectedRole }; }; diff --git a/components/pages/work-flow/use-edit-data.tsx b/components/pages/work-flow/use-edit-data.tsx index 99c80fb..de6452a 100644 --- a/components/pages/work-flow/use-edit-data.tsx +++ b/components/pages/work-flow/use-edit-data.tsx @@ -45,7 +45,8 @@ export const useEditData = (tabType: string) => { optimizeRoleText, updateRoleText, regenerateRole, - uploadImageToQiniu + uploadImageToQiniu, + saveRoleToLibrary } = useRoleServiceHook(); const { @@ -58,7 +59,7 @@ export const useEditData = (tabType: string) => { toggleShotSelection, applyRoleToSelectedShots, clearShotSelection - } = useRoleShotServiceHook(projectId, selectedRole); + } = useRoleShotServiceHook(projectId, selectedRole || undefined); useEffect(() => { if (tabType === 'shot') { @@ -116,6 +117,7 @@ export const useEditData = (tabType: string) => { toggleSelectAllShots, toggleShotSelection, applyRoleToSelectedShots, - clearShotSelection + clearShotSelection, + saveRoleToLibrary } -} \ No newline at end of file +} diff --git a/components/ui/character-tab-content.tsx b/components/ui/character-tab-content.tsx index 4560aa8..e4055f3 100644 --- a/components/ui/character-tab-content.tsx +++ b/components/ui/character-tab-content.tsx @@ -94,7 +94,8 @@ export function CharacterTabContent({ // role shot shotSelectionList, fetchRoleShots, - applyRoleToSelectedShots + applyRoleToSelectedShots, + saveRoleToLibrary } = useEditData('role'); const searchParams = useSearchParams(); const episodeId = searchParams.get('episodeId'); @@ -154,6 +155,9 @@ export function CharacterTabContent({ console.log('Add to library:', addToLibrary); applyRoleToSelectedShots(selectedRole || {} as RoleEntity); setIsReplacePanelOpen(false); + if(addToLibrary){ + saveRoleToLibrary(); + } }; // 取消替换