新增角色描述字段,并更新相关接口和组件以支持角色信息的完整性

This commit is contained in:
北枳 2025-08-14 18:37:54 +08:00
parent 4ce2811cb7
commit 99f6cfdd49
5 changed files with 26 additions and 4 deletions

View File

@ -565,6 +565,8 @@ export interface CharacterUsed {
character_name: string;
/** 角色C-ID */
c_id: string;
/** 角色描述 */
character_description: string;
/** 角色图片路径 */
image_path: string;
/** 角色头像 */

View File

@ -34,7 +34,7 @@ interface UseRoleService {
/** 重新生成角色 */
regenerateRole: () => Promise<void>;
/** 获取用户角色库 */
fetchUserRoleLibrary: () => Promise<void>;
fetchUserRoleLibrary: (generateText?: string) => Promise<void>;
/** 替换角色 */
replaceRoleWithLibrary: (replaceRoleId: string) => Promise<void>;
/** 上传图片并更新角色信息 */

View File

@ -146,6 +146,7 @@ export const useEditData = (tabType: string, originalText?: string) => {
toggleShotSelection,
applyRoleToSelectedShots,
clearShotSelection,
saveRoleToLibrary
saveRoleToLibrary,
setSelectedRole
}
}

View File

@ -32,6 +32,8 @@ PersonBox.displayName = 'PersonBox';
export type PersonDetection = {
id: string;
name: string;
description: string;
imageUrl: string;
position: {
top: number;
left: number;

View File

@ -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);
};