diff --git a/api/DTO/movieEdit.ts b/api/DTO/movieEdit.ts index 9aefa10..71ae535 100644 --- a/api/DTO/movieEdit.ts +++ b/api/DTO/movieEdit.ts @@ -565,6 +565,8 @@ export interface CharacterUsed { character_name: string; /** 角色C-ID */ c_id: string; + /** 角色描述 */ + character_description: string; /** 角色图片路径 */ image_path: string; /** 角色头像 */ diff --git a/app/service/Interaction/RoleService.ts b/app/service/Interaction/RoleService.ts index 5f25304..636ed23 100644 --- a/app/service/Interaction/RoleService.ts +++ b/app/service/Interaction/RoleService.ts @@ -34,7 +34,7 @@ interface UseRoleService { /** 重新生成角色 */ regenerateRole: () => Promise; /** 获取用户角色库 */ - fetchUserRoleLibrary: () => Promise; + fetchUserRoleLibrary: (generateText?: string) => Promise; /** 替换角色 */ replaceRoleWithLibrary: (replaceRoleId: string) => Promise; /** 上传图片并更新角色信息 */ diff --git a/components/pages/work-flow/use-edit-data.tsx b/components/pages/work-flow/use-edit-data.tsx index 70dcf28..fe49b45 100644 --- a/components/pages/work-flow/use-edit-data.tsx +++ b/components/pages/work-flow/use-edit-data.tsx @@ -146,6 +146,7 @@ export const useEditData = (tabType: string, originalText?: string) => { toggleShotSelection, applyRoleToSelectedShots, clearShotSelection, - saveRoleToLibrary + saveRoleToLibrary, + setSelectedRole } } diff --git a/components/ui/person-detection.tsx b/components/ui/person-detection.tsx index 952d41d..a7c0140 100644 --- a/components/ui/person-detection.tsx +++ b/components/ui/person-detection.tsx @@ -32,6 +32,8 @@ PersonBox.displayName = 'PersonBox'; export type PersonDetection = { id: string; name: string; + description: string; + imageUrl: string; position: { top: number; left: number; diff --git a/components/ui/shot-tab-content.tsx b/components/ui/shot-tab-content.tsx index 2ba038b..c4e6e59 100644 --- a/components/ui/shot-tab-content.tsx +++ b/components/ui/shot-tab-content.tsx @@ -11,6 +11,7 @@ import FloatingGlassPanel from './FloatingGlassPanel'; import { ReplaceCharacterPanel } from './replace-character-panel'; import HorizontalScroller from './HorizontalScroller'; import { useEditData } from '@/components/pages/work-flow/use-edit-data'; +import { RoleEntity } from '@/app/service/domain/Entities'; interface ShotTabContentProps { currentSketchIndex: number; @@ -32,7 +33,8 @@ export function ShotTabContent({ fetchRoleShots, shotSelectionList, applyRoleToSelectedShots, - calculateRecognitionBoxes + calculateRecognitionBoxes, + setSelectedRole } = useEditData('shot'); const [selectedIndex, setSelectedIndex] = useState(currentSketchIndex); @@ -82,6 +84,8 @@ export function ShotTabContent({ setDetections(recognitionBoxes.map((person: any) => ({ id: person.person_id, name: person.person_id, + description: roleRecognitionResponse.characters_used.find((character: any) => character.character_name === person.person_id)?.character_description || '', + imageUrl: roleRecognitionResponse.characters_used.find((character: any) => character.character_name === person.person_id)?.avatar || '', position: { top: person.top, left: person.left, width: person.width, height: person.height } }))); } else { @@ -117,10 +121,23 @@ export function ShotTabContent({ // 处理人物点击 打开角色库 const handlePersonClick = async (person: PersonDetection) => { console.log('person', person); + const role: RoleEntity = { + id: person.id, + name: person.name, + generateText: person.description, + tags: [], // 由于 person 对象中没有标签信息,我们设置为空数组 + imageUrl: person.imageUrl, + fromDraft: false, // 默认不是来自草稿箱 + isChangeRole: true, // 默认没有发生角色形象的变更 + updatedAt: Date.now(), // 使用当前时间戳 + loadingProgress: 100 // 已完成加载 + }; + console.log('role', role); + setSelectedRole(role); setSelectedCharacter(person); setIsLoadingLibrary(true); setIsReplaceLibraryOpen(true); - await fetchUserRoleLibrary(); + await fetchUserRoleLibrary(role.generateText); setIsLoadingLibrary(false); };