聊天数据bug修复

This commit is contained in:
2025-10-14 11:34:09 +08:00
parent 0088515f2a
commit 34d07ec143
5 changed files with 36 additions and 15 deletions
@@ -10,6 +10,10 @@ import { InnerMsgCode } from "../../Main/Config/InnerMsgCode";
import { TipsPanel } from "../ui/panels/TipsPanel"; import { TipsPanel } from "../ui/panels/TipsPanel";
import LanguageUtils from "../../Main/Common/LanguageUtils"; import LanguageUtils from "../../Main/Common/LanguageUtils";
import { logger } from "db://assets/Scripts/Main/Common/Logger"; 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之间的通信协议 * 聊天控制器接口 - 定义Panel和Controller之间的通信协议
@@ -152,12 +156,16 @@ export class ChatController {
* @param roleId 角色ID * @param roleId 角色ID
* @returns 是否切换成功 * @returns 是否切换成功
*/ */
public switchRole(categoryId: string, roleId: number): boolean { public async switchRole(
categoryId: string,
roleId: number
): Promise<boolean> {
if (!this.chatModel.switchToRole(categoryId, roleId)) { if (!this.chatModel.switchToRole(categoryId, roleId)) {
logger.error(`Failed to switch to role ${roleId}`); logger.error(`Failed to switch to role ${roleId}`);
return false; return false;
} }
// 更新AI服务的当前角色 // 更新AI服务的当前角色
ChatAIService.Instance.setCurrentRole(roleId); ChatAIService.Instance.setCurrentRole(roleId);
+15 -1
View File
@@ -155,8 +155,10 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
} }
} }
async refresh() { async refresh() {
const newRoleId = NavigationManager.Instance.getSelectedGirlId(); // 请求详细数据
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl); const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
const newRoleId = NavigationManager.Instance.getSelectedGirlId();
this.waitingAI.active = false; this.waitingAI.active = false;
// 检查是否是切换角色 // 检查是否是切换角色
const isRoleSwitch = this.id && this.id !== newRoleId; const isRoleSwitch = this.id && this.id !== newRoleId;
@@ -165,6 +167,18 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
this.categoryId = this.categoryId =
NavigationManager.Instance.getSelectedCategoryId().toString(); 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 // 获取ChatController单例并绑定当前Panel
this.chatController = ChatController.Instance; this.chatController = ChatController.Instance;
this.chatController.bindView(this); this.chatController.bindView(this);
@@ -326,8 +326,7 @@ export class GirlDetailPanel extends li_BaseView {
OnClickChatBtn() { OnClickChatBtn() {
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl); 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) { //if (isRelease || isFree) {
// 直接在当前页面打开ChatPanel作为子页面 // 直接在当前页面打开ChatPanel作为子页面
const currentPanel = NavigationManager.Instance.getCurrentActivePanelNode(); const currentPanel = NavigationManager.Instance.getCurrentActivePanelNode();
@@ -278,6 +278,6 @@ export class SettingPanel extends li_BaseView {
} }
onClickClose() { onClickClose() {
NavigationManager.Instance.closeSubPanel(this); NavigationManager.Instance.closePopupPanel(this.node);
} }
} }
+10 -10
View File
@@ -1337,7 +1337,7 @@
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 0, "x": 0,
"y": 123.22400000000005, "y": 75.25150000000004,
"z": 0 "z": 0
}, },
"_lrot": { "_lrot": {
@@ -1386,8 +1386,8 @@
}, },
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 487.9770000000001, "x": 149.128,
"y": -383.09000000000003, "y": -537.486,
"z": 0 "z": 0
}, },
"_lrot": { "_lrot": {
@@ -1456,9 +1456,9 @@
"_alignFlags": 36, "_alignFlags": 36,
"_target": null, "_target": null,
"_left": 0, "_left": 0,
"_right": 52.02299999999991, "_right": 390.872,
"_top": 0, "_top": 0,
"_bottom": 73.75999999999999, "_bottom": 38.46249999999998,
"_horizontalCenter": 0, "_horizontalCenter": 0,
"_verticalCenter": 0, "_verticalCenter": 0,
"_isAbsLeft": true, "_isAbsLeft": true,
@@ -1524,7 +1524,7 @@
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 0, "x": 0,
"y": -456.85, "y": -575.9485,
"z": 0 "z": 0
}, },
"_lrot": { "_lrot": {
@@ -3733,7 +3733,7 @@
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 1080, "width": 1080,
"height": 913.7 "height": 1151.897
}, },
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
@@ -3878,7 +3878,7 @@
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 1080, "width": 1080,
"height": 913.7 "height": 1151.897
}, },
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
@@ -3949,8 +3949,8 @@
"_target": null, "_target": null,
"_left": 0, "_left": 0,
"_right": 0, "_right": 0,
"_top": 219.92599999999993, "_top": 148.80000000000007,
"_bottom": 466.374, "_bottom": 299.30300000000005,
"_horizontalCenter": 0, "_horizontalCenter": 0,
"_verticalCenter": 0, "_verticalCenter": 0,
"_isAbsLeft": true, "_isAbsLeft": true,