日志控制

This commit is contained in:
chen wei bo
2025-09-21 20:18:30 +08:00
parent 23c038fd14
commit 8f90c1d7cf
23 changed files with 207 additions and 178 deletions
+32 -30
View File
@@ -34,6 +34,8 @@ import { NavigationManager, PanelType } from "../../manager/NavigationManager";
import { GirlService } from "../../network/services/GirlService";
import proto from "db://assets/Scripts/proto/proto.pb.js";
import { TipsPanel } from "./TipsPanel";
import { logger } from "db://assets/Scripts/Main/Common/Logger";
const { ccclass, property } = _decorator;
@ccclass("ChatPanel")
@@ -110,9 +112,9 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
// 检查 SceneBgVideoLayer 是否可用
if (!this.videoLayer) {
console.error("ChatPanel: SceneBgVideoLayer.handle 未初始化");
logger.error("ChatPanel: SceneBgVideoLayer.handle 未初始化");
} else {
console.log("ChatPanel: 成功获取 SceneBgVideoLayer 实例");
logger.log("ChatPanel: 成功获取 SceneBgVideoLayer 实例");
}
this.popUpImage.node.active = false;
}
@@ -199,7 +201,7 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
this.chatController.hasRoleData(this.categoryId, this.id)
) {
// 如果是角色切换且有缓存数据,使用switchRole
console.log(
logger.log(
`ChatPanel: Switching from role ${this.chatController.getCurrentRoleId()} to role ${
this.id
}`
@@ -207,7 +209,7 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
this.chatController.switchRole(this.categoryId, this.id);
} else {
// 首次初始化或没有缓存数据,使用initialize
console.log(`ChatPanel: Initializing role ${this.id}`);
logger.log(`ChatPanel: Initializing role ${this.id}`);
this.chatController.initialize(this.categoryId, this.id);
}
}
@@ -234,7 +236,7 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
if (this.videoLayer) {
// Get current emotion from ChatController
const currentEmotion = this.chatController.getCurrentEmotion();
console.log(
logger.log(
`Current emotion for role ${this.id}: ${VideoEmotion[currentEmotion]}`
);
@@ -244,7 +246,7 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
chatModel.getDefaultVideo();
if (initialVideo) {
console.log(
logger.log(
`Loading initial video: ${initialVideo} (emotion: ${VideoEmotion[initialVideo]})`
);
@@ -263,7 +265,7 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
}
} else {
this.currentEmotion = null; // Reset current emotion when no videos available
console.log("No SceneBgVideoLayer available for role", this.id);
logger.log("No SceneBgVideoLayer available for role", this.id);
}
}
@@ -272,35 +274,35 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
* 保留此方法仅为了兼容性,但不再主动调用
*/
adjustVideoScale() {
console.log(
logger.log(
"ChatPanel: adjustVideoScale() 方法已废弃,缩放和位置由 playVideo() 自动处理"
);
// 如果确实需要手动调整,可以重新调用 playVideo
// this.videoLayer.playVideo(currentVideo, { size, position });
}
onChatCountChange() {
console.log("Trigger On ChatCount Change");
logger.log("Trigger On ChatCount Change");
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
let triggerId = girlData.getTriggerGrilPhotoId(this.categoryId, this.id);
if (triggerId == 0) return;
console.log("Trigger pop up Image id:" + this.id + "--" + triggerId);
logger.log("Trigger pop up Image id:" + this.id + "--" + triggerId);
this.popUpImage.refresh(this.categoryId, this.id, triggerId);
}
setVideoEnable(enable: boolean) {
if (!this.videoLayer) {
console.error("ChatPanel: SceneBgVideoLayer 不可用");
logger.error("ChatPanel: SceneBgVideoLayer 不可用");
return;
}
if (enable) {
this.videoLayer.resume();
console.log("ChatPanel: 恢复视频播放");
logger.log("ChatPanel: 恢复视频播放");
} else {
this.videoLayer.pause();
console.log("ChatPanel: 暂停视频播放");
logger.log("ChatPanel: 暂停视频播放");
}
}
@@ -314,7 +316,7 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
// Check if emotion has changed
if (this.currentEmotion === emotion) {
console.log(
logger.log(
`Emotion ${VideoEmotion[emotion]} unchanged, skipping video switch`
);
return;
@@ -324,7 +326,7 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
const matchingVideo = chatModel.getVideoByEmotion(emotion);
if (matchingVideo) {
console.log(
logger.log(
`Switching to video for emotion ${
VideoEmotion[emotion]
}: ${matchingVideo} (from ${
@@ -346,14 +348,14 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
// 注意:移除了 adjustVideoScale() 调用,因为 playVideo 现在会自动处理缩放和位置
this.setVideoEnable(true);
} else {
console.warn(
logger.warn(
`No video found for emotion ${VideoEmotion[emotion]}, falling back to default video`
);
// Fallback to default video from ChatModel
const fallbackVideo = chatModel.getDefaultVideo();
if (fallbackVideo) {
console.log(
logger.log(
`Loading fallback video: ${fallbackVideo} (emotion: ${VideoEmotion[fallbackVideo]})`
);
@@ -378,7 +380,7 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
}): void {
// 检查是否是当前角色
if (data.roleId === this.id) {
console.log(
logger.log(
`Emotion initialized for current role ${this.id}: ${
VideoEmotion[data.emotion]
}`
@@ -387,7 +389,7 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
// 切换到对应的视频
this.switchVideoByEmotion(data.emotion);
} else {
console.log(
logger.log(
`Emotion initialized for role ${data.roleId} (not current role ${this.id}), ignoring`
);
}
@@ -444,7 +446,7 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
* @param message 用户发送的消息
*/
public onMessageSent(message: string): void {
console.log("Message sent:", message);
logger.log("Message sent:", message);
// 消息发送后开始显示加载动画,由DialogManager处理
}
@@ -453,7 +455,7 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
* @param response AI的回复内容
*/
public onMessageReceived(response: string): void {
//console.log("Message received:", response);
//logger.log("Message received:", response);
// AI回复收到后加载动画会被自动移除,可以在这里添加其他UI效果
}
@@ -483,7 +485,7 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
* @param emotion 当前情绪状态
*/
public onEmotionUpdated(emotion: VideoEmotion): void {
console.log(
logger.log(
`ChatPanel: Emotion updated to ${VideoEmotion[emotion]} (${emotion})`
);
@@ -495,23 +497,23 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
switch (emotion) {
case VideoEmotion.calm_down:
// 平静状态的UI更新
console.log("UI state: Calm");
logger.log("UI state: Calm");
break;
case VideoEmotion.arousal:
// 兴奋状态的UI更新
console.log("UI state: Arousal");
logger.log("UI state: Arousal");
break;
case VideoEmotion.desire:
// 渴望状态的UI更新
console.log("UI state: Desire");
logger.log("UI state: Desire");
break;
case VideoEmotion.passion:
// 激情状态的UI更新
console.log("UI state: Passion");
logger.log("UI state: Passion");
break;
case VideoEmotion.orgasm:
// 高潮状态的UI更新
console.log("UI state: Orgasm");
logger.log("UI state: Orgasm");
break;
}
}
@@ -529,17 +531,17 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
*/
public clearRoleDataDebug(roleId?: number): void {
if (!this.chatController) {
console.warn("ChatController not initialized");
logger.warn("ChatController not initialized");
return;
}
const targetRoleId = roleId || this.id;
if (!targetRoleId) {
console.warn("No role ID specified");
logger.warn("No role ID specified");
return;
}
this.chatController.clearRoleData(targetRoleId);
console.log(`Cleared data for role ${targetRoleId}`);
logger.log(`Cleared data for role ${targetRoleId}`);
}
}
@@ -26,6 +26,8 @@ import { ViewManager } from "../../../Main/Manager/ViewManager";
import { TipsPanel } from "./TipsPanel";
import ResManager from "../../../Main/Manager/ResManager";
import { InnerMsgCode } from "../../../Main/Config/InnerMsgCode";
import { logger } from "db://assets/Scripts/Main/Common/Logger";
const { ccclass, property } = _decorator;
@ccclass("GirlListPopupPanel")
@@ -79,7 +81,7 @@ export class GirlListPopupPanel extends li_BaseView {
const path = girlData.getGrilAvatar(this.category.toString(), this.girlId);
this.refreshCoinNum();
//console.log(path);
//logger.log(path);
// 加载远程资源
const envData = DataManager.I.getDataById<EnvData>(DataId.Env);
let newPath = envData.cdn + "/" + "Girls/" + path + ".png";
@@ -101,13 +103,13 @@ export class GirlListPopupPanel extends li_BaseView {
}
async buyCharacter() {
// 购买id为girlId的女生
console.log(this.girlId);
logger.log(this.girlId);
// 请求解锁
const reqData = {
id: this.girlId,
};
let res = await GirlService.I.reqUnlockGirl(reqData);
console.log("请求解锁技师响应数据:", res);
logger.log("请求解锁技师响应数据:", res);
if (res && res.code === proto.cs.EnmRetCode.SUCCESS) {
const resData = res.data;
// 保存数据
@@ -6,6 +6,7 @@ import { NavigationManager, PanelType } from "../../manager/NavigationManager";
import { NavigationBtn } from "../items/NavigationBtn";
import { ChatHistoryManager } from "../../manager/ChatHistoryManager";
import { PastGirlListPanel } from "./PastGirlListPanel";
import { logger } from "db://assets/Scripts/Main/Common/Logger";
const { ccclass, property } = _decorator;
@@ -101,7 +102,7 @@ export class NavigationPanel extends li_BaseView {
private refreshButtonVisuals() {
// TODO: 实现按钮状态更新的视觉效果
// 根据 currentActivePanel 更新按钮的选中状态
console.log(
logger.log(
"[NavigationPanel] Button states updated for:",
this.currentActivePanel
);
@@ -17,6 +17,8 @@ import proto from "db://assets/Scripts/proto/proto.pb.js";
import { ConfigId, ConfigManager } from "../../manager/ConfigManager";
import { PurchaseConfig } from "../../config/PurchaseConfig";
import LanguageUtils from "../../../Main/Common/LanguageUtils";
import { logger } from "db://assets/Scripts/Main/Common/Logger";
const { ccclass, property } = _decorator;
@ccclass("PayToTalkSubpanel")
@@ -76,7 +78,7 @@ export class PayToTalkSubpanel extends Component {
//ChatController.Instance.resetChatCount();
const shopData = DataManager.I.getDataById<ShopData>(DataId.Shop);
const chatIds = shopData.getChatIds();
console.log("聊天商品Id: ", chatIds);
logger.log("聊天商品Id: ", chatIds);
if (chatIds.length > 0) {
this.reqBuyGood(chatIds[0], this.girlId);
}
@@ -84,7 +86,7 @@ export class PayToTalkSubpanel extends Component {
onClick_BuyVip() {
//购买VIP
console.log("购买vip");
logger.log("购买vip");
const shopData = DataManager.I.getDataById<ShopData>(DataId.Shop);
const memberId = shopData.get7DayMemberId();
this.reqBuyGood(memberId, this.girlId);
@@ -98,7 +100,7 @@ export class PayToTalkSubpanel extends Component {
girlId: girlId,
};
let res = await ShopService.I.reqBuyGood(reqData);
console.log("请求使用余额购买商品的响应数据:", res);
logger.log("请求使用余额购买商品的响应数据:", res);
if (res && res.code === proto.cs.EnmRetCode.SUCCESS) {
const resData = res.data;
// 保存数据
@@ -18,6 +18,8 @@ import { GButton } from "db://assets/Scripts/Main/Common/GButton";
import { SceneBgVideoLayer } from "../../../Sub/UI/SceneBgVideoLayer";
import { DataManager, DataId } from "../../data/DataManager";
import { EnvData } from "../../data/EnvData";
import { logger } from "db://assets/Scripts/Main/Common/Logger";
const { ccclass, property } = _decorator;
interface ShowPanelData {
@@ -139,7 +141,7 @@ export class ShowPanel extends li_BaseView {
const scale = Math.max(scaleX, scaleY); // 填满整个区域
this.videoPlayer.node.setScale(new Vec3(scale, scale, 1));
console.log(`ShowPanel: 调整视频缩放到 ${scale}`);
logger.log(`ShowPanel: 调整视频缩放到 ${scale}`);
}
}
}
+18 -17
View File
@@ -35,6 +35,7 @@ import proto from "db://assets/Scripts/proto/proto.pb.js";
import GameRootUI from "../../../Main/Common/GameRootUI";
import { MainController } from "../../core/MainController";
import { GirlListPanel } from "./GirlListPanel";
import { logger } from "db://assets/Scripts/Main/Common/Logger";
const { ccclass, property } = _decorator;
@@ -79,7 +80,7 @@ export class ThemePanel extends li_BaseView {
async Show(forceRefresh: boolean = false) {
// 防止重复加载
if (this.isLoading) {
console.log("[ThemePanel] 已在加载中,等待当前加载完成");
logger.log("[ThemePanel] 已在加载中,等待当前加载完成");
if (this.loadingPromise) {
await this.loadingPromise;
}
@@ -123,12 +124,12 @@ export class ThemePanel extends li_BaseView {
// 如果需要强制刷新,先刷新数据
if (forceRefresh) {
console.log("[ThemePanel] 开始强制刷新数据");
logger.log("[ThemePanel] 开始强制刷新数据");
await Promise.all([
MainController.I.refreshThemeData(),
MainController.I.refreshDailyRecommend(),
]);
console.log("[ThemePanel] 数据刷新完成");
logger.log("[ThemePanel] 数据刷新完成");
// 再次检查是否已被取消
if (signal.aborted) {
@@ -138,7 +139,7 @@ export class ThemePanel extends li_BaseView {
// 优先使用MainController中预加载的数据
const preloadStatus = MainController.I.getPreloadStatus();
console.log("[ThemePanel] 预加载状态:", preloadStatus);
logger.log("[ThemePanel] 预加载状态:", preloadStatus);
// 处理主题数据
await this.handleThemeData(preloadStatus.themeData);
@@ -161,13 +162,13 @@ export class ThemePanel extends li_BaseView {
// 处理商品列表数据
await this.handleShopListData(preloadStatus.shopList);
} catch (error) {
console.error("[ThemePanel] Show操作出错:", error);
logger.error("[ThemePanel] Show操作出错:", error);
this._nodeTab.loadingRec.active = false;
// 如果不是取消操作导致的错误,可以考虑显示错误提示
if (error.message !== "Operation was aborted") {
// 这里可以添加错误提示逻辑
console.error("[ThemePanel] 数据加载失败,请稍后重试");
logger.error("[ThemePanel] 数据加载失败,请稍后重试");
}
} finally {
this.abortController = null;
@@ -179,7 +180,7 @@ export class ThemePanel extends li_BaseView {
*/
private async handleThemeData(isPreloaded: boolean): Promise<void> {
if (isPreloaded) {
console.log("[ThemePanel] 使用预加载的主题数据");
logger.log("[ThemePanel] 使用预加载的主题数据");
// 直接使用预加载的数据渲染界面
const themeData = DataManager.I.getDataById<ThemeData>(DataId.Theme);
if (themeData && themeData.themes) {
@@ -189,7 +190,7 @@ export class ThemePanel extends li_BaseView {
}
// 如果没有预加载数据,则请求数据
console.log("[ThemePanel] 请求主题数据");
logger.log("[ThemePanel] 请求主题数据");
const reqData = {};
let res = await ThemeService.I.reqHallTheme(reqData);
if (res && res.code === proto.cs.EnmRetCode.SUCCESS) {
@@ -220,7 +221,7 @@ export class ThemePanel extends li_BaseView {
*/
private async handleDailyRecommendData(isPreloaded: boolean): Promise<void> {
if (isPreloaded) {
console.log("[ThemePanel] 使用预加载的每日推荐数据");
logger.log("[ThemePanel] 使用预加载的每日推荐数据");
// 直接使用预加载的数据渲染界面
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
if (girlData) {
@@ -230,7 +231,7 @@ export class ThemePanel extends li_BaseView {
}
// 如果没有预加载数据,则请求数据
console.log("[ThemePanel] 请求每日推荐数据");
logger.log("[ThemePanel] 请求每日推荐数据");
const reqData = {};
let res = await GirlService.I.reqDailyRecommend(reqData);
if (res && res.code === proto.cs.EnmRetCode.SUCCESS) {
@@ -266,13 +267,13 @@ export class ThemePanel extends li_BaseView {
*/
private async handleShopListData(isPreloaded: boolean): Promise<void> {
if (isPreloaded) {
console.log("[ThemePanel] 商品列表数据已预加载");
logger.log("[ThemePanel] 商品列表数据已预加载");
// 数据已经在DataManager中,不需要额外处理
return;
}
// 如果没有预加载数据,则请求数据
console.log("[ThemePanel] 请求商品列表数据");
logger.log("[ThemePanel] 请求商品列表数据");
await this.reqShopList();
}
@@ -336,7 +337,7 @@ export class ThemePanel extends li_BaseView {
}
openMsgBox() {
console.log("打开信箱");
logger.log("打开信箱");
}
// 刷新余额
@@ -380,7 +381,7 @@ export class ThemePanel extends li_BaseView {
*/
private clearCache(): void {
if (this.cache && this.cache.length > 0) {
console.log(`[ThemePanel] 清理 ${this.cache.length} 个缓存节点`);
logger.log(`[ThemePanel] 清理 ${this.cache.length} 个缓存节点`);
for (let i = this.cache.length - 1; i >= 0; i--) {
if (this.cache[i] && this.cache[i].node && this.cache[i].node.isValid) {
this.cache[i].node.destroy();
@@ -394,7 +395,7 @@ export class ThemePanel extends li_BaseView {
* 页面被隐藏时调用
*/
public onHide(): void {
console.log("[ThemePanel] onHide called");
logger.log("[ThemePanel] onHide called");
this.cancelCurrentOperation();
}
@@ -403,14 +404,14 @@ export class ThemePanel extends li_BaseView {
*/
private cancelCurrentOperation(): void {
if (this.abortController) {
console.log("[ThemePanel] 取消当前操作");
logger.log("[ThemePanel] 取消当前操作");
this.abortController.abort();
this.abortController = null;
}
}
onDestroy(): void {
console.log("[ThemePanel] onDestroy called");
logger.log("[ThemePanel] onDestroy called");
// 取消当前操作
this.cancelCurrentOperation();
@@ -11,6 +11,7 @@ import { QRCodeGenerator } from "db://assets/utils/qrcodeGenerator";
import { TipsPanel } from "./TipsPanel";
import { SDKManager } from "../../../Main/Channel/SDKManager";
import LanguageUtils from "../../../Main/Common/LanguageUtils";
import { logger } from "db://assets/Scripts/Main/Common/Logger";
const { ccclass, property } = _decorator;
@@ -326,7 +327,7 @@ export class Web3PopPanel extends li_BaseView {
}
private onCountdownExpired(): void {
console.log("Web3支付倒计时已过期");
logger.log("Web3支付倒计时已过期");
this.disableButtons();
TipsPanel.show("支付时间已过期,请重新发起支付");
}