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

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[];
}
export interface RoleResponse {
/** 角色描述 */
character_description: string;
/** 角色名称 */
character_name: string;
/** 高亮关键词 */
highlights: string[];
/** 角色图片地址 */
image_path: string;
characters: {
/** 角色描述 */
character_description: string;
/** 角色名称 */
character_name: string;
/** 高亮关键词 */
highlights: string[];
/** 角色图片地址 */
image_path: string;
/** 角色图片地址 */
image_url: string;
}[];
/**缓存 */
character_draft: string;
}

View File

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

View File

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