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];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -46,9 +46,7 @@ export class DetailImageItem extends Component {
|
||||
if (!this.img || !this.img.spriteFrame) return;
|
||||
|
||||
// 延迟一帧确保UI布局完成
|
||||
this.scheduleOnce(() => {
|
||||
this.doScaleToFill();
|
||||
}, 0);
|
||||
this.doScaleToFill();
|
||||
}
|
||||
|
||||
doScaleToFill() {
|
||||
@@ -85,7 +83,7 @@ export class DetailImageItem extends Component {
|
||||
refresh(path: string, base: GirlDetailPanel, isImage: boolean = true) {
|
||||
this.base = base;
|
||||
this.lock.active = false;
|
||||
this.question.active = false;
|
||||
this.question.active = true; // 显示问号,表示加载中
|
||||
this.url = path;
|
||||
|
||||
let imgPath = this.url;
|
||||
@@ -94,6 +92,7 @@ export class DetailImageItem extends Component {
|
||||
imgPath = this.url + "_thumbnail";
|
||||
}
|
||||
ResManager.I.changeBundleSpriteFrame(this.img, imgPath, "Chat18x", () => {
|
||||
this.question.active = false; // 图片加载成功后隐藏问号
|
||||
this.scaleToFillItem();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user