forked from 77media/video-flow
新增角色描述字段,并更新相关接口和组件以支持角色信息的完整性
This commit is contained in:
parent
4ce2811cb7
commit
99f6cfdd49
@ -565,6 +565,8 @@ export interface CharacterUsed {
|
|||||||
character_name: string;
|
character_name: string;
|
||||||
/** 角色C-ID */
|
/** 角色C-ID */
|
||||||
c_id: string;
|
c_id: string;
|
||||||
|
/** 角色描述 */
|
||||||
|
character_description: string;
|
||||||
/** 角色图片路径 */
|
/** 角色图片路径 */
|
||||||
image_path: string;
|
image_path: string;
|
||||||
/** 角色头像 */
|
/** 角色头像 */
|
||||||
|
|||||||
@ -34,7 +34,7 @@ interface UseRoleService {
|
|||||||
/** 重新生成角色 */
|
/** 重新生成角色 */
|
||||||
regenerateRole: () => Promise<void>;
|
regenerateRole: () => Promise<void>;
|
||||||
/** 获取用户角色库 */
|
/** 获取用户角色库 */
|
||||||
fetchUserRoleLibrary: () => Promise<void>;
|
fetchUserRoleLibrary: (generateText?: string) => Promise<void>;
|
||||||
/** 替换角色 */
|
/** 替换角色 */
|
||||||
replaceRoleWithLibrary: (replaceRoleId: string) => Promise<void>;
|
replaceRoleWithLibrary: (replaceRoleId: string) => Promise<void>;
|
||||||
/** 上传图片并更新角色信息 */
|
/** 上传图片并更新角色信息 */
|
||||||
|
|||||||
@ -146,6 +146,7 @@ export const useEditData = (tabType: string, originalText?: string) => {
|
|||||||
toggleShotSelection,
|
toggleShotSelection,
|
||||||
applyRoleToSelectedShots,
|
applyRoleToSelectedShots,
|
||||||
clearShotSelection,
|
clearShotSelection,
|
||||||
saveRoleToLibrary
|
saveRoleToLibrary,
|
||||||
|
setSelectedRole
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,6 +32,8 @@ PersonBox.displayName = 'PersonBox';
|
|||||||
export type PersonDetection = {
|
export type PersonDetection = {
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
|
description: string;
|
||||||
|
imageUrl: string;
|
||||||
position: {
|
position: {
|
||||||
top: number;
|
top: number;
|
||||||
left: number;
|
left: number;
|
||||||
|
|||||||
@ -11,6 +11,7 @@ import FloatingGlassPanel from './FloatingGlassPanel';
|
|||||||
import { ReplaceCharacterPanel } from './replace-character-panel';
|
import { ReplaceCharacterPanel } from './replace-character-panel';
|
||||||
import HorizontalScroller from './HorizontalScroller';
|
import HorizontalScroller from './HorizontalScroller';
|
||||||
import { useEditData } from '@/components/pages/work-flow/use-edit-data';
|
import { useEditData } from '@/components/pages/work-flow/use-edit-data';
|
||||||
|
import { RoleEntity } from '@/app/service/domain/Entities';
|
||||||
|
|
||||||
interface ShotTabContentProps {
|
interface ShotTabContentProps {
|
||||||
currentSketchIndex: number;
|
currentSketchIndex: number;
|
||||||
@ -32,7 +33,8 @@ export function ShotTabContent({
|
|||||||
fetchRoleShots,
|
fetchRoleShots,
|
||||||
shotSelectionList,
|
shotSelectionList,
|
||||||
applyRoleToSelectedShots,
|
applyRoleToSelectedShots,
|
||||||
calculateRecognitionBoxes
|
calculateRecognitionBoxes,
|
||||||
|
setSelectedRole
|
||||||
} = useEditData('shot');
|
} = useEditData('shot');
|
||||||
const [selectedIndex, setSelectedIndex] = useState(currentSketchIndex);
|
const [selectedIndex, setSelectedIndex] = useState(currentSketchIndex);
|
||||||
|
|
||||||
@ -82,6 +84,8 @@ export function ShotTabContent({
|
|||||||
setDetections(recognitionBoxes.map((person: any) => ({
|
setDetections(recognitionBoxes.map((person: any) => ({
|
||||||
id: person.person_id,
|
id: person.person_id,
|
||||||
name: 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 }
|
position: { top: person.top, left: person.left, width: person.width, height: person.height }
|
||||||
})));
|
})));
|
||||||
} else {
|
} else {
|
||||||
@ -117,10 +121,23 @@ export function ShotTabContent({
|
|||||||
// 处理人物点击 打开角色库
|
// 处理人物点击 打开角色库
|
||||||
const handlePersonClick = async (person: PersonDetection) => {
|
const handlePersonClick = async (person: PersonDetection) => {
|
||||||
console.log('person', person);
|
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);
|
setSelectedCharacter(person);
|
||||||
setIsLoadingLibrary(true);
|
setIsLoadingLibrary(true);
|
||||||
setIsReplaceLibraryOpen(true);
|
setIsReplaceLibraryOpen(true);
|
||||||
await fetchUserRoleLibrary();
|
await fetchUserRoleLibrary(role.generateText);
|
||||||
setIsLoadingLibrary(false);
|
setIsLoadingLibrary(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user