更新角色响应接口,调整角色数据结构以支持多个角色信息,并修复角色解析函数以适应新结构。

This commit is contained in:
北枳 2025-08-13 17:45:34 +08:00
parent 5e55ec5baa
commit 4f31df7fe7
3 changed files with 19 additions and 15 deletions

View File

@ -602,14 +602,18 @@ export interface RoleRecognitionResponse {
characters_used: CharacterUsed[]; characters_used: CharacterUsed[];
} }
export interface RoleResponse { export interface RoleResponse {
/** 角色描述 */ characters: {
character_description: string; /** 角色描述 */
/** 角色名称 */ character_description: string;
character_name: string; /** 角色名称 */
/** 高亮关键词 */ character_name: string;
highlights: string[]; /** 高亮关键词 */
/** 角色图片地址 */ highlights: string[];
image_path: string; /** 角色图片地址 */
image_path: string;
/** 角色图片地址 */
image_url: string;
}[];
/**缓存 */ /**缓存 */
character_draft: string; character_draft: string;
} }

View File

@ -918,7 +918,7 @@ export const getCharacterListByProjectWithHighlight = async (request: {
project_id: string; project_id: string;
/** 每个角色最多提取的高亮关键词数量 */ /** 每个角色最多提取的高亮关键词数量 */
max_keywords?: number; max_keywords?: number;
}): Promise<ApiResponse<RoleResponse[]>> => { }): Promise<ApiResponse<RoleResponse>> => {
return post("/character/list_by_project_with_highlight", request); return post("/character/list_by_project_with_highlight", request);
}; };

View File

@ -86,16 +86,16 @@ export class RoleEditUseCase {
* @returns {RoleEntity[]} * @returns {RoleEntity[]}
* @throws {Error} * @throws {Error}
*/ */
parseProjectRoleList(projectRoleData: RoleResponse[]): RoleEntity[] { parseProjectRoleList(projectRoleData: RoleResponse): RoleEntity[] {
if (!Array.isArray(projectRoleData)) { if (!Array.isArray(projectRoleData)) {
throw new Error('项目角色数据格式错误'); throw new Error('项目角色数据格式错误');
} }
return projectRoleData.map((char, index) => { if(projectRoleData.character_draft){
if(char.character_draft){ const roleEntity: RoleEntity[] = JSON.parse(projectRoleData.character_draft);
const roleEntity: RoleEntity = JSON.parse(char.character_draft); return roleEntity;
return roleEntity; }
} return projectRoleData.characters.map((char, index) => {
/** 角色实体对象 */ /** 角色实体对象 */
const roleEntity: RoleEntity = { const roleEntity: RoleEntity = {
id: `role_${index + 1}`, id: `role_${index + 1}`,