日志控制

This commit is contained in:
chen wei bo
2025-09-21 20:25:42 +08:00
parent 8f90c1d7cf
commit e78f6b937e
13 changed files with 122 additions and 107 deletions
+12 -11
View File
@@ -12,6 +12,7 @@ import { GirlData } from "../data/GirlData";
import proto from "db://assets/Scripts/proto/proto.pb.js"; import proto from "db://assets/Scripts/proto/proto.pb.js";
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";
/** /**
* AI聊天服务类 * AI聊天服务类
@@ -130,7 +131,7 @@ export class ChatAIService {
}, },
history: savedHistory, history: savedHistory,
}); });
console.log( logger.log(
`Loaded ${savedHistory.length} history messages for role ${roleId}` `Loaded ${savedHistory.length} history messages for role ${roleId}`
); );
} else { } else {
@@ -164,7 +165,7 @@ export class ChatAIService {
], ],
}, },
}); });
console.log(`Created new chat instance for role ${roleId}`); logger.log(`Created new chat instance for role ${roleId}`);
} }
this.chatInstances.set(roleId, chat); this.chatInstances.set(roleId, chat);
@@ -201,7 +202,7 @@ export class ChatAIService {
* @example * @example
* ```typescript * ```typescript
* const response = await chatService.sendMessage(10001, "你好"); * const response = await chatService.sendMessage(10001, "你好");
* console.log(response); // AI的回复 * logger.log(response); // AI的回复
* ``` * ```
*/ */
public async sendMessage(roleId: number, message: string): Promise<string> { public async sendMessage(roleId: number, message: string): Promise<string> {
@@ -231,7 +232,7 @@ export class ChatAIService {
}); });
if (response && response.text) { if (response && response.text) {
console.log(`Response from role ${roleId}:`, response.text); logger.log(`Response from role ${roleId}:`, response.text);
try { try {
// 保存用户消息 // 保存用户消息
@@ -318,7 +319,7 @@ export class ChatAIService {
EmotionAIService.Instance.clearEmotionHistory(roleId); EmotionAIService.Instance.clearEmotionHistory(roleId);
// 清除本地存储的历史 // 清除本地存储的历史
ChatHistoryManager.Instance.clearHistory(roleId); ChatHistoryManager.Instance.clearHistory(roleId);
console.log(`Cleared chat history for role ${roleId}`); logger.log(`Cleared chat history for role ${roleId}`);
} }
/** /**
@@ -330,7 +331,7 @@ export class ChatAIService {
EmotionAIService.Instance.clearAllEmotionHistory(); EmotionAIService.Instance.clearAllEmotionHistory();
// 清除本地存储的所有历史 // 清除本地存储的所有历史
ChatHistoryManager.Instance.clearAllHistory(); ChatHistoryManager.Instance.clearAllHistory();
console.log("Cleared all chat histories"); logger.log("Cleared all chat histories");
} }
/** /**
@@ -345,7 +346,7 @@ export class ChatAIService {
* @deprecated 请使用sendMessage方法,此方法将在下个版本中移除 * @deprecated 请使用sendMessage方法,此方法将在下个版本中移除
*/ */
public async Post(data: GPTRequest): Promise<string> { public async Post(data: GPTRequest): Promise<string> {
console.warn("Post方法已废弃,请使用sendMessage方法"); logger.warn("Post方法已废弃,请使用sendMessage方法");
const roleId = this.currentRoleId || 10001; // 默认使用第一个角色 const roleId = this.currentRoleId || 10001; // 默认使用第一个角色
const message = data.messages[0]?.content || ""; const message = data.messages[0]?.content || "";
return this.sendMessage(roleId, message); return this.sendMessage(roleId, message);
@@ -360,9 +361,9 @@ export class ChatAIService {
girlId, girlId,
msgs: msgList, msgs: msgList,
}; };
console.log("请求上报聊天数据的请求数据:", reqData); logger.log("请求上报聊天数据的请求数据:", reqData);
let res = await ChatService.I.reqChatMsg(reqData); let res = await ChatService.I.reqChatMsg(reqData);
console.log("请求上报聊天数据的响应数据:", res); logger.log("请求上报聊天数据的响应数据:", res);
if (res && res.code === proto.cs.EnmRetCode.SUCCESS) { if (res && res.code === proto.cs.EnmRetCode.SUCCESS) {
const resData = res.data; const resData = res.data;
// 保存数据 // 保存数据
@@ -391,9 +392,9 @@ export class ChatAIService {
page, page,
limit, limit,
}; };
console.log("获取聊天数据的请求数据:", reqData); logger.log("获取聊天数据的请求数据:", reqData);
let res = await ChatService.I.reqGetChatMsg(reqData); let res = await ChatService.I.reqGetChatMsg(reqData);
console.log("获取聊天数据的响应数据:", res); logger.log("获取聊天数据的响应数据:", res);
if (res && res.code === proto.cs.EnmRetCode.SUCCESS) { if (res && res.code === proto.cs.EnmRetCode.SUCCESS) {
const resData = res.data; const resData = res.data;
// 保存数据 // 保存数据
+23 -22
View File
@@ -9,6 +9,7 @@ import Utils from "../../Main/Common/Utils";
import { InnerMsgCode } from "../../Main/Config/InnerMsgCode"; 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";
/** /**
* 聊天控制器接口 - 定义Panel和Controller之间的通信协议 * 聊天控制器接口 - 定义Panel和Controller之间的通信协议
@@ -102,7 +103,7 @@ export class ChatController {
*/ */
public bindView(callback: IChatPanelCallback): void { public bindView(callback: IChatPanelCallback): void {
this.callback = callback; this.callback = callback;
console.log("ChatController: View bound successfully"); logger.log("ChatController: View bound successfully");
} }
/** /**
@@ -110,7 +111,7 @@ export class ChatController {
*/ */
public unbindView(): void { public unbindView(): void {
this.callback = null; this.callback = null;
console.log("ChatController: View unbound"); logger.log("ChatController: View unbound");
} }
/** /**
@@ -139,7 +140,7 @@ export class ChatController {
// 同步到DialogManager // 同步到DialogManager
//this.syncDialogData(); //this.syncDialogData();
console.log(`ChatController initialized with role ${roleId}`); logger.log(`ChatController initialized with role ${roleId}`);
} else { } else {
const error = new Error(`Invalid roleId: ${roleId}`); const error = new Error(`Invalid roleId: ${roleId}`);
this.handleError(error); this.handleError(error);
@@ -153,7 +154,7 @@ export class ChatController {
*/ */
public switchRole(categoryId: string, roleId: number): boolean { public switchRole(categoryId: string, roleId: number): boolean {
if (!this.chatModel.switchToRole(categoryId, roleId)) { if (!this.chatModel.switchToRole(categoryId, roleId)) {
console.error(`Failed to switch to role ${roleId}`); logger.error(`Failed to switch to role ${roleId}`);
return false; return false;
} }
@@ -166,7 +167,7 @@ export class ChatController {
// 同步对话数据到DialogManager // 同步对话数据到DialogManager
//this.syncDialogData(); //this.syncDialogData();
console.log(`ChatController switched to role ${roleId}`); logger.log(`ChatController switched to role ${roleId}`);
return true; return true;
} }
@@ -182,7 +183,7 @@ export class ChatController {
// 检查聊天次数限制 // 检查聊天次数限制
if (!this.canSendMessage()) { if (!this.canSendMessage()) {
console.warn("ChatController: Cannot send message - chat limit reached"); logger.warn("ChatController: Cannot send message - chat limit reached");
this.callback?.onChatLimitReached(); this.callback?.onChatLimitReached();
return false; return false;
} }
@@ -190,7 +191,7 @@ export class ChatController {
try { try {
const roleId = this.chatModel.getCurrentRoleId(); const roleId = this.chatModel.getCurrentRoleId();
if (!roleId) { if (!roleId) {
console.error("Role ID is not available in ChatModel"); logger.error("Role ID is not available in ChatModel");
TipsPanel.show(LanguageUtils.getText("chat_error_code_1004")); TipsPanel.show(LanguageUtils.getText("chat_error_code_1004"));
} }
@@ -200,7 +201,7 @@ export class ChatController {
// 显示加载中的对话 // 显示加载中的对话
//this.dialogManager?.addLoadingDialog(); //this.dialogManager?.addLoadingDialog();
console.log(`Sending message to role ${roleId}: ${message}`); logger.log(`Sending message to role ${roleId}: ${message}`);
// 发送消息给AI服务 // 发送消息给AI服务
const response = await ChatAIService.Instance.sendMessage( const response = await ChatAIService.Instance.sendMessage(
roleId, roleId,
@@ -225,7 +226,7 @@ export class ChatController {
// 注意:情绪状态将通过异步事件更新,不在这里同步获取 // 注意:情绪状态将通过异步事件更新,不在这里同步获取
console.log(`Response received from role ${roleId}: ${response}`); logger.log(`Response received from role ${roleId}: ${response}`);
return true; return true;
} else { } else {
return false; return false;
@@ -259,7 +260,7 @@ export class ChatController {
public clearChatHistory(): void { public clearChatHistory(): void {
const roleId = this.chatModel.getCurrentRoleId(); const roleId = this.chatModel.getCurrentRoleId();
if (!roleId) { if (!roleId) {
console.warn("Cannot clear history: roleId is null"); logger.warn("Cannot clear history: roleId is null");
return; return;
} }
@@ -270,9 +271,9 @@ export class ChatController {
// 清除模型中的对话记录 // 清除模型中的对话记录
this.chatModel.clearDialogs(); this.chatModel.clearDialogs();
console.log(`Chat history cleared for role ${roleId}`); logger.log(`Chat history cleared for role ${roleId}`);
} catch (error) { } catch (error) {
console.error("Failed to clear chat history:", error); logger.error("Failed to clear chat history:", error);
this.handleError(error as Error); this.handleError(error as Error);
} }
} }
@@ -289,9 +290,9 @@ export class ChatController {
// 清除模型中的对话记录 // 清除模型中的对话记录
this.chatModel.clearDialogs(roleId); this.chatModel.clearDialogs(roleId);
console.log(`Chat history cleared for role ${roleId}`); logger.log(`Chat history cleared for role ${roleId}`);
} catch (error) { } catch (error) {
console.error(`Failed to clear chat history for role ${roleId}:`, error); logger.error(`Failed to clear chat history for role ${roleId}:`, error);
this.handleError(error as Error); this.handleError(error as Error);
} }
} }
@@ -311,7 +312,7 @@ export class ChatController {
this.chatModel.reset(); this.chatModel.reset();
this.callback = null; this.callback = null;
this.dialogManager = null; this.dialogManager = null;
console.log("ChatController destroyed"); logger.log("ChatController destroyed");
} }
/** /**
@@ -373,7 +374,7 @@ export class ChatController {
this.chatModel.addDialog(isPlayer, content, targetRoleId); this.chatModel.addDialog(isPlayer, content, targetRoleId);
}); });
console.log( logger.log(
`Loaded ${chatHistory.length} messages from ChatHistoryManager for role ${targetRoleId}` `Loaded ${chatHistory.length} messages from ChatHistoryManager for role ${targetRoleId}`
); );
} }
@@ -384,7 +385,7 @@ export class ChatController {
*/ */
public syncDialogData(): void { public syncDialogData(): void {
if (!this.dialogManager || !this.chatModel.validate()) { if (!this.dialogManager || !this.chatModel.validate()) {
console.warn( logger.warn(
"Cannot sync dialog data: missing DialogManager or invalid ChatModel" "Cannot sync dialog data: missing DialogManager or invalid ChatModel"
); );
return; return;
@@ -392,7 +393,7 @@ export class ChatController {
const dialogs = this.chatModel.getDialogs(); const dialogs = this.chatModel.getDialogs();
this.dialogManager.syncFromChatModel(dialogs); this.dialogManager.syncFromChatModel(dialogs);
console.log( logger.log(
`Synced ${dialogs.length} dialogs from ChatModel to DialogManager` `Synced ${dialogs.length} dialogs from ChatModel to DialogManager`
); );
} }
@@ -445,9 +446,9 @@ export class ChatController {
// 清除模型中的角色数据 // 清除模型中的角色数据
this.chatModel.clearRoleData(roleId); this.chatModel.clearRoleData(roleId);
console.log(`All data cleared for role ${roleId}`); logger.log(`All data cleared for role ${roleId}`);
} catch (error) { } catch (error) {
console.error(`Failed to clear all data for role ${roleId}:`, error); logger.error(`Failed to clear all data for role ${roleId}:`, error);
this.handleError(error as Error); this.handleError(error as Error);
} }
} }
@@ -482,7 +483,7 @@ export class ChatController {
*/ */
private onEmotionUpdated(data: any): void { private onEmotionUpdated(data: any): void {
if (!data || !data.roleId || data.emotion === undefined) { if (!data || !data.roleId || data.emotion === undefined) {
console.warn("Invalid emotion update data:", data); logger.warn("Invalid emotion update data:", data);
return; return;
} }
@@ -490,7 +491,7 @@ export class ChatController {
// 只处理当前角色的情绪更新 // 只处理当前角色的情绪更新
if (roleId === this.chatModel.getCurrentRoleId()) { if (roleId === this.chatModel.getCurrentRoleId()) {
console.log( logger.log(
`ChatController: Emotion updated for role ${roleId}: ${VideoEmotion[emotion]}` `ChatController: Emotion updated for role ${roleId}: ${VideoEmotion[emotion]}`
); );
+12 -11
View File
@@ -10,6 +10,7 @@ import { ConfigManager } from "../manager/ConfigManager";
import LanguageUtils, { LanguageType } from "../../Main/Common/LanguageUtils"; import LanguageUtils, { LanguageType } from "../../Main/Common/LanguageUtils";
import Utils from "../../Main/Common/Utils"; import Utils from "../../Main/Common/Utils";
import { InnerMsgCode } from "../../Main/Config/InnerMsgCode"; import { InnerMsgCode } from "../../Main/Config/InnerMsgCode";
import { logger } from "db://assets/Scripts/Main/Common/Logger";
/** /**
* AI情绪分析服务类 * AI情绪分析服务类
@@ -24,7 +25,7 @@ import { InnerMsgCode } from "../../Main/Config/InnerMsgCode";
* ```typescript * ```typescript
* const emotionService = EmotionAIService.Instance; * const emotionService = EmotionAIService.Instance;
* const emotion = await emotionService.analyzeEmotionalState(10001); * const emotion = await emotionService.analyzeEmotionalState(10001);
* console.log(VideoEmotion[emotion]); // "calm_down" * logger.log(VideoEmotion[emotion]); // "calm_down"
* ``` * ```
* *
* @author AI Chat System * @author AI Chat System
@@ -86,7 +87,7 @@ export class EmotionAIService {
}); });
this.emotionChatInstances.set(roleId, chat); this.emotionChatInstances.set(roleId, chat);
console.log(`Created new emotion chat instance for role ${roleId}`); logger.log(`Created new emotion chat instance for role ${roleId}`);
// 异步分析历史情绪状态 // 异步分析历史情绪状态
this.initializeEmotionAnalysis(roleId); this.initializeEmotionAnalysis(roleId);
@@ -106,7 +107,7 @@ export class EmotionAIService {
let emotionalState: VideoEmotion; let emotionalState: VideoEmotion;
if (messageCount > 0) { if (messageCount > 0) {
console.log( logger.log(
`Analyzing emotional state for role ${roleId} based on ${messageCount} messages` `Analyzing emotional state for role ${roleId} based on ${messageCount} messages`
); );
@@ -115,11 +116,11 @@ export class EmotionAIService {
if (emotionalState == null) { if (emotionalState == null) {
emotionalState = VideoEmotion.calm_down; emotionalState = VideoEmotion.calm_down;
} }
console.log( logger.log(
`Initial emotional state for role ${roleId}: ${VideoEmotion[emotionalState]}` `Initial emotional state for role ${roleId}: ${VideoEmotion[emotionalState]}`
); );
} else { } else {
console.log( logger.log(
`No history found for role ${roleId}, using default emotion: calm_down` `No history found for role ${roleId}, using default emotion: calm_down`
); );
emotionalState = VideoEmotion.calm_down; emotionalState = VideoEmotion.calm_down;
@@ -131,11 +132,11 @@ export class EmotionAIService {
emotion: emotionalState, emotion: emotionalState,
}); });
console.log( logger.log(
`Emotion initialization completed for role ${roleId}: ${VideoEmotion[emotionalState]}` `Emotion initialization completed for role ${roleId}: ${VideoEmotion[emotionalState]}`
); );
} catch (error) { } catch (error) {
console.error( logger.error(
`Failed to initialize emotion analysis for role ${roleId}:`, `Failed to initialize emotion analysis for role ${roleId}:`,
error error
); );
@@ -209,7 +210,7 @@ export class EmotionAIService {
}); });
if (response && response.text) { if (response && response.text) {
console.log(`Emotion analysis from role ${roleId}:`, response.text); logger.log(`Emotion analysis from role ${roleId}:`, response.text);
return this.parseEmotionResponse(response.text); return this.parseEmotionResponse(response.text);
} else { } else {
const warningMsg = `情绪AI返回了空响应 (角色ID: ${roleId})`; const warningMsg = `情绪AI返回了空响应 (角色ID: ${roleId})`;
@@ -297,7 +298,7 @@ export class EmotionAIService {
if (this.emotionChatInstances.has(roleId)) { if (this.emotionChatInstances.has(roleId)) {
this.emotionChatInstances.delete(roleId); this.emotionChatInstances.delete(roleId);
} }
console.log(`Cleared emotion chat history for role ${roleId}`); logger.log(`Cleared emotion chat history for role ${roleId}`);
} }
/** /**
@@ -305,7 +306,7 @@ export class EmotionAIService {
*/ */
public clearAllEmotionHistory(): void { public clearAllEmotionHistory(): void {
this.emotionChatInstances.clear(); this.emotionChatInstances.clear();
console.log("Cleared all emotion chat histories"); logger.log("Cleared all emotion chat histories");
} }
/** /**
@@ -331,7 +332,7 @@ export class EmotionAIService {
*/ */
private setCurrentEmotion(roleId: number, emotion: VideoEmotion): void { private setCurrentEmotion(roleId: number, emotion: VideoEmotion): void {
this.currentEmotions.set(roleId, emotion); this.currentEmotions.set(roleId, emotion);
console.log(`Updated emotion for role ${roleId}: ${VideoEmotion[emotion]}`); logger.log(`Updated emotion for role ${roleId}: ${VideoEmotion[emotion]}`);
} }
/** /**
+28 -26
View File
@@ -6,6 +6,8 @@ import { DataManager, DataId } from "../data/DataManager";
import { ThemeData } from "../data/ThemeData"; import { ThemeData } from "../data/ThemeData";
import { GirlData } from "../data/GirlData"; import { GirlData } from "../data/GirlData";
import { ShopData } from "../data/ShopData"; import { ShopData } from "../data/ShopData";
import { logger } from "db://assets/Scripts/Main/Common/Logger";
import proto from "db://assets/Scripts/proto/proto.pb.js"; import proto from "db://assets/Scripts/proto/proto.pb.js";
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
@@ -30,7 +32,7 @@ export class MainController {
* 初始化并预加载数据 * 初始化并预加载数据
*/ */
async init(): Promise<void> { async init(): Promise<void> {
console.log("[MainController] 开始初始化并预加载数据"); logger.log("[MainController] 开始初始化并预加载数据");
// 并行预加载所有数据 // 并行预加载所有数据
await Promise.all([ await Promise.all([
@@ -39,7 +41,7 @@ export class MainController {
this.preloadShopList() this.preloadShopList()
]); ]);
console.log("[MainController] 数据预加载完成"); logger.log("[MainController] 数据预加载完成");
} }
/** /**
@@ -47,12 +49,12 @@ export class MainController {
*/ */
async preloadThemeData(): Promise<boolean> { async preloadThemeData(): Promise<boolean> {
if (this.isThemeDataPreloaded) { if (this.isThemeDataPreloaded) {
console.log("[MainController] 主题数据已预加载"); logger.log("[MainController] 主题数据已预加载");
return true; return true;
} }
try { try {
console.log("[MainController] 开始预加载主题数据"); logger.log("[MainController] 开始预加载主题数据");
const reqData = {}; const reqData = {};
const res = await ThemeService.I.reqHallTheme(reqData); const res = await ThemeService.I.reqHallTheme(reqData);
@@ -61,14 +63,14 @@ export class MainController {
const themeData = DataManager.I.getDataById<ThemeData>(DataId.Theme); const themeData = DataManager.I.getDataById<ThemeData>(DataId.Theme);
themeData.themes = res.data; themeData.themes = res.data;
this.isThemeDataPreloaded = true; this.isThemeDataPreloaded = true;
console.log("[MainController] 主题数据预加载成功"); logger.log("[MainController] 主题数据预加载成功");
return true; return true;
} else { } else {
console.warn("[MainController] 主题数据预加载失败:", res); logger.warn("[MainController] 主题数据预加载失败:", res);
return false; return false;
} }
} catch (error) { } catch (error) {
console.error("[MainController] 主题数据预加载异常:", error); logger.error("[MainController] 主题数据预加载异常:", error);
return false; return false;
} }
} }
@@ -78,12 +80,12 @@ export class MainController {
*/ */
async preloadDailyRecommend(): Promise<boolean> { async preloadDailyRecommend(): Promise<boolean> {
if (this.isDailyRecommendPreloaded) { if (this.isDailyRecommendPreloaded) {
console.log("[MainController] 每日推荐数据已预加载"); logger.log("[MainController] 每日推荐数据已预加载");
return true; return true;
} }
try { try {
console.log("[MainController] 开始预加载每日推荐数据"); logger.log("[MainController] 开始预加载每日推荐数据");
const reqData = {}; const reqData = {};
const res = await GirlService.I.reqDailyRecommend(reqData); const res = await GirlService.I.reqDailyRecommend(reqData);
@@ -92,14 +94,14 @@ export class MainController {
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl); const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
girlData.setDailyRecommend(res.data); girlData.setDailyRecommend(res.data);
this.isDailyRecommendPreloaded = true; this.isDailyRecommendPreloaded = true;
console.log("[MainController] 每日推荐数据预加载成功"); logger.log("[MainController] 每日推荐数据预加载成功");
return true; return true;
} else { } else {
console.warn("[MainController] 每日推荐数据预加载失败:", res); logger.warn("[MainController] 每日推荐数据预加载失败:", res);
return false; return false;
} }
} catch (error) { } catch (error) {
console.error("[MainController] 每日推荐数据预加载异常:", error); logger.error("[MainController] 每日推荐数据预加载异常:", error);
return false; return false;
} }
} }
@@ -109,12 +111,12 @@ export class MainController {
*/ */
async preloadShopList(): Promise<boolean> { async preloadShopList(): Promise<boolean> {
if (this.isShopListPreloaded) { if (this.isShopListPreloaded) {
console.log("[MainController] 商品列表数据已预加载"); logger.log("[MainController] 商品列表数据已预加载");
return true; return true;
} }
try { try {
console.log("[MainController] 开始预加载商品列表数据"); logger.log("[MainController] 开始预加载商品列表数据");
const reqData = {}; const reqData = {};
const res = await ShopService.I.reqShopList(reqData); const res = await ShopService.I.reqShopList(reqData);
@@ -123,14 +125,14 @@ export class MainController {
const shopData = DataManager.I.getDataById<ShopData>(DataId.Shop); const shopData = DataManager.I.getDataById<ShopData>(DataId.Shop);
shopData.goods = res.data; shopData.goods = res.data;
this.isShopListPreloaded = true; this.isShopListPreloaded = true;
console.log("[MainController] 商品列表数据预加载成功"); logger.log("[MainController] 商品列表数据预加载成功");
return true; return true;
} else { } else {
console.warn("[MainController] 商品列表数据预加载失败:", res); logger.warn("[MainController] 商品列表数据预加载失败:", res);
return false; return false;
} }
} catch (error) { } catch (error) {
console.error("[MainController] 商品列表数据预加载异常:", error); logger.error("[MainController] 商品列表数据预加载异常:", error);
return false; return false;
} }
} }
@@ -161,14 +163,14 @@ export class MainController {
this.isThemeDataPreloaded = false; this.isThemeDataPreloaded = false;
this.isDailyRecommendPreloaded = false; this.isDailyRecommendPreloaded = false;
this.isShopListPreloaded = false; this.isShopListPreloaded = false;
console.log("[MainController] 预加载状态已重置"); logger.log("[MainController] 预加载状态已重置");
} }
/** /**
* 强制刷新主题数据 * 强制刷新主题数据
*/ */
async refreshThemeData(): Promise<boolean> { async refreshThemeData(): Promise<boolean> {
console.log("[MainController] 开始强制刷新主题数据"); logger.log("[MainController] 开始强制刷新主题数据");
try { try {
const reqData = {}; const reqData = {};
const res = await ThemeService.I.reqHallTheme(reqData); const res = await ThemeService.I.reqHallTheme(reqData);
@@ -178,14 +180,14 @@ export class MainController {
const themeData = DataManager.I.getDataById<ThemeData>(DataId.Theme); const themeData = DataManager.I.getDataById<ThemeData>(DataId.Theme);
themeData.themes = res.data; themeData.themes = res.data;
this.isThemeDataPreloaded = true; this.isThemeDataPreloaded = true;
console.log("[MainController] 主题数据刷新成功"); logger.log("[MainController] 主题数据刷新成功");
return true; return true;
} else { } else {
console.warn("[MainController] 主题数据刷新失败:", res); logger.warn("[MainController] 主题数据刷新失败:", res);
return false; return false;
} }
} catch (error) { } catch (error) {
console.error("[MainController] 主题数据刷新异常:", error); logger.error("[MainController] 主题数据刷新异常:", error);
return false; return false;
} }
} }
@@ -194,7 +196,7 @@ export class MainController {
* 强制刷新每日推荐数据 * 强制刷新每日推荐数据
*/ */
async refreshDailyRecommend(): Promise<boolean> { async refreshDailyRecommend(): Promise<boolean> {
console.log("[MainController] 开始强制刷新每日推荐数据"); logger.log("[MainController] 开始强制刷新每日推荐数据");
try { try {
const reqData = {}; const reqData = {};
const res = await GirlService.I.reqDailyRecommend(reqData); const res = await GirlService.I.reqDailyRecommend(reqData);
@@ -204,14 +206,14 @@ export class MainController {
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl); const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
girlData.setDailyRecommend(res.data); girlData.setDailyRecommend(res.data);
this.isDailyRecommendPreloaded = true; this.isDailyRecommendPreloaded = true;
console.log("[MainController] 每日推荐数据刷新成功"); logger.log("[MainController] 每日推荐数据刷新成功");
return true; return true;
} else { } else {
console.warn("[MainController] 每日推荐数据刷新失败:", res); logger.warn("[MainController] 每日推荐数据刷新失败:", res);
return false; return false;
} }
} catch (error) { } catch (error) {
console.error("[MainController] 每日推荐数据刷新异常:", error); logger.error("[MainController] 每日推荐数据刷新异常:", error);
return false; return false;
} }
} }
+15 -14
View File
@@ -3,6 +3,7 @@ import { Dialog } from "./DialogData";
import { ConfigManager } from "../manager/ConfigManager"; import { ConfigManager } from "../manager/ConfigManager";
import { DataId, DataManager } from "./DataManager"; import { DataId, DataManager } from "./DataManager";
import { GirlData } from "./GirlData"; import { GirlData } from "./GirlData";
import { logger } from "db://assets/Scripts/Main/Common/Logger";
/** /**
* 单个角色的聊天数据结构 * 单个角色的聊天数据结构
@@ -44,7 +45,7 @@ export class ChatModel {
*/ */
public initializeRole(categoryId: string, girlId: number): boolean { public initializeRole(categoryId: string, girlId: number): boolean {
if (girlId <= 0) { if (girlId <= 0) {
console.error("ChatModel: Invalid roleId provided"); logger.error("ChatModel: Invalid roleId provided");
return false; return false;
} }
@@ -52,7 +53,7 @@ export class ChatModel {
if (this.rolesData.has(girlId)) { if (this.rolesData.has(girlId)) {
this.currentGirlId = girlId; this.currentGirlId = girlId;
this.updateLastActiveTime(girlId); this.updateLastActiveTime(girlId);
console.log(`ChatModel: Switched to existing role ${girlId}`); logger.log(`ChatModel: Switched to existing role ${girlId}`);
return true; return true;
} }
@@ -64,7 +65,7 @@ export class ChatModel {
this.rolesData.set(girlId, newRoleData); this.rolesData.set(girlId, newRoleData);
this.currentGirlId = girlId; this.currentGirlId = girlId;
console.log(`ChatModel: Initialized new role ${girlId}`); logger.log(`ChatModel: Initialized new role ${girlId}`);
return true; return true;
} }
@@ -152,7 +153,7 @@ export class ChatModel {
if (oldestRoleId !== null) { if (oldestRoleId !== null) {
this.rolesData.delete(oldestRoleId); this.rolesData.delete(oldestRoleId);
console.log(`ChatModel: Cleaned up unused role ${oldestRoleId} data`); logger.log(`ChatModel: Cleaned up unused role ${oldestRoleId} data`);
} }
} }
@@ -238,7 +239,7 @@ export class ChatModel {
public clearDialogs(roleId?: number): void { public clearDialogs(roleId?: number): void {
const targetRoleId = roleId || this.currentGirlId; const targetRoleId = roleId || this.currentGirlId;
if (!targetRoleId) { if (!targetRoleId) {
console.warn("ChatModel: Cannot clear dialogs - no active role"); logger.warn("ChatModel: Cannot clear dialogs - no active role");
return; return;
} }
@@ -246,7 +247,7 @@ export class ChatModel {
if (roleData) { if (roleData) {
roleData.dialogs = []; roleData.dialogs = [];
this.updateLastActiveTime(targetRoleId); this.updateLastActiveTime(targetRoleId);
console.log(`ChatModel: Dialogs cleared for role ${targetRoleId}`); logger.log(`ChatModel: Dialogs cleared for role ${targetRoleId}`);
} }
} }
@@ -272,13 +273,13 @@ export class ChatModel {
public setCurrentEmotion(emotion: VideoEmotion, roleId?: number): void { public setCurrentEmotion(emotion: VideoEmotion, roleId?: number): void {
const targetRoleId = roleId || this.currentGirlId; const targetRoleId = roleId || this.currentGirlId;
if (!targetRoleId) { if (!targetRoleId) {
console.warn("ChatModel: Cannot set emotion - no active role"); logger.warn("ChatModel: Cannot set emotion - no active role");
return; return;
} }
const roleData = this.rolesData.get(targetRoleId); const roleData = this.rolesData.get(targetRoleId);
if (!roleData) { if (!roleData) {
console.warn(`ChatModel: Role data not found for roleId ${targetRoleId}`); logger.warn(`ChatModel: Role data not found for roleId ${targetRoleId}`);
return; return;
} }
@@ -286,7 +287,7 @@ export class ChatModel {
const oldEmotion = roleData.currentEmotion; const oldEmotion = roleData.currentEmotion;
roleData.currentEmotion = emotion; roleData.currentEmotion = emotion;
this.updateLastActiveTime(targetRoleId); this.updateLastActiveTime(targetRoleId);
console.log( logger.log(
`ChatModel: Role ${targetRoleId} emotion changed from ${VideoEmotion[oldEmotion]} to ${VideoEmotion[emotion]}` `ChatModel: Role ${targetRoleId} emotion changed from ${VideoEmotion[oldEmotion]} to ${VideoEmotion[emotion]}`
); );
} }
@@ -423,7 +424,7 @@ export class ChatModel {
public reset(): void { public reset(): void {
this.rolesData.clear(); this.rolesData.clear();
this.currentGirlId = null; this.currentGirlId = null;
console.log( logger.log(
"ChatModel: All role data cleared and model reset to initial state" "ChatModel: All role data cleared and model reset to initial state"
); );
} }
@@ -441,7 +442,7 @@ export class ChatModel {
this.currentGirlId = null; this.currentGirlId = null;
} }
console.log(`ChatModel: Role ${roleId} data cleared`); logger.log(`ChatModel: Role ${roleId} data cleared`);
} }
} }
@@ -452,13 +453,13 @@ export class ChatModel {
public validate(roleId?: number): boolean { public validate(roleId?: number): boolean {
const targetRoleId = roleId || this.currentGirlId; const targetRoleId = roleId || this.currentGirlId;
if (!targetRoleId) { if (!targetRoleId) {
console.error("ChatModel: No active role"); logger.error("ChatModel: No active role");
return false; return false;
} }
const roleData = this.rolesData.get(targetRoleId); const roleData = this.rolesData.get(targetRoleId);
if (!roleData) { if (!roleData) {
console.error(`ChatModel: Role data not found for ${targetRoleId}`); logger.error(`ChatModel: Role data not found for ${targetRoleId}`);
return false; return false;
} }
return true; return true;
@@ -500,7 +501,7 @@ export class ChatModel {
public setMaxCachedRoles(maxCount: number): void { public setMaxCachedRoles(maxCount: number): void {
if (maxCount > 0) { if (maxCount > 0) {
this.maxCachedRoles = maxCount; this.maxCachedRoles = maxCount;
console.log(`ChatModel: Max cached roles set to ${maxCount}`); logger.log(`ChatModel: Max cached roles set to ${maxCount}`);
// 如果当前缓存超过新限制,清理多余的 // 如果当前缓存超过新限制,清理多余的
this.manageMemory(); this.manageMemory();
+2 -1
View File
@@ -3,6 +3,7 @@
*/ */
import { BaseData } from "./BaseData"; import { BaseData } from "./BaseData";
import proto from 'db://assets/Scripts/proto/proto.pb.js'; import proto from 'db://assets/Scripts/proto/proto.pb.js';
import { logger } from "db://assets/Scripts/Main/Common/Logger";
export class ShopData extends BaseData { export class ShopData extends BaseData {
// 商品数据 // 商品数据
@@ -41,7 +42,7 @@ export class ShopData extends BaseData {
this._goods.set(vo.id, vo); this._goods.set(vo.id, vo);
this._goodIds.push(vo.id); this._goodIds.push(vo.id);
} }
console.log("设置商品数据:", this._goods); logger.log("设置商品数据:", this._goods);
} }
/** 获取所有商品数据 */ /** 获取所有商品数据 */
+2 -1
View File
@@ -3,6 +3,7 @@
*/ */
import { BaseData } from "./BaseData"; import { BaseData } from "./BaseData";
import proto from 'db://assets/Scripts/proto/proto.pb.js'; import proto from 'db://assets/Scripts/proto/proto.pb.js';
import { logger } from "db://assets/Scripts/Main/Common/Logger";
export class ThemeData extends BaseData { export class ThemeData extends BaseData {
// 主题数据 // 主题数据
@@ -43,7 +44,7 @@ export class ThemeData extends BaseData {
this._themes.set(vo.id, vo); this._themes.set(vo.id, vo);
this._themeIds.push(vo.id); this._themeIds.push(vo.id);
} }
console.log("设置主题数据:", this._themes); logger.log("设置主题数据:", this._themes);
} }
/** 获取所有主题数据 */ /** 获取所有主题数据 */
@@ -28,6 +28,7 @@ import { GirlData } from "../../data/GirlData";
import { GirlService } from "db://assets/Scripts/chat18x/network/services/GirlService"; import { GirlService } from "db://assets/Scripts/chat18x/network/services/GirlService";
import proto from "db://assets/Scripts/proto/proto.pb.js"; import proto from "db://assets/Scripts/proto/proto.pb.js";
import { SceneBgVideoLayer } from "../../../Sub/UI/SceneBgVideoLayer"; import { SceneBgVideoLayer } from "../../../Sub/UI/SceneBgVideoLayer";
import { logger } from "db://assets/Scripts/Main/Common/Logger";
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
@@ -106,18 +107,18 @@ export class GirlDetailPanel extends li_BaseView {
setVideEnable(enable: boolean) { setVideEnable(enable: boolean) {
if (!this.videoLayer) { if (!this.videoLayer) {
console.error("GirlDetailPanel: SceneBgVideoLayer 不可用"); logger.error("GirlDetailPanel: SceneBgVideoLayer 不可用");
return; return;
} }
if (enable) { if (enable) {
// 恢复播放 // 恢复播放
this.videoLayer.resume(); this.videoLayer.resume();
console.log("GirlDetailPanel: 开启视频播放"); logger.log("GirlDetailPanel: 开启视频播放");
} else { } else {
// 暂停播放 // 暂停播放
this.videoLayer.pause(); this.videoLayer.pause();
console.log("GirlDetailPanel: 暂停视频播放"); logger.log("GirlDetailPanel: 暂停视频播放");
} }
} }
@@ -159,9 +160,9 @@ export class GirlDetailPanel extends li_BaseView {
// 检查 SceneBgVideoLayer 是否可用 // 检查 SceneBgVideoLayer 是否可用
if (!this.videoLayer) { if (!this.videoLayer) {
console.error("GirlDetailPanel: SceneBgVideoLayer.handle 未初始化"); logger.error("GirlDetailPanel: SceneBgVideoLayer.handle 未初始化");
} else { } else {
console.log("GirlDetailPanel: 成功获取 SceneBgVideoLayer 实例"); logger.log("GirlDetailPanel: 成功获取 SceneBgVideoLayer 实例");
// 初始化视频显示位置 // 初始化视频显示位置
//this.initVideoPosition(); //this.initVideoPosition();
} }
@@ -191,7 +192,7 @@ export class GirlDetailPanel extends li_BaseView {
this.tags.string = desc; this.tags.string = desc;
const star = girlData.getStar(this.category.toString(), this.id); const star = girlData.getStar(this.category.toString(), this.id);
const stars = this.starParent.getComponentsInChildren(Sprite); const stars = this.starParent.getComponentsInChildren(Sprite);
console.log("好感度:" + star); logger.log("好感度:" + star);
for (let i = 0; i < stars.length; i++) { for (let i = 0; i < stars.length; i++) {
const element = stars[i]; const element = stars[i];
if (star > i) { if (star > i) {
@@ -215,7 +216,7 @@ export class GirlDetailPanel extends li_BaseView {
// 使用 SceneBgVideoLayer 加载并播放视频 // 使用 SceneBgVideoLayer 加载并播放视频
if (this.videoLayer && firstPath) { if (this.videoLayer && firstPath) {
console.log(`GirlDetailPanel: 加载视频 ${firstPath}`); logger.log(`GirlDetailPanel: 加载视频 ${firstPath}`);
// 获取 videoArea 的尺寸和位置 // 获取 videoArea 的尺寸和位置
const targetSize = this.videoArea const targetSize = this.videoArea
@@ -234,7 +235,7 @@ export class GirlDetailPanel extends li_BaseView {
this.videoLayer.getVideoPlayer().node.parent; this.videoLayer.getVideoPlayer().node.parent;
if (videoPlayerParent) { if (videoPlayerParent) {
const parentWorldPos = videoPlayerParent.getWorldPosition(); const parentWorldPos = videoPlayerParent.getWorldPosition();
console.log( logger.log(
`GirlDetailPanel: VideoPlayer 父节点世界位置: (${parentWorldPos.x}, ${parentWorldPos.y}, ${parentWorldPos.z})` `GirlDetailPanel: VideoPlayer 父节点世界位置: (${parentWorldPos.x}, ${parentWorldPos.y}, ${parentWorldPos.z})`
); );
} }
@@ -339,7 +340,7 @@ export class GirlDetailPanel extends li_BaseView {
// 停止视频播放,释放资源 // 停止视频播放,释放资源
if (this.videoLayer) { if (this.videoLayer) {
//this.videoLayer.stop(); //this.videoLayer.stop();
//console.log("GirlDetailPanel: 停止视频播放"); //logger.log("GirlDetailPanel: 停止视频播放");
} }
super.onClose(); super.onClose();
@@ -352,7 +353,7 @@ export class GirlDetailPanel extends li_BaseView {
// 确保视频资源被释放 // 确保视频资源被释放
if (this.videoLayer) { if (this.videoLayer) {
//this.videoLayer.stop(); //this.videoLayer.stop();
//console.log("GirlDetailPanel: 销毁时停止视频播放"); //logger.log("GirlDetailPanel: 销毁时停止视频播放");
} }
// 回收所有使用中的节点到对象池 // 回收所有使用中的节点到对象池
@@ -6,6 +6,7 @@ import { PastGirlListItem } from "../../uiitems/PastGirlListItem";
import { DataManager, DataId } from "../../data/DataManager"; import { DataManager, DataId } from "../../data/DataManager";
import { GirlData } from "../../data/GirlData"; import { GirlData } from "../../data/GirlData";
import { ChatHistoryManager } from "../../manager/ChatHistoryManager"; import { ChatHistoryManager } from "../../manager/ChatHistoryManager";
import { logger } from "db://assets/Scripts/Main/Common/Logger";
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
@@ -71,7 +72,7 @@ export class PastGirlListPanel extends li_BaseView {
private getUnlockedGirls(): number[] { private getUnlockedGirls(): number[] {
const GirlData = DataManager.I.getDataById<GirlData>(DataId.Girl); const GirlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
const allids = GirlData.getAllReleaseGirlIds(); const allids = GirlData.getAllReleaseGirlIds();
console.log(allids); logger.log(allids);
return allids; return allids;
} }
@@ -26,6 +26,7 @@ import {
} from "../../manager/NavigationManager"; } from "../../manager/NavigationManager";
import { PlayerDataService } from "../../network/services/PlayerDataService"; import { PlayerDataService } from "../../network/services/PlayerDataService";
import proto from "db://assets/Scripts/proto/proto.pb.js"; import proto from "db://assets/Scripts/proto/proto.pb.js";
import { logger } from "db://assets/Scripts/Main/Common/Logger";
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
@@ -91,7 +92,7 @@ export class PersonalPanel extends li_BaseView {
private async refresh() { private async refresh() {
const reqData = {}; const reqData = {};
let res = await PlayerDataService.I.reqMyInfo(reqData); let res = await PlayerDataService.I.reqMyInfo(reqData);
console.log("个人信息响应数据:", res); logger.log("个人信息响应数据:", res);
if (res && res.code === proto.cs.EnmRetCode.SUCCESS) { if (res && res.code === proto.cs.EnmRetCode.SUCCESS) {
const resData = res.data; const resData = res.data;
const walletData = DataManager.I.getDataById<WalletData>(DataId.Wallet); const walletData = DataManager.I.getDataById<WalletData>(DataId.Wallet);
@@ -22,6 +22,8 @@ import LanguageUtils from "../../../Main/Common/LanguageUtils";
import { ImagePopup } from "../components/ImagePopup"; import { ImagePopup } from "../components/ImagePopup";
import { TipsPanel } from "./TipsPanel"; import { TipsPanel } from "./TipsPanel";
import ResManager from "../../../Main/Manager/ResManager"; import ResManager from "../../../Main/Manager/ResManager";
import { logger } from "db://assets/Scripts/Main/Common/Logger";
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
@ccclass("PopupGirlDetailPanel") @ccclass("PopupGirlDetailPanel")
@@ -115,7 +117,7 @@ export class PopupGirlDetailPanel extends li_BaseView {
} }
async buyCharacter() { async buyCharacter() {
// 购买id为girlId的女生 // 购买id为girlId的女生
console.log(this.girlId + "---" + this.resId); logger.log(this.girlId + "---" + this.resId);
// 请求解锁 // 请求解锁
const reqData = { const reqData = {
@@ -124,7 +126,7 @@ export class PopupGirlDetailPanel extends li_BaseView {
type: this.type, type: this.type,
}; };
let res = await GirlService.I.reqUnlockGirlRes(reqData); let res = await GirlService.I.reqUnlockGirlRes(reqData);
console.log("请求解锁资源响应数据:", res); logger.log("请求解锁资源响应数据:", res);
if (res && res.code === proto.cs.EnmRetCode.SUCCESS) { if (res && res.code === proto.cs.EnmRetCode.SUCCESS) {
const resData = res.data; const resData = res.data;
// 保存数据 // 保存数据
@@ -15,6 +15,7 @@ import proto from "db://assets/Scripts/proto/proto.pb.js";
import { NavigationManager, PanelType } from "../../manager/NavigationManager"; import { NavigationManager, PanelType } from "../../manager/NavigationManager";
import { Web3PopPanel } from "./Web3PopPanel"; import { Web3PopPanel } from "./Web3PopPanel";
import { TipsPanel } from "./TipsPanel"; import { TipsPanel } from "./TipsPanel";
import { logger } from "db://assets/Scripts/Main/Common/Logger";
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
@@ -255,7 +256,7 @@ export class PurchasePanel extends li_BaseView {
girlId: 0, girlId: 0,
}; };
let res = await ShopService.I.reqBuyGood(reqData); let res = await ShopService.I.reqBuyGood(reqData);
console.log("请求使用余额购买商品的响应数据:", res); logger.log("请求使用余额购买商品的响应数据:", res);
if (res && res.code === proto.cs.EnmRetCode.SUCCESS) { if (res && res.code === proto.cs.EnmRetCode.SUCCESS) {
const resData = res.data; const resData = res.data;
// 保存数据 // 保存数据
@@ -276,16 +277,16 @@ export class PurchasePanel extends li_BaseView {
network, network,
}; };
let res = await PaymentService.I.startPayment(reqData); let res = await PaymentService.I.startPayment(reqData);
console.log("支付完成的响应数据:", res); logger.log("支付完成的响应数据:", res);
if (res) { if (res) {
let status = res.status; let status = res.status;
if (status === -1) { if (status === -1) {
console.log("支付失败!!!,错误码:", res.retCode); logger.log("支付失败!!!,错误码:", res.retCode);
const key = "error_code_" + res.retCode; const key = "error_code_" + res.retCode;
TipsPanel.show(LanguageUtils.getText(key)); TipsPanel.show(LanguageUtils.getText(key));
} else if (status === 0) { } else if (status === 0) {
console.log("支付成功!!!"); logger.log("支付成功!!!");
const walletData = DataManager.I.getDataById<WalletData>(DataId.Wallet); const walletData = DataManager.I.getDataById<WalletData>(DataId.Wallet);
walletData.balance = Number(res.balance); walletData.balance = Number(res.balance);
walletData.vipExpire = Number(res.vipExpire); walletData.vipExpire = Number(res.vipExpire);
@@ -22,6 +22,7 @@ import { ConfigManager } from "../../manager/ConfigManager";
import LanguageUtils from "../../../Main/Common/LanguageUtils"; import LanguageUtils from "../../../Main/Common/LanguageUtils";
import { Dialog } from "../../data/DialogData"; import { Dialog } from "../../data/DialogData";
import { InnerMsgCode } from "../../../Main/Config/InnerMsgCode"; import { InnerMsgCode } from "../../../Main/Config/InnerMsgCode";
import { logger } from "db://assets/Scripts/Main/Common/Logger";
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
@@ -132,7 +133,7 @@ export class RecordPanel extends li_BaseView {
this.allMessages = ChatHistoryManager.Instance.loadHistory(this.id); this.allMessages = ChatHistoryManager.Instance.loadHistory(this.id);
if (this.allMessages.length === 0) { if (this.allMessages.length === 0) {
console.log(`No chat history found for role ${this.id}`); logger.log(`No chat history found for role ${this.id}`);
this.updateLoadMoreBtn(); this.updateLoadMoreBtn();
return; return;
} }
@@ -170,7 +171,7 @@ export class RecordPanel extends li_BaseView {
// 添加到已显示的消息列表 // 添加到已显示的消息列表
this.displayedMessages.push(...newDialogs); this.displayedMessages.push(...newDialogs);
console.log( logger.log(
`Loaded page ${this.currentPage + 1}, showing ${ `Loaded page ${this.currentPage + 1}, showing ${
this.displayedMessages.length this.displayedMessages.length
}/${this.allMessages.length} messages` }/${this.allMessages.length} messages`
@@ -234,7 +235,7 @@ export class RecordPanel extends li_BaseView {
*/ */
public clearHistory() { public clearHistory() {
ChatHistoryManager.Instance.clearHistory(this.id); ChatHistoryManager.Instance.clearHistory(this.id);
console.log(`Cleared chat history for role ${this.id}`); logger.log(`Cleared chat history for role ${this.id}`);
// 重置数据 // 重置数据
this.allMessages = []; this.allMessages = [];