fix
This commit is contained in:
@@ -14,6 +14,7 @@ import {
|
||||
import "../../utils/polyfills";
|
||||
import { DialogManager } from "../../manager/DialogManager";
|
||||
import { ChatController, IChatPanelCallback } from "../../core/ChatController";
|
||||
import { ChatAIService } from "../../core/ChatAIService";
|
||||
import li_BaseView from "db://assets/Scripts/Main/Common/li_BaseView";
|
||||
import Utils from "db://assets/Scripts/Main/Common/Utils";
|
||||
import { InnerMsgCode } from "db://assets/Scripts/Main/Config/InnerMsgCode";
|
||||
@@ -73,6 +74,7 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
|
||||
private waitingAI: Node;
|
||||
nameKey: string;
|
||||
private currentEmotion: VideoEmotion | null = null;
|
||||
private isActive: boolean = false; // 标记Panel是否处于活跃状态
|
||||
|
||||
private onLanguageChangeCallback = () => {
|
||||
if (!this.girlName) return;
|
||||
@@ -388,10 +390,14 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
|
||||
protected onEnable(): void {
|
||||
if (!this.manager) this.manager = DialogManager.getInstance();
|
||||
|
||||
this.isActive = true; // 设置为活跃状态
|
||||
ChatAIService.Instance.setShouldShowErrorTips(true); // 启用错误提示
|
||||
this.base.active = false;
|
||||
this.refresh();
|
||||
}
|
||||
protected onDisable(): void {
|
||||
this.isActive = false; // 设置为非活跃状态,停止响应异步操作
|
||||
ChatAIService.Instance.setShouldShowErrorTips(false); // 禁用错误提示,避免在其他页面显示
|
||||
this.base.active = true;
|
||||
}
|
||||
|
||||
@@ -404,12 +410,20 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
|
||||
}
|
||||
if (this.isWaiting) {
|
||||
TipsPanel.show(LanguageUtils.getText("chat_error_code_1003"));
|
||||
return; // 修复:添加return,避免重复发送
|
||||
}
|
||||
|
||||
// 通过ChatController发送消息
|
||||
this.isWaiting = true;
|
||||
this.waitingAI.active = true;
|
||||
const succeed = await this.chatController.sendMessage(str);
|
||||
|
||||
// 检查Panel是否仍然活跃,如果已经关闭则不处理结果
|
||||
if (!this.isActive) {
|
||||
logger.log("ChatPanel已关闭,忽略AI响应结果");
|
||||
return;
|
||||
}
|
||||
|
||||
if (succeed) {
|
||||
// 清空输入框
|
||||
this.editBox.string = "";
|
||||
|
||||
@@ -329,18 +329,18 @@ export class GirlDetailPanel extends li_BaseView {
|
||||
const isRelease = girlData.getIsRelease(this.category.toString(), this.id);
|
||||
const isFree = girlData.isGirlFreeType(this.category.toString(), this.id);
|
||||
//if (isRelease || isFree) {
|
||||
// 使用带过渡动画的导航方法
|
||||
NavigationManager.Instance.switchToPanel(
|
||||
PanelType.PAST_GIRL_LIST,
|
||||
false,
|
||||
(base) => {
|
||||
const chatData = { girlId: this.id, base: base };
|
||||
NavigationManager.Instance.openSubPanel("ChatPanel", base, chatData, {
|
||||
openAnimation: PageTransitionType.SLIDE_LEFT,
|
||||
closeAnimation: PageTransitionType.SLIDE_RIGHT,
|
||||
});
|
||||
}
|
||||
);
|
||||
// 直接在当前页面打开ChatPanel作为子页面
|
||||
const currentPanel = NavigationManager.Instance.getCurrentActivePanelNode();
|
||||
if (currentPanel) {
|
||||
const chatData = { girlId: this.id, base: currentPanel };
|
||||
NavigationManager.Instance.openSubPanel("ChatPanel", currentPanel, chatData, {
|
||||
openAnimation: PageTransitionType.SLIDE_LEFT,
|
||||
closeAnimation: PageTransitionType.SLIDE_RIGHT,
|
||||
hideBasePanel: true,
|
||||
});
|
||||
} else {
|
||||
logger.warn("[GirlDetailPanel] 无法获取当前激活的主页面");
|
||||
}
|
||||
// } else {
|
||||
// //未解锁
|
||||
// NavigationManager.Instance.openPopupPanel("GirlListPopupPanel", {
|
||||
|
||||
@@ -76,7 +76,14 @@ export class ShowPanel extends li_BaseView {
|
||||
// 加载远程资源
|
||||
let newPath = envData.cdn + "/" + "Girls/" + path + ".png";
|
||||
ResManager.I.changeRemoteSpriteFrame(this.image, newPath, () => {
|
||||
Utils.adjustBgPixelRatio(this.image.node, 3);
|
||||
// 固定高度为 1334,等比缩放宽度
|
||||
const targetHeight = 1334;
|
||||
const uiTransform = this.image.node.getComponent(UITransform);
|
||||
if (uiTransform && uiTransform.height > 0) {
|
||||
const scale = targetHeight / uiTransform.height;
|
||||
uiTransform.height = targetHeight;
|
||||
uiTransform.width = uiTransform.width * scale;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// 使用自己的 videoPlayer 进行置顶显示
|
||||
|
||||
Reference in New Issue
Block a user