fix
This commit is contained in:
@@ -358,7 +358,7 @@ export class ChatModel {
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据情绪获取对应的视频
|
||||
* 根据情绪获取对应的视频(如果有多个视频,随机返回一个)
|
||||
* @param emotion 目标情绪
|
||||
* @param roleId 角色ID,不传则使用当前角色
|
||||
* @returns 匹配的视频对象,没找到则返回null
|
||||
@@ -377,10 +377,23 @@ export class ChatModel {
|
||||
return null;
|
||||
}
|
||||
|
||||
const video = roleData.commercialVideos.find(
|
||||
// 获取所有匹配该情绪的视频
|
||||
const matchingVideos = roleData.commercialVideos.filter(
|
||||
(video) => video.emotion === emotion
|
||||
);
|
||||
return video || null;
|
||||
|
||||
if (matchingVideos.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 如果只有一个匹配的视频,直接返回
|
||||
if (matchingVideos.length === 1) {
|
||||
return matchingVideos[0];
|
||||
}
|
||||
|
||||
// 如果有多个匹配的视频,随机选择一个
|
||||
const randomIndex = Math.floor(Math.random() * matchingVideos.length);
|
||||
return matchingVideos[randomIndex];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user