聊天数据bug修复
This commit is contained in:
@@ -10,6 +10,10 @@ import { InnerMsgCode } from "../../Main/Config/InnerMsgCode";
|
||||
import { TipsPanel } from "../ui/panels/TipsPanel";
|
||||
import LanguageUtils from "../../Main/Common/LanguageUtils";
|
||||
import { logger } from "db://assets/Scripts/Main/Common/Logger";
|
||||
import { GirlService } from "../network/services/GirlService";
|
||||
import { DataManager, DataId } from "../data/DataManager";
|
||||
import { GirlData } from "../data/GirlData";
|
||||
import proto from "db://assets/Scripts/proto/proto.pb.js";
|
||||
|
||||
/**
|
||||
* 聊天控制器接口 - 定义Panel和Controller之间的通信协议
|
||||
@@ -152,12 +156,16 @@ export class ChatController {
|
||||
* @param roleId 角色ID
|
||||
* @returns 是否切换成功
|
||||
*/
|
||||
public switchRole(categoryId: string, roleId: number): boolean {
|
||||
public async switchRole(
|
||||
categoryId: string,
|
||||
roleId: number
|
||||
): Promise<boolean> {
|
||||
if (!this.chatModel.switchToRole(categoryId, roleId)) {
|
||||
logger.error(`Failed to switch to role ${roleId}`);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// 更新AI服务的当前角色
|
||||
ChatAIService.Instance.setCurrentRole(roleId);
|
||||
|
||||
|
||||
@@ -155,8 +155,10 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
|
||||
}
|
||||
}
|
||||
async refresh() {
|
||||
const newRoleId = NavigationManager.Instance.getSelectedGirlId();
|
||||
// 请求详细数据
|
||||
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
|
||||
|
||||
const newRoleId = NavigationManager.Instance.getSelectedGirlId();
|
||||
this.waitingAI.active = false;
|
||||
// 检查是否是切换角色
|
||||
const isRoleSwitch = this.id && this.id !== newRoleId;
|
||||
@@ -165,6 +167,18 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
|
||||
this.categoryId =
|
||||
NavigationManager.Instance.getSelectedCategoryId().toString();
|
||||
|
||||
const detail = girlData.getGrilDetail(this.categoryId, this.id);
|
||||
if (!detail) {
|
||||
const reqData = {
|
||||
id: this.id,
|
||||
};
|
||||
let res = await GirlService.I.reqGetGirlDetail(reqData);
|
||||
if (res && res.code === proto.cs.EnmRetCode.SUCCESS) {
|
||||
// 保存数据
|
||||
girlData.setGirlDetailData(this.categoryId.toString(), res.data);
|
||||
}
|
||||
}
|
||||
|
||||
// 获取ChatController单例并绑定当前Panel
|
||||
this.chatController = ChatController.Instance;
|
||||
this.chatController.bindView(this);
|
||||
|
||||
@@ -326,8 +326,7 @@ export class GirlDetailPanel extends li_BaseView {
|
||||
OnClickChatBtn() {
|
||||
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
|
||||
|
||||
const isRelease = girlData.getIsRelease(this.category.toString(), this.id);
|
||||
const isFree = girlData.isGirlFreeType(this.category.toString(), this.id);
|
||||
|
||||
//if (isRelease || isFree) {
|
||||
// 直接在当前页面打开ChatPanel作为子页面
|
||||
const currentPanel = NavigationManager.Instance.getCurrentActivePanelNode();
|
||||
|
||||
@@ -278,6 +278,6 @@ export class SettingPanel extends li_BaseView {
|
||||
}
|
||||
|
||||
onClickClose() {
|
||||
NavigationManager.Instance.closeSubPanel(this);
|
||||
NavigationManager.Instance.closePopupPanel(this.node);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user