日志控制
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
import { _decorator, Component, Node, tween, UIOpacity, Vec3, VideoPlayer } from 'cc';
|
import { _decorator, Component, Node, tween, UIOpacity, Vec3, VideoPlayer } from 'cc';
|
||||||
import Utils from '../Common/Utils';
|
import Utils from '../Common/Utils';
|
||||||
import { VideoRoleType } from '../Common/GlobalValue';
|
import { VideoRoleType } from '../Common/GlobalValue';
|
||||||
|
import { logger } from "db://assets/Scripts/Main/Common/Logger";
|
||||||
|
|
||||||
const { ccclass, property } = _decorator;
|
const { ccclass, property } = _decorator;
|
||||||
|
|
||||||
/**背景视频 */
|
/**背景视频 */
|
||||||
@@ -49,14 +51,14 @@ export class BgVideo extends Component {
|
|||||||
|
|
||||||
update(deltaTime: number) {
|
update(deltaTime: number) {
|
||||||
// if (this._isPlaying && this.vtype == VideoRoleType.Idle) {
|
// if (this._isPlaying && this.vtype == VideoRoleType.Idle) {
|
||||||
// console.log("BgVideo 主视频时长:", this.vp.currentTime, this.vp.duration);
|
// logger.log("BgVideo 主视频时长:", this.vp.currentTime, this.vp.duration);
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**播放视频 */
|
/**播放视频 */
|
||||||
playVideo(remoteUrl:string, loop:boolean = false, autoIn:boolean = true) {
|
playVideo(remoteUrl:string, loop:boolean = false, autoIn:boolean = true) {
|
||||||
console.log("BgVideo 播放视频:", this.node.position)
|
logger.log("BgVideo 播放视频:", this.node.position)
|
||||||
this.vp.remoteURL = remoteUrl
|
this.vp.remoteURL = remoteUrl
|
||||||
this.vp.loop = loop
|
this.vp.loop = loop
|
||||||
this.vp.stop()
|
this.vp.stop()
|
||||||
@@ -69,7 +71,7 @@ export class BgVideo extends Component {
|
|||||||
|
|
||||||
/**暂停视频 */
|
/**暂停视频 */
|
||||||
pauseVideo() {
|
pauseVideo() {
|
||||||
console.log("BgVideo 暂停视频:", this._vtype)
|
logger.log("BgVideo 暂停视频:", this._vtype)
|
||||||
this.vp.pause()
|
this.vp.pause()
|
||||||
}
|
}
|
||||||
/**继续播放 */
|
/**继续播放 */
|
||||||
@@ -99,7 +101,7 @@ export class BgVideo extends Component {
|
|||||||
|
|
||||||
|
|
||||||
onVideoEvent(event1:any, event2:any) {
|
onVideoEvent(event1:any, event2:any) {
|
||||||
// console.log("bgvideo BgVideo组件 event", event2, this._vtype)
|
// logger.log("bgvideo BgVideo组件 event", event2, this._vtype)
|
||||||
if (event2 == "ready-to-play") {
|
if (event2 == "ready-to-play") {
|
||||||
// if (!this._emoShow) {
|
// if (!this._emoShow) {
|
||||||
// this._emoShow = true;
|
// this._emoShow = true;
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import { _decorator, Component, EditBox, Label, macro, Node, view } from 'cc';
|
import { _decorator, Component, EditBox, Label, macro, Node, view } from 'cc';
|
||||||
import GameRootUI from './GameRootUI';
|
import GameRootUI from './GameRootUI';
|
||||||
|
import { logger } from "db://assets/Scripts/Main/Common/Logger";
|
||||||
|
|
||||||
const { ccclass, property, requireComponent } = _decorator;
|
const { ccclass, property, requireComponent } = _decorator;
|
||||||
|
|
||||||
//输入框事件监听
|
//输入框事件监听
|
||||||
@@ -18,7 +20,7 @@ export class EditBoxEvent extends Component {
|
|||||||
this.node.on(EditBox.EventType.EDITING_DID_BEGAN, this.onEditDidBegan, this);
|
this.node.on(EditBox.EventType.EDITING_DID_BEGAN, this.onEditDidBegan, this);
|
||||||
this.node.on(EditBox.EventType.EDITING_DID_ENDED, this.onEditDidEnded, this);
|
this.node.on(EditBox.EventType.EDITING_DID_ENDED, this.onEditDidEnded, this);
|
||||||
this.node.on(EditBox.EventType.EDITING_RETURN, this.onEditingReturn, this);
|
this.node.on(EditBox.EventType.EDITING_RETURN, this.onEditingReturn, this);
|
||||||
console.log("EditBoxEvent: start.")
|
logger.log("EditBoxEvent: start.")
|
||||||
}
|
}
|
||||||
|
|
||||||
update(deltaTime: number) {
|
update(deltaTime: number) {
|
||||||
@@ -27,20 +29,20 @@ export class EditBoxEvent extends Component {
|
|||||||
|
|
||||||
|
|
||||||
onEditDidBegan(editbox, customEventData) {
|
onEditDidBegan(editbox, customEventData) {
|
||||||
console.log("EditBoxEvent: 开始编辑...")
|
logger.log("EditBoxEvent: 开始编辑...")
|
||||||
// view.setOrientation(macro.ORIENTATION_LANDSCAPE); //设置横屏
|
// view.setOrientation(macro.ORIENTATION_LANDSCAPE); //设置横屏
|
||||||
// console.log("窗口大小 开始:", view.getVisibleSize(), GameRootUI.MainCamera)
|
// logger.log("窗口大小 开始:", view.getVisibleSize(), GameRootUI.MainCamera)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onEditDidEnded(editbox, customEventData) {
|
onEditDidEnded(editbox, customEventData) {
|
||||||
console.log("EditBoxEvent: 结束编辑.")
|
logger.log("EditBoxEvent: 结束编辑.")
|
||||||
// view.setOrientation(macro.ORIENTATION_LANDSCAPE); //设置横屏
|
// view.setOrientation(macro.ORIENTATION_LANDSCAPE); //设置横屏
|
||||||
// console.log("窗口大小 结束:", view.getVisibleSize(), GameRootUI.MainCamera)
|
// logger.log("窗口大小 结束:", view.getVisibleSize(), GameRootUI.MainCamera)
|
||||||
}
|
}
|
||||||
|
|
||||||
onEditingReturn(editbox, customEventData) {
|
onEditingReturn(editbox, customEventData) {
|
||||||
console.log("EditBoxEvent: 按下返回.")
|
logger.log("EditBoxEvent: 按下返回.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { DataManager, DataId } from "../data/DataManager";
|
|||||||
import { GirlData } from "../data/GirlData";
|
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 { ChatService } from "../network/services/ChatService";
|
import { ChatService } from "../network/services/ChatService";
|
||||||
|
import { logger } from "db://assets/Scripts/Main/Common/Logger";
|
||||||
|
|
||||||
export interface ChatMessage {
|
export interface ChatMessage {
|
||||||
role: "user" | "model";
|
role: "user" | "model";
|
||||||
@@ -49,7 +50,7 @@ export class ChatHistoryManager {
|
|||||||
const existingHistory: ChatHistory = JSON.parse(existingData);
|
const existingHistory: ChatHistory = JSON.parse(existingData);
|
||||||
createdAt = existingHistory.createdAt;
|
createdAt = existingHistory.createdAt;
|
||||||
} catch (parseError) {
|
} catch (parseError) {
|
||||||
console.warn(`Failed to parse existing history for role ${roleId}, using current time as createdAt`);
|
logger.warn(`Failed to parse existing history for role ${roleId}, using current time as createdAt`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,11 +62,11 @@ export class ChatHistoryManager {
|
|||||||
};
|
};
|
||||||
|
|
||||||
sys.localStorage.setItem(key, JSON.stringify(history));
|
sys.localStorage.setItem(key, JSON.stringify(history));
|
||||||
console.log(
|
logger.log(
|
||||||
`Saved chat history for role ${roleId}, ${messages.length} messages`
|
`Saved chat history for role ${roleId}, ${messages.length} messages`
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Failed to save chat history for role ${roleId}:`, error);
|
logger.error(`Failed to save chat history for role ${roleId}:`, error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,13 +81,13 @@ export class ChatHistoryManager {
|
|||||||
const data = sys.localStorage.getItem(key);
|
const data = sys.localStorage.getItem(key);
|
||||||
if (data) {
|
if (data) {
|
||||||
const history: ChatHistory = JSON.parse(data);
|
const history: ChatHistory = JSON.parse(data);
|
||||||
console.log(
|
logger.log(
|
||||||
`Loaded chat history for role ${roleId}: ${history.messages.length} messages`
|
`Loaded chat history for role ${roleId}: ${history.messages.length} messages`
|
||||||
);
|
);
|
||||||
return history.messages;
|
return history.messages;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Failed to load chat history for role ${roleId}:`, error);
|
logger.error(`Failed to load chat history for role ${roleId}:`, error);
|
||||||
// 如果数据损坏,清除错误的数据
|
// 如果数据损坏,清除错误的数据
|
||||||
this.clearHistory(roleId);
|
this.clearHistory(roleId);
|
||||||
}
|
}
|
||||||
@@ -100,7 +101,7 @@ export class ChatHistoryManager {
|
|||||||
public clearHistory(roleId: number): void {
|
public clearHistory(roleId: number): void {
|
||||||
const key = `chat_history_${roleId}`;
|
const key = `chat_history_${roleId}`;
|
||||||
sys.localStorage.removeItem(key);
|
sys.localStorage.removeItem(key);
|
||||||
console.log(`Cleared chat history for role ${roleId}`);
|
logger.log(`Cleared chat history for role ${roleId}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -118,7 +119,7 @@ export class ChatHistoryManager {
|
|||||||
// 限制历史长度,保留最近100条消息
|
// 限制历史长度,保留最近100条消息
|
||||||
if (history.length > 100) {
|
if (history.length > 100) {
|
||||||
history.splice(0, history.length - 100);
|
history.splice(0, history.length - 100);
|
||||||
console.log(`Trimmed chat history for role ${roleId} to 100 messages`);
|
logger.log(`Trimmed chat history for role ${roleId} to 100 messages`);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.saveHistory(roleId, history);
|
this.saveHistory(roleId, history);
|
||||||
@@ -163,7 +164,7 @@ export class ChatHistoryManager {
|
|||||||
sys.localStorage.removeItem(key);
|
sys.localStorage.removeItem(key);
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(
|
logger.log(
|
||||||
`Cleared all chat histories, ${keysToRemove.length} records removed`
|
`Cleared all chat histories, ${keysToRemove.length} records removed`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -193,7 +194,7 @@ export class ChatHistoryManager {
|
|||||||
public async syncToRemote(roleId: number): Promise<void> {
|
public async syncToRemote(roleId: number): Promise<void> {
|
||||||
const history = this.loadHistory(roleId);
|
const history = this.loadHistory(roleId);
|
||||||
if (history.length === 0) {
|
if (history.length === 0) {
|
||||||
console.log(`No history to sync for role ${roleId}`);
|
logger.log(`No history to sync for role ${roleId}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,11 +205,11 @@ export class ChatHistoryManager {
|
|||||||
// messages: history
|
// messages: history
|
||||||
// }, "POST");
|
// }, "POST");
|
||||||
|
|
||||||
console.log(
|
logger.log(
|
||||||
`Ready to sync ${history.length} messages for role ${roleId} to remote server`
|
`Ready to sync ${history.length} messages for role ${roleId} to remote server`
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Failed to sync history for role ${roleId}:`, error);
|
logger.error(`Failed to sync history for role ${roleId}:`, error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,7 +233,7 @@ export class ChatHistoryManager {
|
|||||||
return history.createdAt;
|
return history.createdAt;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Failed to get last chat time for role ${roleId}:`, error);
|
logger.error(`Failed to get last chat time for role ${roleId}:`, error);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -250,14 +251,14 @@ export class ChatHistoryManager {
|
|||||||
|
|
||||||
// if (response && response.messages) {
|
// if (response && response.messages) {
|
||||||
// this.saveHistory(roleId, response.messages);
|
// this.saveHistory(roleId, response.messages);
|
||||||
// console.log(`Synced ${response.messages.length} messages from remote for role ${roleId}`);
|
// logger.log(`Synced ${response.messages.length} messages from remote for role ${roleId}`);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
console.log(
|
logger.log(
|
||||||
`Ready to sync history from remote server for role ${roleId}`
|
`Ready to sync history from remote server for role ${roleId}`
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Failed to sync from remote for role ${roleId}:`, error);
|
logger.error(`Failed to sync from remote for role ${roleId}:`, error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -288,7 +289,7 @@ export class ChatHistoryManager {
|
|||||||
// 按时间戳排序,确保消息顺序正确
|
// 按时间戳排序,确保消息顺序正确
|
||||||
messages.sort((a, b) => (a.timestamp || 0) - (b.timestamp || 0));
|
messages.sort((a, b) => (a.timestamp || 0) - (b.timestamp || 0));
|
||||||
|
|
||||||
console.log(
|
logger.log(
|
||||||
`Converted ${serverMessages.length} server messages to ${messages.length} local messages`
|
`Converted ${serverMessages.length} server messages to ${messages.length} local messages`
|
||||||
);
|
);
|
||||||
return messages;
|
return messages;
|
||||||
@@ -313,7 +314,7 @@ export class ChatHistoryManager {
|
|||||||
limit,
|
limit,
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log("获取服务端聊天记录:", reqData);
|
logger.log("获取服务端聊天记录:", reqData);
|
||||||
const res = await ChatService.I.reqGetChatMsg(reqData);
|
const res = await ChatService.I.reqGetChatMsg(reqData);
|
||||||
|
|
||||||
if (res && res.code === proto.cs.EnmRetCode.SUCCESS) {
|
if (res && res.code === proto.cs.EnmRetCode.SUCCESS) {
|
||||||
@@ -333,20 +334,20 @@ export class ChatHistoryManager {
|
|||||||
resData.chatRemainCount
|
resData.chatRemainCount
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log(
|
logger.log(
|
||||||
`成功从服务端获取聊天记录,roleId: ${roleId}, 消息数: ${
|
`成功从服务端获取聊天记录,roleId: ${roleId}, 消息数: ${
|
||||||
resData.msgs?.length || 0
|
resData.msgs?.length || 0
|
||||||
}`
|
}`
|
||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
console.warn(
|
logger.warn(
|
||||||
`从服务端获取聊天记录失败,roleId: ${roleId}, code: ${res?.code}`
|
`从服务端获取聊天记录失败,roleId: ${roleId}, code: ${res?.code}`
|
||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`获取服务端聊天记录异常,roleId: ${roleId}:`, error);
|
logger.error(`获取服务端聊天记录异常,roleId: ${roleId}:`, error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -390,7 +391,7 @@ export class ChatHistoryManager {
|
|||||||
const mergedMessages = Array.from(messageMap.values());
|
const mergedMessages = Array.from(messageMap.values());
|
||||||
mergedMessages.sort((a, b) => (a.timestamp || 0) - (b.timestamp || 0));
|
mergedMessages.sort((a, b) => (a.timestamp || 0) - (b.timestamp || 0));
|
||||||
|
|
||||||
console.log(
|
logger.log(
|
||||||
`合并聊天记录: 本地 ${localMessages.length} 条, 服务端 ${serverMessages.length} 条, 合并后 ${mergedMessages.length} 条`
|
`合并聊天记录: 本地 ${localMessages.length} 条, 服务端 ${serverMessages.length} 条, 合并后 ${mergedMessages.length} 条`
|
||||||
);
|
);
|
||||||
return mergedMessages;
|
return mergedMessages;
|
||||||
@@ -407,18 +408,18 @@ export class ChatHistoryManager {
|
|||||||
|
|
||||||
// 2. 如果本地有数据,直接返回
|
// 2. 如果本地有数据,直接返回
|
||||||
if (localHistory && localHistory.length > 0) {
|
if (localHistory && localHistory.length > 0) {
|
||||||
console.log(
|
logger.log(
|
||||||
`使用本地聊天记录,roleId: ${roleId}, 消息数: ${localHistory.length}`
|
`使用本地聊天记录,roleId: ${roleId}, 消息数: ${localHistory.length}`
|
||||||
);
|
);
|
||||||
return localHistory;
|
return localHistory;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. 本地没有数据,尝试从服务端获取
|
// 3. 本地没有数据,尝试从服务端获取
|
||||||
console.log(`本地无聊天记录,尝试从服务端获取,roleId: ${roleId}`);
|
logger.log(`本地无聊天记录,尝试从服务端获取,roleId: ${roleId}`);
|
||||||
const serverSuccess = await this.fetchServerChatHistory(roleId);
|
const serverSuccess = await this.fetchServerChatHistory(roleId);
|
||||||
|
|
||||||
if (!serverSuccess) {
|
if (!serverSuccess) {
|
||||||
console.log(`服务端获取失败,返回空记录,roleId: ${roleId}`);
|
logger.log(`服务端获取失败,返回空记录,roleId: ${roleId}`);
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -447,7 +448,7 @@ export class ChatHistoryManager {
|
|||||||
// 6. 保存到本地存储
|
// 6. 保存到本地存储
|
||||||
if (convertedMessages.length > 0) {
|
if (convertedMessages.length > 0) {
|
||||||
this.saveHistory(roleId, convertedMessages);
|
this.saveHistory(roleId, convertedMessages);
|
||||||
console.log(
|
logger.log(
|
||||||
`从服务端获取并保存聊天记录,roleId: ${roleId}, 消息数: ${convertedMessages.length}`
|
`从服务端获取并保存聊天记录,roleId: ${roleId}, 消息数: ${convertedMessages.length}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { ChatContentsLayout } from "../ui/components/ChatContentsLayout";
|
|||||||
import { DiaLogData, Dialog } from "../data/DialogData";
|
import { DiaLogData, Dialog } from "../data/DialogData";
|
||||||
import Utils from "db://assets/Scripts/Main/Common/Utils";
|
import Utils from "db://assets/Scripts/Main/Common/Utils";
|
||||||
import { InnerMsgCode } from "db://assets/Scripts/Main/Config/InnerMsgCode";
|
import { InnerMsgCode } from "db://assets/Scripts/Main/Config/InnerMsgCode";
|
||||||
|
import { logger } from "db://assets/Scripts/Main/Common/Logger";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 对话管理器
|
* 对话管理器
|
||||||
@@ -75,7 +76,7 @@ export class DialogManager {
|
|||||||
// 如果是玩家消息,直接添加单个气泡
|
// 如果是玩家消息,直接添加单个气泡
|
||||||
if (isPlayer) {
|
if (isPlayer) {
|
||||||
this.dialogData.pushDialog(isPlayer, str);
|
this.dialogData.pushDialog(isPlayer, str);
|
||||||
console.log("Dialog updated:", {
|
logger.log("Dialog updated:", {
|
||||||
isPlayer,
|
isPlayer,
|
||||||
content: str.substring(0, 50) + "...",
|
content: str.substring(0, 50) + "...",
|
||||||
});
|
});
|
||||||
@@ -134,7 +135,7 @@ export class DialogManager {
|
|||||||
*/
|
*/
|
||||||
public addLoadingDialog(): void {
|
public addLoadingDialog(): void {
|
||||||
this.dialogData.pushDialog(false, "...", true);
|
this.dialogData.pushDialog(false, "...", true);
|
||||||
console.log("Loading dialog added");
|
logger.log("Loading dialog added");
|
||||||
Utils.sendInnerMsg(InnerMsgCode.Chat_DialogRefresh);
|
Utils.sendInnerMsg(InnerMsgCode.Chat_DialogRefresh);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,7 +154,7 @@ export class DialogManager {
|
|||||||
*/
|
*/
|
||||||
public clearDialogs(): void {
|
public clearDialogs(): void {
|
||||||
this.dialogData.cleanDialog();
|
this.dialogData.cleanDialog();
|
||||||
console.log("All dialogs cleared");
|
logger.log("All dialogs cleared");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -168,7 +169,7 @@ export class DialogManager {
|
|||||||
dialog.content,
|
dialog.content,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
console.log(`DialogManager: Set ${dialogs.length} dialogs`);
|
logger.log(`DialogManager: Set ${dialogs.length} dialogs`);
|
||||||
Utils.sendInnerMsg(InnerMsgCode.Chat_DialogRefresh);
|
Utils.sendInnerMsg(InnerMsgCode.Chat_DialogRefresh);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,7 +179,7 @@ export class DialogManager {
|
|||||||
*/
|
*/
|
||||||
public syncFromChatModel(dialogs: Dialog[]): void {
|
public syncFromChatModel(dialogs: Dialog[]): void {
|
||||||
this.setDialogs(dialogs);
|
this.setDialogs(dialogs);
|
||||||
console.log("DialogManager: Synced dialogs from ChatModel");
|
logger.log("DialogManager: Synced dialogs from ChatModel");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { InnerMsgCode } from "../../Main/Config/InnerMsgCode";
|
|||||||
import { ThemePanel } from "../ui/panels/ThemePanel";
|
import { ThemePanel } from "../ui/panels/ThemePanel";
|
||||||
import { GirlListPanel } from "../ui/panels/GirlListPanel";
|
import { GirlListPanel } from "../ui/panels/GirlListPanel";
|
||||||
import li_BaseView from "../../Main/Common/li_BaseView";
|
import li_BaseView from "../../Main/Common/li_BaseView";
|
||||||
|
import { logger } from "db://assets/Scripts/Main/Common/Logger";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 页面过渡动画类型枚举
|
* 页面过渡动画类型枚举
|
||||||
@@ -120,7 +121,7 @@ export class NavigationManager {
|
|||||||
*/
|
*/
|
||||||
public registerNavigationPanel(panel: any): void {
|
public registerNavigationPanel(panel: any): void {
|
||||||
this.navigationPanel = panel;
|
this.navigationPanel = panel;
|
||||||
console.log("[NavigationManager] NavigationPanel registered");
|
logger.log("[NavigationManager] NavigationPanel registered");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -133,19 +134,19 @@ export class NavigationManager {
|
|||||||
callback: Function = null
|
callback: Function = null
|
||||||
): Node {
|
): Node {
|
||||||
if (!panelType) {
|
if (!panelType) {
|
||||||
console.error("[NavigationManager] switchToPanel: panelType is invalid");
|
logger.error("[NavigationManager] switchToPanel: panelType is invalid");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.currentActivePanelType === panelType && !force) {
|
if (this.currentActivePanelType === panelType && !force) {
|
||||||
console.log(
|
logger.log(
|
||||||
`[NavigationManager] Already on ${panelType}, skipping switch`
|
`[NavigationManager] Already on ${panelType}, skipping switch`
|
||||||
);
|
);
|
||||||
return this.currentActivePanel;
|
return this.currentActivePanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.navigationPanel) {
|
if (!this.navigationPanel) {
|
||||||
console.warn(
|
logger.warn(
|
||||||
"[NavigationManager] NavigationPanel not registered, fallback to direct ViewManager call"
|
"[NavigationManager] NavigationPanel not registered, fallback to direct ViewManager call"
|
||||||
);
|
);
|
||||||
//this.fallbackSwitchPanel(panelType);
|
//this.fallbackSwitchPanel(panelType);
|
||||||
@@ -377,21 +378,21 @@ export class NavigationManager {
|
|||||||
force: boolean = false
|
force: boolean = false
|
||||||
): Node {
|
): Node {
|
||||||
if (!panelType) {
|
if (!panelType) {
|
||||||
console.error(
|
logger.error(
|
||||||
"[NavigationManager] switchToPanelWithTransition: panelType is invalid"
|
"[NavigationManager] switchToPanelWithTransition: panelType is invalid"
|
||||||
);
|
);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.currentActivePanelType === panelType && !force) {
|
if (this.currentActivePanelType === panelType && !force) {
|
||||||
console.log(
|
logger.log(
|
||||||
`[NavigationManager] Already on ${panelType}, skipping switch`
|
`[NavigationManager] Already on ${panelType}, skipping switch`
|
||||||
);
|
);
|
||||||
return this.currentActivePanel;
|
return this.currentActivePanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.navigationPanel) {
|
if (!this.navigationPanel) {
|
||||||
console.warn(
|
logger.warn(
|
||||||
"[NavigationManager] NavigationPanel not registered, fallback to direct ViewManager call"
|
"[NavigationManager] NavigationPanel not registered, fallback to direct ViewManager call"
|
||||||
);
|
);
|
||||||
return null;
|
return null;
|
||||||
@@ -545,13 +546,13 @@ export class NavigationManager {
|
|||||||
callback?: Function
|
callback?: Function
|
||||||
): void {
|
): void {
|
||||||
if (!panelName) {
|
if (!panelName) {
|
||||||
console.error("[NavigationManager] openPopupPanel: panelName is empty");
|
logger.error("[NavigationManager] openPopupPanel: panelName is empty");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const popupCallback = (panel: Node) => {
|
const popupCallback = (panel: Node) => {
|
||||||
if (!panel || !panel.isValid) {
|
if (!panel || !panel.isValid) {
|
||||||
console.error(
|
logger.error(
|
||||||
"[NavigationManager] openPopupPanel: created panel is invalid"
|
"[NavigationManager] openPopupPanel: created panel is invalid"
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
@@ -559,7 +560,7 @@ export class NavigationManager {
|
|||||||
|
|
||||||
// 将弹窗添加到管理集合中
|
// 将弹窗添加到管理集合中
|
||||||
this.popupPanels.add(panel);
|
this.popupPanels.add(panel);
|
||||||
console.log(
|
logger.log(
|
||||||
`[NavigationManager] Popup panel opened: ${panelName}, total popups: ${this.popupPanels.size}`
|
`[NavigationManager] Popup panel opened: ${panelName}, total popups: ${this.popupPanels.size}`
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -577,14 +578,14 @@ export class NavigationManager {
|
|||||||
*/
|
*/
|
||||||
public closePopupPanel(panel: Node): void {
|
public closePopupPanel(panel: Node): void {
|
||||||
if (!panel || !panel.isValid) {
|
if (!panel || !panel.isValid) {
|
||||||
console.warn("[NavigationManager] closePopupPanel: panel is invalid");
|
logger.warn("[NavigationManager] closePopupPanel: panel is invalid");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 从弹窗管理集合中移除
|
// 从弹窗管理集合中移除
|
||||||
if (this.popupPanels.has(panel)) {
|
if (this.popupPanels.has(panel)) {
|
||||||
this.popupPanels.delete(panel);
|
this.popupPanels.delete(panel);
|
||||||
console.log(
|
logger.log(
|
||||||
`[NavigationManager] Popup panel closed: ${panel.name}, total popups: ${this.popupPanels.size}`
|
`[NavigationManager] Popup panel closed: ${panel.name}, total popups: ${this.popupPanels.size}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -598,7 +599,7 @@ export class NavigationManager {
|
|||||||
panel.destroy();
|
panel.destroy();
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("[NavigationManager] closePopupPanel error:", error);
|
logger.error("[NavigationManager] closePopupPanel error:", error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -610,7 +611,7 @@ export class NavigationManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(
|
logger.log(
|
||||||
`[NavigationManager] Closing all popups, count: ${this.popupPanels.size}`
|
`[NavigationManager] Closing all popups, count: ${this.popupPanels.size}`
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -631,7 +632,7 @@ export class NavigationManager {
|
|||||||
animationConfig?: SubPanelAnimationConfig
|
animationConfig?: SubPanelAnimationConfig
|
||||||
) {
|
) {
|
||||||
if (!panel) {
|
if (!panel) {
|
||||||
console.warn(
|
logger.warn(
|
||||||
"[NavigationManager] closeSubPanel: panel is null or undefined"
|
"[NavigationManager] closeSubPanel: panel is null or undefined"
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
@@ -794,7 +795,7 @@ export class NavigationManager {
|
|||||||
// 不在这里调用Show(),因为ThemePanel已经有加载状态保护
|
// 不在这里调用Show(),因为ThemePanel已经有加载状态保护
|
||||||
// 只在必要时调用onHide()确保子页面状态正确
|
// 只在必要时调用onHide()确保子页面状态正确
|
||||||
if (typeof themePanel.onHide === "function") {
|
if (typeof themePanel.onHide === "function") {
|
||||||
console.log("[NavigationManager] 确保主题面板子页面状态正确");
|
logger.log("[NavigationManager] 确保主题面板子页面状态正确");
|
||||||
themePanel.onHide();
|
themePanel.onHide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -918,7 +919,7 @@ export class NavigationManager {
|
|||||||
public setSelectedGirlId(girlId: number): void {
|
public setSelectedGirlId(girlId: number): void {
|
||||||
this.selectedGirlId = girlId;
|
this.selectedGirlId = girlId;
|
||||||
sys.localStorage.setItem(NavigationManager.LastSelectGirlID, girlId);
|
sys.localStorage.setItem(NavigationManager.LastSelectGirlID, girlId);
|
||||||
console.log("[NavigationManager] Selected girl ID set to:", girlId);
|
logger.log("[NavigationManager] Selected girl ID set to:", girlId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -935,7 +936,7 @@ export class NavigationManager {
|
|||||||
*/
|
*/
|
||||||
public setSelectedCategoryId(themeId: number): void {
|
public setSelectedCategoryId(themeId: number): void {
|
||||||
this.selectedCategoryId = themeId;
|
this.selectedCategoryId = themeId;
|
||||||
console.log("[NavigationManager] Selected theme ID set to:", themeId);
|
logger.log("[NavigationManager] Selected theme ID set to:", themeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import type proto from "db://assets/Scripts/proto/proto.pb.js";
|
|||||||
import { type OpenStrategy } from "./PaymentOpener";
|
import { type OpenStrategy } from "./PaymentOpener";
|
||||||
import { DataManager, DataId } from "db://assets/Scripts/chat18x/data/DataManager";
|
import { DataManager, DataId } from "db://assets/Scripts/chat18x/data/DataManager";
|
||||||
import { OrderData } from "db://assets/Scripts/chat18x/data/OrderData";
|
import { OrderData } from "db://assets/Scripts/chat18x/data/OrderData";
|
||||||
|
import { logger } from "db://assets/Scripts/Main/Common/Logger";
|
||||||
|
|
||||||
export class CashInrFlow implements PaymentFlow {
|
export class CashInrFlow implements PaymentFlow {
|
||||||
constructor(private waitAppResume: (open: OpenStrategy) => Promise<void>) {}
|
constructor(private waitAppResume: (open: OpenStrategy) => Promise<void>) {}
|
||||||
@@ -41,6 +42,6 @@ export class CashInrFlow implements PaymentFlow {
|
|||||||
startIntervalMs: 2000,
|
startIntervalMs: 2000,
|
||||||
maxIntervalMs: 10000,
|
maxIntervalMs: 10000,
|
||||||
jitter: true,
|
jitter: true,
|
||||||
}, (d) => console.log());
|
}, (d) => logger.log());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
import { PaymentApi } from "./PaymentApi";
|
import { PaymentApi } from "./PaymentApi";
|
||||||
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 interface PollOptions {
|
export interface PollOptions {
|
||||||
maxDurationMs: number; // 最大轮询时长(超过就自动退出)(例如 2分钟)
|
maxDurationMs: number; // 最大轮询时长(超过就自动退出)(例如 2分钟)
|
||||||
@@ -41,9 +42,9 @@ export class PaymentPoller {
|
|||||||
this.currentPollCount++;
|
this.currentPollCount++;
|
||||||
// 查询
|
// 查询
|
||||||
let reqData = {orderId: orderId};
|
let reqData = {orderId: orderId};
|
||||||
console.log("订单:", orderId, " ,第 ", this.currentPollCount, " 次轮询订单的请求数据:", reqData);
|
logger.log("订单:", orderId, " ,第 ", this.currentPollCount, " 次轮询订单的请求数据:", reqData);
|
||||||
const r = await PaymentApi.I.queryOrder(reqData);
|
const r = await PaymentApi.I.queryOrder(reqData);
|
||||||
console.log("订单:", orderId, " ,第 ", this.currentPollCount, " 次轮询订单的响应数据:", r);
|
logger.log("订单:", orderId, " ,第 ", this.currentPollCount, " 次轮询订单的响应数据:", r);
|
||||||
if (r.code === proto.cs.EnmRetCode.SUCCESS && r.data) {
|
if (r.code === proto.cs.EnmRetCode.SUCCESS && r.data) {
|
||||||
// 回调
|
// 回调
|
||||||
onTick?.(r.data);
|
onTick?.(r.data);
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import { DataManager, DataId } from "db://assets/Scripts/chat18x/data/DataManage
|
|||||||
import { OrderData } from "db://assets/Scripts/chat18x/data/OrderData";
|
import { OrderData } from "db://assets/Scripts/chat18x/data/OrderData";
|
||||||
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";
|
||||||
|
|
||||||
export class PaymentService {
|
export class PaymentService {
|
||||||
private static _I: PaymentService | null = null;
|
private static _I: PaymentService | null = null;
|
||||||
@@ -32,9 +33,9 @@ export class PaymentService {
|
|||||||
/** 发起支付:创建订单→打开URL→回到App后开始轮询 */
|
/** 发起支付:创建订单→打开URL→回到App后开始轮询 */
|
||||||
async startPayment(req: proto.cs.ICSCreateOrderReq, open: OpenStrategy = "system"): Promise<proto.cs.ICSQueryOrderRes> {
|
async startPayment(req: proto.cs.ICSCreateOrderReq, open: OpenStrategy = "system"): Promise<proto.cs.ICSQueryOrderRes> {
|
||||||
// 下单
|
// 下单
|
||||||
console.log("创建订单的请求数据:", req);
|
logger.log("创建订单的请求数据:", req);
|
||||||
const create = await PaymentApi.I.createOrder(req);
|
const create = await PaymentApi.I.createOrder(req);
|
||||||
console.log("创建订单的响应数据:", create);
|
logger.log("创建订单的响应数据:", create);
|
||||||
if (create.code !== proto.cs.EnmRetCode.SUCCESS || !create.data) {
|
if (create.code !== proto.cs.EnmRetCode.SUCCESS || !create.data) {
|
||||||
return { status: -1, retCode: -1, balance: 0, vipExpire: 0};
|
return { status: -1, retCode: -1, balance: 0, vipExpire: 0};
|
||||||
}
|
}
|
||||||
@@ -88,7 +89,7 @@ export class PaymentService {
|
|||||||
return new Promise<void>((resolve) => {
|
return new Promise<void>((resolve) => {
|
||||||
let finished = false;
|
let finished = false;
|
||||||
const finish = () => {
|
const finish = () => {
|
||||||
console.log("应用回到 finish");
|
logger.log("应用回到 finish");
|
||||||
if (finished) return;
|
if (finished) return;
|
||||||
finished = true;
|
finished = true;
|
||||||
// 安全移除监听
|
// 安全移除监听
|
||||||
@@ -98,7 +99,7 @@ export class PaymentService {
|
|||||||
|
|
||||||
const onShow = () => {
|
const onShow = () => {
|
||||||
// 应用回到前台
|
// 应用回到前台
|
||||||
console.log("应用回到了前台");
|
logger.log("应用回到了前台");
|
||||||
finish();
|
finish();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import type proto from "db://assets/Scripts/proto/proto.pb.js";
|
|||||||
import { type OpenStrategy } from "./PaymentOpener";
|
import { type OpenStrategy } from "./PaymentOpener";
|
||||||
import { DataManager, DataId } from "db://assets/Scripts/chat18x/data/DataManager";
|
import { DataManager, DataId } from "db://assets/Scripts/chat18x/data/DataManager";
|
||||||
import { OrderData } from "db://assets/Scripts/chat18x/data/OrderData";
|
import { OrderData } from "db://assets/Scripts/chat18x/data/OrderData";
|
||||||
|
import { logger } from "db://assets/Scripts/Main/Common/Logger";
|
||||||
|
|
||||||
export class WebUsdFlow implements PaymentFlow {
|
export class WebUsdFlow implements PaymentFlow {
|
||||||
constructor(private delayMs: number = 5000) {}
|
constructor(private delayMs: number = 5000) {}
|
||||||
@@ -36,7 +37,7 @@ export class WebUsdFlow implements PaymentFlow {
|
|||||||
startIntervalMs: 5000,
|
startIntervalMs: 5000,
|
||||||
maxIntervalMs: 10000,
|
maxIntervalMs: 10000,
|
||||||
jitter: true,
|
jitter: true,
|
||||||
}, (d) => console.log());
|
}, (d) => logger.log());
|
||||||
}
|
}
|
||||||
|
|
||||||
private delay(ms: number) {
|
private delay(ms: number) {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { ChatAIService } from '../core/ChatAIService';
|
import { ChatAIService } from '../core/ChatAIService';
|
||||||
|
import { logger } from "db://assets/Scripts/Main/Common/Logger";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ChatAI 批量测试运行器 - 纯脚本版本
|
* ChatAI 批量测试运行器 - 纯脚本版本
|
||||||
@@ -14,7 +15,7 @@ export class ChatAIBatchTestRunner {
|
|||||||
private isRunning: boolean = false;
|
private isRunning: boolean = false;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
console.log("[ChatAIBatchTestRunner] 测试运行器已初始化");
|
logger.log("[ChatAIBatchTestRunner] 测试运行器已初始化");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -32,13 +33,13 @@ export class ChatAIBatchTestRunner {
|
|||||||
*/
|
*/
|
||||||
public async runBatchTest(): Promise<void> {
|
public async runBatchTest(): Promise<void> {
|
||||||
if (this.isRunning) {
|
if (this.isRunning) {
|
||||||
console.log("[ChatAIBatchTestRunner] 测试已在运行中,请等待完成...");
|
logger.log("[ChatAIBatchTestRunner] 测试已在运行中,请等待完成...");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.isRunning = true;
|
this.isRunning = true;
|
||||||
console.log("[ChatAIBatchTestRunner] 开始批量测试角色ID 10001-10030");
|
logger.log("[ChatAIBatchTestRunner] 开始批量测试角色ID 10001-10030");
|
||||||
console.log("[ChatAIBatchTestRunner] 每次测试间隔10秒");
|
logger.log("[ChatAIBatchTestRunner] 每次测试间隔10秒");
|
||||||
|
|
||||||
const startTime = Date.now();
|
const startTime = Date.now();
|
||||||
const successIds: number[] = [];
|
const successIds: number[] = [];
|
||||||
@@ -47,7 +48,7 @@ export class ChatAIBatchTestRunner {
|
|||||||
|
|
||||||
// 测试角色ID 10001-10030
|
// 测试角色ID 10001-10030
|
||||||
for (let roleId = 10001; roleId <= 10030; roleId++) {
|
for (let roleId = 10001; roleId <= 10030; roleId++) {
|
||||||
console.log(`[ChatAIBatchTestRunner] 正在测试角色ID: ${roleId}`);
|
logger.log(`[ChatAIBatchTestRunner] 正在测试角色ID: ${roleId}`);
|
||||||
|
|
||||||
const testStartTime = Date.now();
|
const testStartTime = Date.now();
|
||||||
|
|
||||||
@@ -57,12 +58,12 @@ export class ChatAIBatchTestRunner {
|
|||||||
|
|
||||||
if (response && response.trim() !== "") {
|
if (response && response.trim() !== "") {
|
||||||
successIds.push(roleId);
|
successIds.push(roleId);
|
||||||
console.log(`[ChatAIBatchTestRunner] ✅ 角色 ${roleId} 测试成功 (${testDuration}ms)`);
|
logger.log(`[ChatAIBatchTestRunner] ✅ 角色 ${roleId} 测试成功 (${testDuration}ms)`);
|
||||||
console.log(`[ChatAIBatchTestRunner] 响应预览: ${response.substring(0, 50)}...`);
|
logger.log(`[ChatAIBatchTestRunner] 响应预览: ${response.substring(0, 50)}...`);
|
||||||
} else {
|
} else {
|
||||||
failureIds.push(roleId);
|
failureIds.push(roleId);
|
||||||
errorDetails[roleId] = "返回空响应";
|
errorDetails[roleId] = "返回空响应";
|
||||||
console.log(`[ChatAIBatchTestRunner] ❌ 角色 ${roleId} 返回空响应 (${testDuration}ms)`);
|
logger.log(`[ChatAIBatchTestRunner] ❌ 角色 ${roleId} 返回空响应 (${testDuration}ms)`);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const testDuration = Date.now() - testStartTime;
|
const testDuration = Date.now() - testStartTime;
|
||||||
@@ -70,12 +71,12 @@ export class ChatAIBatchTestRunner {
|
|||||||
|
|
||||||
failureIds.push(roleId);
|
failureIds.push(roleId);
|
||||||
errorDetails[roleId] = errorMessage;
|
errorDetails[roleId] = errorMessage;
|
||||||
console.log(`[ChatAIBatchTestRunner] ❌ 角色 ${roleId} 测试失败 (${testDuration}ms): ${errorMessage}`);
|
logger.log(`[ChatAIBatchTestRunner] ❌ 角色 ${roleId} 测试失败 (${testDuration}ms): ${errorMessage}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 等待10秒(最后一个不需要等待)
|
// 等待10秒(最后一个不需要等待)
|
||||||
if (roleId < 10030) {
|
if (roleId < 10030) {
|
||||||
console.log(`[ChatAIBatchTestRunner] 等待10秒后继续下一个测试...`);
|
logger.log(`[ChatAIBatchTestRunner] 等待10秒后继续下一个测试...`);
|
||||||
await this.delay(10);
|
await this.delay(10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -86,7 +87,7 @@ export class ChatAIBatchTestRunner {
|
|||||||
this.printFinalReport(successIds, failureIds, errorDetails, totalDuration);
|
this.printFinalReport(successIds, failureIds, errorDetails, totalDuration);
|
||||||
|
|
||||||
this.isRunning = false;
|
this.isRunning = false;
|
||||||
console.log("[ChatAIBatchTestRunner] 批量测试完成!");
|
logger.log("[ChatAIBatchTestRunner] 批量测试完成!");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -103,44 +104,44 @@ export class ChatAIBatchTestRunner {
|
|||||||
const failureCount = failureIds.length;
|
const failureCount = failureIds.length;
|
||||||
const successRate = ((successCount / totalTests) * 100).toFixed(2);
|
const successRate = ((successCount / totalTests) * 100).toFixed(2);
|
||||||
|
|
||||||
console.log("\n" + "=".repeat(60));
|
logger.log("\n" + "=".repeat(60));
|
||||||
console.log(" ChatAI 批量测试报告");
|
logger.log(" ChatAI 批量测试报告");
|
||||||
console.log("=".repeat(60));
|
logger.log("=".repeat(60));
|
||||||
console.log(`测试时间: ${new Date().toLocaleString()}`);
|
logger.log(`测试时间: ${new Date().toLocaleString()}`);
|
||||||
console.log(`总测试数: ${totalTests}`);
|
logger.log(`总测试数: ${totalTests}`);
|
||||||
console.log(`成功数量: ${successCount}`);
|
logger.log(`成功数量: ${successCount}`);
|
||||||
console.log(`失败数量: ${failureCount}`);
|
logger.log(`失败数量: ${failureCount}`);
|
||||||
console.log(`成功率: ${successRate}%`);
|
logger.log(`成功率: ${successRate}%`);
|
||||||
console.log(`总耗时: ${(totalDuration / 1000).toFixed(2)}秒`);
|
logger.log(`总耗时: ${(totalDuration / 1000).toFixed(2)}秒`);
|
||||||
console.log(`平均耗时: ${(totalDuration / totalTests / 1000).toFixed(2)}秒/测试`);
|
logger.log(`平均耗时: ${(totalDuration / totalTests / 1000).toFixed(2)}秒/测试`);
|
||||||
|
|
||||||
console.log("\n" + "-".repeat(30) + " 成功的角色ID " + "-".repeat(30));
|
logger.log("\n" + "-".repeat(30) + " 成功的角色ID " + "-".repeat(30));
|
||||||
if (successIds.length > 0) {
|
if (successIds.length > 0) {
|
||||||
const successList = this.formatIdList(successIds);
|
const successList = this.formatIdList(successIds);
|
||||||
console.log(successList);
|
logger.log(successList);
|
||||||
} else {
|
} else {
|
||||||
console.log("无成功案例");
|
logger.log("无成功案例");
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("\n" + "-".repeat(30) + " 失败的角色ID " + "-".repeat(30));
|
logger.log("\n" + "-".repeat(30) + " 失败的角色ID " + "-".repeat(30));
|
||||||
if (failureIds.length > 0) {
|
if (failureIds.length > 0) {
|
||||||
const failureList = this.formatIdList(failureIds);
|
const failureList = this.formatIdList(failureIds);
|
||||||
console.log(failureList);
|
logger.log(failureList);
|
||||||
|
|
||||||
console.log("\n" + "-".repeat(25) + " 失败详情 " + "-".repeat(25));
|
logger.log("\n" + "-".repeat(25) + " 失败详情 " + "-".repeat(25));
|
||||||
failureIds.forEach(roleId => {
|
failureIds.forEach(roleId => {
|
||||||
console.log(`角色 ${roleId}: ${errorDetails[roleId]}`);
|
logger.log(`角色 ${roleId}: ${errorDetails[roleId]}`);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
console.log("无失败案例");
|
logger.log("无失败案例");
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("\n" + "=".repeat(60));
|
logger.log("\n" + "=".repeat(60));
|
||||||
|
|
||||||
// 输出简洁版结果供复制使用
|
// 输出简洁版结果供复制使用
|
||||||
console.log("\n简洁结果:");
|
logger.log("\n简洁结果:");
|
||||||
console.log(`成功(${successCount}): ${successIds.join(',')}`);
|
logger.log(`成功(${successCount}): ${successIds.join(',')}`);
|
||||||
console.log(`失败(${failureCount}): ${failureIds.join(',')}`);
|
logger.log(`失败(${failureCount}): ${failureIds.join(',')}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ import { NavigationManager, PanelType } from "../../manager/NavigationManager";
|
|||||||
import { GirlService } from "../../network/services/GirlService";
|
import { GirlService } from "../../network/services/GirlService";
|
||||||
import proto from "db://assets/Scripts/proto/proto.pb.js";
|
import proto from "db://assets/Scripts/proto/proto.pb.js";
|
||||||
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;
|
||||||
|
|
||||||
@ccclass("ChatPanel")
|
@ccclass("ChatPanel")
|
||||||
@@ -110,9 +112,9 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
|
|||||||
|
|
||||||
// 检查 SceneBgVideoLayer 是否可用
|
// 检查 SceneBgVideoLayer 是否可用
|
||||||
if (!this.videoLayer) {
|
if (!this.videoLayer) {
|
||||||
console.error("ChatPanel: SceneBgVideoLayer.handle 未初始化");
|
logger.error("ChatPanel: SceneBgVideoLayer.handle 未初始化");
|
||||||
} else {
|
} else {
|
||||||
console.log("ChatPanel: 成功获取 SceneBgVideoLayer 实例");
|
logger.log("ChatPanel: 成功获取 SceneBgVideoLayer 实例");
|
||||||
}
|
}
|
||||||
this.popUpImage.node.active = false;
|
this.popUpImage.node.active = false;
|
||||||
}
|
}
|
||||||
@@ -199,7 +201,7 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
|
|||||||
this.chatController.hasRoleData(this.categoryId, this.id)
|
this.chatController.hasRoleData(this.categoryId, this.id)
|
||||||
) {
|
) {
|
||||||
// 如果是角色切换且有缓存数据,使用switchRole
|
// 如果是角色切换且有缓存数据,使用switchRole
|
||||||
console.log(
|
logger.log(
|
||||||
`ChatPanel: Switching from role ${this.chatController.getCurrentRoleId()} to role ${
|
`ChatPanel: Switching from role ${this.chatController.getCurrentRoleId()} to role ${
|
||||||
this.id
|
this.id
|
||||||
}`
|
}`
|
||||||
@@ -207,7 +209,7 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
|
|||||||
this.chatController.switchRole(this.categoryId, this.id);
|
this.chatController.switchRole(this.categoryId, this.id);
|
||||||
} else {
|
} else {
|
||||||
// 首次初始化或没有缓存数据,使用initialize
|
// 首次初始化或没有缓存数据,使用initialize
|
||||||
console.log(`ChatPanel: Initializing role ${this.id}`);
|
logger.log(`ChatPanel: Initializing role ${this.id}`);
|
||||||
this.chatController.initialize(this.categoryId, this.id);
|
this.chatController.initialize(this.categoryId, this.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -234,7 +236,7 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
|
|||||||
if (this.videoLayer) {
|
if (this.videoLayer) {
|
||||||
// Get current emotion from ChatController
|
// Get current emotion from ChatController
|
||||||
const currentEmotion = this.chatController.getCurrentEmotion();
|
const currentEmotion = this.chatController.getCurrentEmotion();
|
||||||
console.log(
|
logger.log(
|
||||||
`Current emotion for role ${this.id}: ${VideoEmotion[currentEmotion]}`
|
`Current emotion for role ${this.id}: ${VideoEmotion[currentEmotion]}`
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -244,7 +246,7 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
|
|||||||
chatModel.getDefaultVideo();
|
chatModel.getDefaultVideo();
|
||||||
|
|
||||||
if (initialVideo) {
|
if (initialVideo) {
|
||||||
console.log(
|
logger.log(
|
||||||
`Loading initial video: ${initialVideo} (emotion: ${VideoEmotion[initialVideo]})`
|
`Loading initial video: ${initialVideo} (emotion: ${VideoEmotion[initialVideo]})`
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -263,7 +265,7 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.currentEmotion = null; // Reset current emotion when no videos available
|
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() {
|
adjustVideoScale() {
|
||||||
console.log(
|
logger.log(
|
||||||
"ChatPanel: adjustVideoScale() 方法已废弃,缩放和位置由 playVideo() 自动处理"
|
"ChatPanel: adjustVideoScale() 方法已废弃,缩放和位置由 playVideo() 自动处理"
|
||||||
);
|
);
|
||||||
// 如果确实需要手动调整,可以重新调用 playVideo
|
// 如果确实需要手动调整,可以重新调用 playVideo
|
||||||
// this.videoLayer.playVideo(currentVideo, { size, position });
|
// this.videoLayer.playVideo(currentVideo, { size, position });
|
||||||
}
|
}
|
||||||
onChatCountChange() {
|
onChatCountChange() {
|
||||||
console.log("Trigger On ChatCount Change");
|
logger.log("Trigger On ChatCount Change");
|
||||||
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
|
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
|
||||||
let triggerId = girlData.getTriggerGrilPhotoId(this.categoryId, this.id);
|
let triggerId = girlData.getTriggerGrilPhotoId(this.categoryId, this.id);
|
||||||
|
|
||||||
if (triggerId == 0) return;
|
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);
|
this.popUpImage.refresh(this.categoryId, this.id, triggerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
setVideoEnable(enable: boolean) {
|
setVideoEnable(enable: boolean) {
|
||||||
if (!this.videoLayer) {
|
if (!this.videoLayer) {
|
||||||
console.error("ChatPanel: SceneBgVideoLayer 不可用");
|
logger.error("ChatPanel: SceneBgVideoLayer 不可用");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enable) {
|
if (enable) {
|
||||||
this.videoLayer.resume();
|
this.videoLayer.resume();
|
||||||
console.log("ChatPanel: 恢复视频播放");
|
logger.log("ChatPanel: 恢复视频播放");
|
||||||
} else {
|
} else {
|
||||||
this.videoLayer.pause();
|
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
|
// Check if emotion has changed
|
||||||
if (this.currentEmotion === emotion) {
|
if (this.currentEmotion === emotion) {
|
||||||
console.log(
|
logger.log(
|
||||||
`Emotion ${VideoEmotion[emotion]} unchanged, skipping video switch`
|
`Emotion ${VideoEmotion[emotion]} unchanged, skipping video switch`
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
@@ -324,7 +326,7 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
|
|||||||
const matchingVideo = chatModel.getVideoByEmotion(emotion);
|
const matchingVideo = chatModel.getVideoByEmotion(emotion);
|
||||||
|
|
||||||
if (matchingVideo) {
|
if (matchingVideo) {
|
||||||
console.log(
|
logger.log(
|
||||||
`Switching to video for emotion ${
|
`Switching to video for emotion ${
|
||||||
VideoEmotion[emotion]
|
VideoEmotion[emotion]
|
||||||
}: ${matchingVideo} (from ${
|
}: ${matchingVideo} (from ${
|
||||||
@@ -346,14 +348,14 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
|
|||||||
// 注意:移除了 adjustVideoScale() 调用,因为 playVideo 现在会自动处理缩放和位置
|
// 注意:移除了 adjustVideoScale() 调用,因为 playVideo 现在会自动处理缩放和位置
|
||||||
this.setVideoEnable(true);
|
this.setVideoEnable(true);
|
||||||
} else {
|
} else {
|
||||||
console.warn(
|
logger.warn(
|
||||||
`No video found for emotion ${VideoEmotion[emotion]}, falling back to default video`
|
`No video found for emotion ${VideoEmotion[emotion]}, falling back to default video`
|
||||||
);
|
);
|
||||||
|
|
||||||
// Fallback to default video from ChatModel
|
// Fallback to default video from ChatModel
|
||||||
const fallbackVideo = chatModel.getDefaultVideo();
|
const fallbackVideo = chatModel.getDefaultVideo();
|
||||||
if (fallbackVideo) {
|
if (fallbackVideo) {
|
||||||
console.log(
|
logger.log(
|
||||||
`Loading fallback video: ${fallbackVideo} (emotion: ${VideoEmotion[fallbackVideo]})`
|
`Loading fallback video: ${fallbackVideo} (emotion: ${VideoEmotion[fallbackVideo]})`
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -378,7 +380,7 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
|
|||||||
}): void {
|
}): void {
|
||||||
// 检查是否是当前角色
|
// 检查是否是当前角色
|
||||||
if (data.roleId === this.id) {
|
if (data.roleId === this.id) {
|
||||||
console.log(
|
logger.log(
|
||||||
`Emotion initialized for current role ${this.id}: ${
|
`Emotion initialized for current role ${this.id}: ${
|
||||||
VideoEmotion[data.emotion]
|
VideoEmotion[data.emotion]
|
||||||
}`
|
}`
|
||||||
@@ -387,7 +389,7 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
|
|||||||
// 切换到对应的视频
|
// 切换到对应的视频
|
||||||
this.switchVideoByEmotion(data.emotion);
|
this.switchVideoByEmotion(data.emotion);
|
||||||
} else {
|
} else {
|
||||||
console.log(
|
logger.log(
|
||||||
`Emotion initialized for role ${data.roleId} (not current role ${this.id}), ignoring`
|
`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 用户发送的消息
|
* @param message 用户发送的消息
|
||||||
*/
|
*/
|
||||||
public onMessageSent(message: string): void {
|
public onMessageSent(message: string): void {
|
||||||
console.log("Message sent:", message);
|
logger.log("Message sent:", message);
|
||||||
// 消息发送后开始显示加载动画,由DialogManager处理
|
// 消息发送后开始显示加载动画,由DialogManager处理
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -453,7 +455,7 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
|
|||||||
* @param response AI的回复内容
|
* @param response AI的回复内容
|
||||||
*/
|
*/
|
||||||
public onMessageReceived(response: string): void {
|
public onMessageReceived(response: string): void {
|
||||||
//console.log("Message received:", response);
|
//logger.log("Message received:", response);
|
||||||
// AI回复收到后加载动画会被自动移除,可以在这里添加其他UI效果
|
// AI回复收到后加载动画会被自动移除,可以在这里添加其他UI效果
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -483,7 +485,7 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
|
|||||||
* @param emotion 当前情绪状态
|
* @param emotion 当前情绪状态
|
||||||
*/
|
*/
|
||||||
public onEmotionUpdated(emotion: VideoEmotion): void {
|
public onEmotionUpdated(emotion: VideoEmotion): void {
|
||||||
console.log(
|
logger.log(
|
||||||
`ChatPanel: Emotion updated to ${VideoEmotion[emotion]} (${emotion})`
|
`ChatPanel: Emotion updated to ${VideoEmotion[emotion]} (${emotion})`
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -495,23 +497,23 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
|
|||||||
switch (emotion) {
|
switch (emotion) {
|
||||||
case VideoEmotion.calm_down:
|
case VideoEmotion.calm_down:
|
||||||
// 平静状态的UI更新
|
// 平静状态的UI更新
|
||||||
console.log("UI state: Calm");
|
logger.log("UI state: Calm");
|
||||||
break;
|
break;
|
||||||
case VideoEmotion.arousal:
|
case VideoEmotion.arousal:
|
||||||
// 兴奋状态的UI更新
|
// 兴奋状态的UI更新
|
||||||
console.log("UI state: Arousal");
|
logger.log("UI state: Arousal");
|
||||||
break;
|
break;
|
||||||
case VideoEmotion.desire:
|
case VideoEmotion.desire:
|
||||||
// 渴望状态的UI更新
|
// 渴望状态的UI更新
|
||||||
console.log("UI state: Desire");
|
logger.log("UI state: Desire");
|
||||||
break;
|
break;
|
||||||
case VideoEmotion.passion:
|
case VideoEmotion.passion:
|
||||||
// 激情状态的UI更新
|
// 激情状态的UI更新
|
||||||
console.log("UI state: Passion");
|
logger.log("UI state: Passion");
|
||||||
break;
|
break;
|
||||||
case VideoEmotion.orgasm:
|
case VideoEmotion.orgasm:
|
||||||
// 高潮状态的UI更新
|
// 高潮状态的UI更新
|
||||||
console.log("UI state: Orgasm");
|
logger.log("UI state: Orgasm");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -529,17 +531,17 @@ export class ChatPanel extends li_BaseView implements IChatPanelCallback {
|
|||||||
*/
|
*/
|
||||||
public clearRoleDataDebug(roleId?: number): void {
|
public clearRoleDataDebug(roleId?: number): void {
|
||||||
if (!this.chatController) {
|
if (!this.chatController) {
|
||||||
console.warn("ChatController not initialized");
|
logger.warn("ChatController not initialized");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const targetRoleId = roleId || this.id;
|
const targetRoleId = roleId || this.id;
|
||||||
if (!targetRoleId) {
|
if (!targetRoleId) {
|
||||||
console.warn("No role ID specified");
|
logger.warn("No role ID specified");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.chatController.clearRoleData(targetRoleId);
|
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 { TipsPanel } from "./TipsPanel";
|
||||||
import ResManager from "../../../Main/Manager/ResManager";
|
import ResManager from "../../../Main/Manager/ResManager";
|
||||||
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;
|
||||||
|
|
||||||
@ccclass("GirlListPopupPanel")
|
@ccclass("GirlListPopupPanel")
|
||||||
@@ -79,7 +81,7 @@ export class GirlListPopupPanel extends li_BaseView {
|
|||||||
|
|
||||||
const path = girlData.getGrilAvatar(this.category.toString(), this.girlId);
|
const path = girlData.getGrilAvatar(this.category.toString(), this.girlId);
|
||||||
this.refreshCoinNum();
|
this.refreshCoinNum();
|
||||||
//console.log(path);
|
//logger.log(path);
|
||||||
// 加载远程资源
|
// 加载远程资源
|
||||||
const envData = DataManager.I.getDataById<EnvData>(DataId.Env);
|
const envData = DataManager.I.getDataById<EnvData>(DataId.Env);
|
||||||
let newPath = envData.cdn + "/" + "Girls/" + path + ".png";
|
let newPath = envData.cdn + "/" + "Girls/" + path + ".png";
|
||||||
@@ -101,13 +103,13 @@ export class GirlListPopupPanel extends li_BaseView {
|
|||||||
}
|
}
|
||||||
async buyCharacter() {
|
async buyCharacter() {
|
||||||
// 购买id为girlId的女生
|
// 购买id为girlId的女生
|
||||||
console.log(this.girlId);
|
logger.log(this.girlId);
|
||||||
// 请求解锁
|
// 请求解锁
|
||||||
const reqData = {
|
const reqData = {
|
||||||
id: this.girlId,
|
id: this.girlId,
|
||||||
};
|
};
|
||||||
let res = await GirlService.I.reqUnlockGirl(reqData);
|
let res = await GirlService.I.reqUnlockGirl(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;
|
||||||
// 保存数据
|
// 保存数据
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { NavigationManager, PanelType } from "../../manager/NavigationManager";
|
|||||||
import { NavigationBtn } from "../items/NavigationBtn";
|
import { NavigationBtn } from "../items/NavigationBtn";
|
||||||
import { ChatHistoryManager } from "../../manager/ChatHistoryManager";
|
import { ChatHistoryManager } from "../../manager/ChatHistoryManager";
|
||||||
import { PastGirlListPanel } from "./PastGirlListPanel";
|
import { PastGirlListPanel } from "./PastGirlListPanel";
|
||||||
|
import { logger } from "db://assets/Scripts/Main/Common/Logger";
|
||||||
|
|
||||||
const { ccclass, property } = _decorator;
|
const { ccclass, property } = _decorator;
|
||||||
|
|
||||||
@@ -101,7 +102,7 @@ export class NavigationPanel extends li_BaseView {
|
|||||||
private refreshButtonVisuals() {
|
private refreshButtonVisuals() {
|
||||||
// TODO: 实现按钮状态更新的视觉效果
|
// TODO: 实现按钮状态更新的视觉效果
|
||||||
// 根据 currentActivePanel 更新按钮的选中状态
|
// 根据 currentActivePanel 更新按钮的选中状态
|
||||||
console.log(
|
logger.log(
|
||||||
"[NavigationPanel] Button states updated for:",
|
"[NavigationPanel] Button states updated for:",
|
||||||
this.currentActivePanel
|
this.currentActivePanel
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ import proto from "db://assets/Scripts/proto/proto.pb.js";
|
|||||||
import { ConfigId, ConfigManager } from "../../manager/ConfigManager";
|
import { ConfigId, ConfigManager } from "../../manager/ConfigManager";
|
||||||
import { PurchaseConfig } from "../../config/PurchaseConfig";
|
import { PurchaseConfig } from "../../config/PurchaseConfig";
|
||||||
import LanguageUtils from "../../../Main/Common/LanguageUtils";
|
import LanguageUtils from "../../../Main/Common/LanguageUtils";
|
||||||
|
import { logger } from "db://assets/Scripts/Main/Common/Logger";
|
||||||
|
|
||||||
const { ccclass, property } = _decorator;
|
const { ccclass, property } = _decorator;
|
||||||
|
|
||||||
@ccclass("PayToTalkSubpanel")
|
@ccclass("PayToTalkSubpanel")
|
||||||
@@ -76,7 +78,7 @@ export class PayToTalkSubpanel extends Component {
|
|||||||
//ChatController.Instance.resetChatCount();
|
//ChatController.Instance.resetChatCount();
|
||||||
const shopData = DataManager.I.getDataById<ShopData>(DataId.Shop);
|
const shopData = DataManager.I.getDataById<ShopData>(DataId.Shop);
|
||||||
const chatIds = shopData.getChatIds();
|
const chatIds = shopData.getChatIds();
|
||||||
console.log("聊天商品Id: ", chatIds);
|
logger.log("聊天商品Id: ", chatIds);
|
||||||
if (chatIds.length > 0) {
|
if (chatIds.length > 0) {
|
||||||
this.reqBuyGood(chatIds[0], this.girlId);
|
this.reqBuyGood(chatIds[0], this.girlId);
|
||||||
}
|
}
|
||||||
@@ -84,7 +86,7 @@ export class PayToTalkSubpanel extends Component {
|
|||||||
|
|
||||||
onClick_BuyVip() {
|
onClick_BuyVip() {
|
||||||
//购买VIP
|
//购买VIP
|
||||||
console.log("购买vip");
|
logger.log("购买vip");
|
||||||
const shopData = DataManager.I.getDataById<ShopData>(DataId.Shop);
|
const shopData = DataManager.I.getDataById<ShopData>(DataId.Shop);
|
||||||
const memberId = shopData.get7DayMemberId();
|
const memberId = shopData.get7DayMemberId();
|
||||||
this.reqBuyGood(memberId, this.girlId);
|
this.reqBuyGood(memberId, this.girlId);
|
||||||
@@ -98,7 +100,7 @@ export class PayToTalkSubpanel extends Component {
|
|||||||
girlId: girlId,
|
girlId: girlId,
|
||||||
};
|
};
|
||||||
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;
|
||||||
// 保存数据
|
// 保存数据
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ import { GButton } from "db://assets/Scripts/Main/Common/GButton";
|
|||||||
import { SceneBgVideoLayer } from "../../../Sub/UI/SceneBgVideoLayer";
|
import { SceneBgVideoLayer } from "../../../Sub/UI/SceneBgVideoLayer";
|
||||||
import { DataManager, DataId } from "../../data/DataManager";
|
import { DataManager, DataId } from "../../data/DataManager";
|
||||||
import { EnvData } from "../../data/EnvData";
|
import { EnvData } from "../../data/EnvData";
|
||||||
|
import { logger } from "db://assets/Scripts/Main/Common/Logger";
|
||||||
|
|
||||||
const { ccclass, property } = _decorator;
|
const { ccclass, property } = _decorator;
|
||||||
|
|
||||||
interface ShowPanelData {
|
interface ShowPanelData {
|
||||||
@@ -139,7 +141,7 @@ export class ShowPanel extends li_BaseView {
|
|||||||
const scale = Math.max(scaleX, scaleY); // 填满整个区域
|
const scale = Math.max(scaleX, scaleY); // 填满整个区域
|
||||||
|
|
||||||
this.videoPlayer.node.setScale(new Vec3(scale, scale, 1));
|
this.videoPlayer.node.setScale(new Vec3(scale, scale, 1));
|
||||||
console.log(`ShowPanel: 调整视频缩放到 ${scale}`);
|
logger.log(`ShowPanel: 调整视频缩放到 ${scale}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import proto from "db://assets/Scripts/proto/proto.pb.js";
|
|||||||
import GameRootUI from "../../../Main/Common/GameRootUI";
|
import GameRootUI from "../../../Main/Common/GameRootUI";
|
||||||
import { MainController } from "../../core/MainController";
|
import { MainController } from "../../core/MainController";
|
||||||
import { GirlListPanel } from "./GirlListPanel";
|
import { GirlListPanel } from "./GirlListPanel";
|
||||||
|
import { logger } from "db://assets/Scripts/Main/Common/Logger";
|
||||||
|
|
||||||
const { ccclass, property } = _decorator;
|
const { ccclass, property } = _decorator;
|
||||||
|
|
||||||
@@ -79,7 +80,7 @@ export class ThemePanel extends li_BaseView {
|
|||||||
async Show(forceRefresh: boolean = false) {
|
async Show(forceRefresh: boolean = false) {
|
||||||
// 防止重复加载
|
// 防止重复加载
|
||||||
if (this.isLoading) {
|
if (this.isLoading) {
|
||||||
console.log("[ThemePanel] 已在加载中,等待当前加载完成");
|
logger.log("[ThemePanel] 已在加载中,等待当前加载完成");
|
||||||
if (this.loadingPromise) {
|
if (this.loadingPromise) {
|
||||||
await this.loadingPromise;
|
await this.loadingPromise;
|
||||||
}
|
}
|
||||||
@@ -123,12 +124,12 @@ export class ThemePanel extends li_BaseView {
|
|||||||
|
|
||||||
// 如果需要强制刷新,先刷新数据
|
// 如果需要强制刷新,先刷新数据
|
||||||
if (forceRefresh) {
|
if (forceRefresh) {
|
||||||
console.log("[ThemePanel] 开始强制刷新数据");
|
logger.log("[ThemePanel] 开始强制刷新数据");
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
MainController.I.refreshThemeData(),
|
MainController.I.refreshThemeData(),
|
||||||
MainController.I.refreshDailyRecommend(),
|
MainController.I.refreshDailyRecommend(),
|
||||||
]);
|
]);
|
||||||
console.log("[ThemePanel] 数据刷新完成");
|
logger.log("[ThemePanel] 数据刷新完成");
|
||||||
|
|
||||||
// 再次检查是否已被取消
|
// 再次检查是否已被取消
|
||||||
if (signal.aborted) {
|
if (signal.aborted) {
|
||||||
@@ -138,7 +139,7 @@ export class ThemePanel extends li_BaseView {
|
|||||||
|
|
||||||
// 优先使用MainController中预加载的数据
|
// 优先使用MainController中预加载的数据
|
||||||
const preloadStatus = MainController.I.getPreloadStatus();
|
const preloadStatus = MainController.I.getPreloadStatus();
|
||||||
console.log("[ThemePanel] 预加载状态:", preloadStatus);
|
logger.log("[ThemePanel] 预加载状态:", preloadStatus);
|
||||||
|
|
||||||
// 处理主题数据
|
// 处理主题数据
|
||||||
await this.handleThemeData(preloadStatus.themeData);
|
await this.handleThemeData(preloadStatus.themeData);
|
||||||
@@ -161,13 +162,13 @@ export class ThemePanel extends li_BaseView {
|
|||||||
// 处理商品列表数据
|
// 处理商品列表数据
|
||||||
await this.handleShopListData(preloadStatus.shopList);
|
await this.handleShopListData(preloadStatus.shopList);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("[ThemePanel] Show操作出错:", error);
|
logger.error("[ThemePanel] Show操作出错:", error);
|
||||||
this._nodeTab.loadingRec.active = false;
|
this._nodeTab.loadingRec.active = false;
|
||||||
|
|
||||||
// 如果不是取消操作导致的错误,可以考虑显示错误提示
|
// 如果不是取消操作导致的错误,可以考虑显示错误提示
|
||||||
if (error.message !== "Operation was aborted") {
|
if (error.message !== "Operation was aborted") {
|
||||||
// 这里可以添加错误提示逻辑
|
// 这里可以添加错误提示逻辑
|
||||||
console.error("[ThemePanel] 数据加载失败,请稍后重试");
|
logger.error("[ThemePanel] 数据加载失败,请稍后重试");
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
this.abortController = null;
|
this.abortController = null;
|
||||||
@@ -179,7 +180,7 @@ export class ThemePanel extends li_BaseView {
|
|||||||
*/
|
*/
|
||||||
private async handleThemeData(isPreloaded: boolean): Promise<void> {
|
private async handleThemeData(isPreloaded: boolean): Promise<void> {
|
||||||
if (isPreloaded) {
|
if (isPreloaded) {
|
||||||
console.log("[ThemePanel] 使用预加载的主题数据");
|
logger.log("[ThemePanel] 使用预加载的主题数据");
|
||||||
// 直接使用预加载的数据渲染界面
|
// 直接使用预加载的数据渲染界面
|
||||||
const themeData = DataManager.I.getDataById<ThemeData>(DataId.Theme);
|
const themeData = DataManager.I.getDataById<ThemeData>(DataId.Theme);
|
||||||
if (themeData && themeData.themes) {
|
if (themeData && themeData.themes) {
|
||||||
@@ -189,7 +190,7 @@ export class ThemePanel extends li_BaseView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 如果没有预加载数据,则请求数据
|
// 如果没有预加载数据,则请求数据
|
||||||
console.log("[ThemePanel] 请求主题数据");
|
logger.log("[ThemePanel] 请求主题数据");
|
||||||
const reqData = {};
|
const reqData = {};
|
||||||
let res = await ThemeService.I.reqHallTheme(reqData);
|
let res = await ThemeService.I.reqHallTheme(reqData);
|
||||||
if (res && res.code === proto.cs.EnmRetCode.SUCCESS) {
|
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> {
|
private async handleDailyRecommendData(isPreloaded: boolean): Promise<void> {
|
||||||
if (isPreloaded) {
|
if (isPreloaded) {
|
||||||
console.log("[ThemePanel] 使用预加载的每日推荐数据");
|
logger.log("[ThemePanel] 使用预加载的每日推荐数据");
|
||||||
// 直接使用预加载的数据渲染界面
|
// 直接使用预加载的数据渲染界面
|
||||||
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
|
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
|
||||||
if (girlData) {
|
if (girlData) {
|
||||||
@@ -230,7 +231,7 @@ export class ThemePanel extends li_BaseView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 如果没有预加载数据,则请求数据
|
// 如果没有预加载数据,则请求数据
|
||||||
console.log("[ThemePanel] 请求每日推荐数据");
|
logger.log("[ThemePanel] 请求每日推荐数据");
|
||||||
const reqData = {};
|
const reqData = {};
|
||||||
let res = await GirlService.I.reqDailyRecommend(reqData);
|
let res = await GirlService.I.reqDailyRecommend(reqData);
|
||||||
if (res && res.code === proto.cs.EnmRetCode.SUCCESS) {
|
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> {
|
private async handleShopListData(isPreloaded: boolean): Promise<void> {
|
||||||
if (isPreloaded) {
|
if (isPreloaded) {
|
||||||
console.log("[ThemePanel] 商品列表数据已预加载");
|
logger.log("[ThemePanel] 商品列表数据已预加载");
|
||||||
// 数据已经在DataManager中,不需要额外处理
|
// 数据已经在DataManager中,不需要额外处理
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果没有预加载数据,则请求数据
|
// 如果没有预加载数据,则请求数据
|
||||||
console.log("[ThemePanel] 请求商品列表数据");
|
logger.log("[ThemePanel] 请求商品列表数据");
|
||||||
await this.reqShopList();
|
await this.reqShopList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -336,7 +337,7 @@ export class ThemePanel extends li_BaseView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
openMsgBox() {
|
openMsgBox() {
|
||||||
console.log("打开信箱");
|
logger.log("打开信箱");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 刷新余额
|
// 刷新余额
|
||||||
@@ -380,7 +381,7 @@ export class ThemePanel extends li_BaseView {
|
|||||||
*/
|
*/
|
||||||
private clearCache(): void {
|
private clearCache(): void {
|
||||||
if (this.cache && this.cache.length > 0) {
|
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--) {
|
for (let i = this.cache.length - 1; i >= 0; i--) {
|
||||||
if (this.cache[i] && this.cache[i].node && this.cache[i].node.isValid) {
|
if (this.cache[i] && this.cache[i].node && this.cache[i].node.isValid) {
|
||||||
this.cache[i].node.destroy();
|
this.cache[i].node.destroy();
|
||||||
@@ -394,7 +395,7 @@ export class ThemePanel extends li_BaseView {
|
|||||||
* 页面被隐藏时调用
|
* 页面被隐藏时调用
|
||||||
*/
|
*/
|
||||||
public onHide(): void {
|
public onHide(): void {
|
||||||
console.log("[ThemePanel] onHide called");
|
logger.log("[ThemePanel] onHide called");
|
||||||
this.cancelCurrentOperation();
|
this.cancelCurrentOperation();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -403,14 +404,14 @@ export class ThemePanel extends li_BaseView {
|
|||||||
*/
|
*/
|
||||||
private cancelCurrentOperation(): void {
|
private cancelCurrentOperation(): void {
|
||||||
if (this.abortController) {
|
if (this.abortController) {
|
||||||
console.log("[ThemePanel] 取消当前操作");
|
logger.log("[ThemePanel] 取消当前操作");
|
||||||
this.abortController.abort();
|
this.abortController.abort();
|
||||||
this.abortController = null;
|
this.abortController = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onDestroy(): void {
|
onDestroy(): void {
|
||||||
console.log("[ThemePanel] onDestroy called");
|
logger.log("[ThemePanel] onDestroy called");
|
||||||
|
|
||||||
// 取消当前操作
|
// 取消当前操作
|
||||||
this.cancelCurrentOperation();
|
this.cancelCurrentOperation();
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import { QRCodeGenerator } from "db://assets/utils/qrcodeGenerator";
|
|||||||
import { TipsPanel } from "./TipsPanel";
|
import { TipsPanel } from "./TipsPanel";
|
||||||
import { SDKManager } from "../../../Main/Channel/SDKManager";
|
import { SDKManager } from "../../../Main/Channel/SDKManager";
|
||||||
import LanguageUtils from "../../../Main/Common/LanguageUtils";
|
import LanguageUtils from "../../../Main/Common/LanguageUtils";
|
||||||
|
import { logger } from "db://assets/Scripts/Main/Common/Logger";
|
||||||
|
|
||||||
const { ccclass, property } = _decorator;
|
const { ccclass, property } = _decorator;
|
||||||
|
|
||||||
@@ -326,7 +327,7 @@ export class Web3PopPanel extends li_BaseView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private onCountdownExpired(): void {
|
private onCountdownExpired(): void {
|
||||||
console.log("Web3支付倒计时已过期");
|
logger.log("Web3支付倒计时已过期");
|
||||||
this.disableButtons();
|
this.disableButtons();
|
||||||
TipsPanel.show("支付时间已过期,请重新发起支付");
|
TipsPanel.show("支付时间已过期,请重新发起支付");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import { InnerMsgCode } from "../../Main/Config/InnerMsgCode";
|
|||||||
import { DataManager, DataId } from "../data/DataManager";
|
import { DataManager, DataId } from "../data/DataManager";
|
||||||
import { GirlData } from "../data/GirlData";
|
import { GirlData } from "../data/GirlData";
|
||||||
import { EnvData } from "../data/EnvData";
|
import { EnvData } from "../data/EnvData";
|
||||||
|
import { logger } from "db://assets/Scripts/Main/Common/Logger";
|
||||||
|
|
||||||
const { ccclass, property } = _decorator;
|
const { ccclass, property } = _decorator;
|
||||||
|
|
||||||
@@ -148,7 +149,7 @@ export class GirlListItem extends Component {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const star = girlData.getStar(this.category.toString(), this.id);
|
const star = girlData.getStar(this.category.toString(), this.id);
|
||||||
console.log("好感度:" + star);
|
logger.log("好感度:" + star);
|
||||||
for (let i = 0; i < this.stars.length; i++) {
|
for (let i = 0; i < this.stars.length; i++) {
|
||||||
const element = this.stars[i];
|
const element = this.stars[i];
|
||||||
if (star > i) {
|
if (star > i) {
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ import { InnerMsgCode } from "../../Main/Config/InnerMsgCode";
|
|||||||
import { DataManager, DataId } from "../data/DataManager";
|
import { DataManager, DataId } from "../data/DataManager";
|
||||||
import { ThemeData } from "../data/ThemeData";
|
import { ThemeData } from "../data/ThemeData";
|
||||||
import { ViewManager } from "../../Main/Manager/ViewManager";
|
import { ViewManager } from "../../Main/Manager/ViewManager";
|
||||||
|
import { logger } from "db://assets/Scripts/Main/Common/Logger";
|
||||||
|
|
||||||
const { ccclass, property } = _decorator;
|
const { ccclass, property } = _decorator;
|
||||||
|
|
||||||
@ccclass("ThemeItem")
|
@ccclass("ThemeItem")
|
||||||
@@ -91,7 +93,7 @@ export class ThemeItem extends Component {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(
|
logger.log(
|
||||||
"[ThemeItem] Opening GirlListPanel for category:",
|
"[ThemeItem] Opening GirlListPanel for category:",
|
||||||
this.category
|
this.category
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
* @version 1.0.0
|
* @version 1.0.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { logger } from "db://assets/Scripts/Main/Common/Logger";
|
||||||
|
|
||||||
export enum ErrorType {
|
export enum ErrorType {
|
||||||
/** API调用错误 */
|
/** API调用错误 */
|
||||||
API_ERROR = "API_ERROR",
|
API_ERROR = "API_ERROR",
|
||||||
@@ -166,18 +168,18 @@ export class ErrorHandler {
|
|||||||
switch (errorInfo.type) {
|
switch (errorInfo.type) {
|
||||||
case ErrorType.API_ERROR:
|
case ErrorType.API_ERROR:
|
||||||
case ErrorType.NETWORK_ERROR:
|
case ErrorType.NETWORK_ERROR:
|
||||||
console.error(logMessage, errorInfo.details);
|
logger.error(logMessage, errorInfo.details);
|
||||||
break;
|
break;
|
||||||
case ErrorType.VALIDATION_ERROR:
|
case ErrorType.VALIDATION_ERROR:
|
||||||
console.warn(logMessage, errorInfo.details);
|
logger.warn(logMessage, errorInfo.details);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
console.log(logMessage, errorInfo.details);
|
logger.log(logMessage, errorInfo.details);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果有堆栈信息,也输出
|
// 如果有堆栈信息,也输出
|
||||||
if (errorInfo.stack) {
|
if (errorInfo.stack) {
|
||||||
console.error("Stack trace:", errorInfo.stack);
|
logger.error("Stack trace:", errorInfo.stack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -205,7 +207,7 @@ export class ErrorHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: 这里应该显示UI提示,比如Toast或对话框
|
// TODO: 这里应该显示UI提示,比如Toast或对话框
|
||||||
console.log("用户提示:", userMessage);
|
logger.log("用户提示:", userMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -220,7 +222,7 @@ export class ErrorHandler {
|
|||||||
*/
|
*/
|
||||||
public clearErrorLog(): void {
|
public clearErrorLog(): void {
|
||||||
this.errorLog = [];
|
this.errorLog = [];
|
||||||
console.log("Error log cleared");
|
logger.log("Error log cleared");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -37,8 +37,6 @@ export function initPolyfills(): void {
|
|||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
};
|
};
|
||||||
|
|
||||||
//console.log('[Polyfill] structuredClone polyfill loaded');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import b from "buffer/index.js";
|
import b from "buffer/index.js";
|
||||||
|
import { logger } from "db://assets/Scripts/Main/Common/Logger";
|
||||||
|
|
||||||
const { Buffer } = b;
|
const { Buffer } = b;
|
||||||
|
|
||||||
export enum EDeserializeError {
|
export enum EDeserializeError {
|
||||||
@@ -153,7 +155,7 @@ export default class ByteBuf {
|
|||||||
return x
|
return x
|
||||||
}
|
}
|
||||||
else if (h < 0xe0) {
|
else if (h < 0xe0) {
|
||||||
// console.log(`== read ${buf.readInt32BE(this._readerIndex)}`)
|
// logger.log(`== read ${buf.readInt32BE(this._readerIndex)}`)
|
||||||
this.ensureRead(3)
|
this.ensureRead(3)
|
||||||
const x = ((h & 0x1f) << 16) | (buf.readUInt16BE(this._readerIndex + 1))
|
const x = ((h & 0x1f) << 16) | (buf.readUInt16BE(this._readerIndex + 1))
|
||||||
this._readerIndex += 3
|
this._readerIndex += 3
|
||||||
@@ -161,7 +163,7 @@ export default class ByteBuf {
|
|||||||
}
|
}
|
||||||
else if (h < 0xf0) {
|
else if (h < 0xf0) {
|
||||||
this.ensureRead(4)
|
this.ensureRead(4)
|
||||||
// console.log(`== read ${buf.readInt32BE(this._readerIndex)}`)
|
// logger.log(`== read ${buf.readInt32BE(this._readerIndex)}`)
|
||||||
const x = buf.readInt32BE(this._readerIndex) & 0x0fffffff
|
const x = buf.readInt32BE(this._readerIndex) & 0x0fffffff
|
||||||
this._readerIndex += 4
|
this._readerIndex += 4
|
||||||
return x
|
return x
|
||||||
@@ -194,12 +196,12 @@ export default class ByteBuf {
|
|||||||
else if (h < 0xc0) {
|
else if (h < 0xc0) {
|
||||||
this.ensureRead(2)
|
this.ensureRead(2)
|
||||||
const x = buf.readUInt16BE(this._readerIndex) & 0x3fff
|
const x = buf.readUInt16BE(this._readerIndex) & 0x3fff
|
||||||
// console.log(`== read long :${x} index:${this._readerIndex}`)
|
// logger.log(`== read long :${x} index:${this._readerIndex}`)
|
||||||
this._readerIndex += 2
|
this._readerIndex += 2
|
||||||
return x
|
return x
|
||||||
}
|
}
|
||||||
else if (h < 0xe0) {
|
else if (h < 0xe0) {
|
||||||
// console.log(`== read ${buf.readInt32BE(this._readerIndex)}`)
|
// logger.log(`== read ${buf.readInt32BE(this._readerIndex)}`)
|
||||||
this.ensureRead(3)
|
this.ensureRead(3)
|
||||||
const x = ((h & 0x1f) << 16) | (buf.readUInt16BE(this._readerIndex + 1))
|
const x = ((h & 0x1f) << 16) | (buf.readUInt16BE(this._readerIndex + 1))
|
||||||
this._readerIndex += 3
|
this._readerIndex += 3
|
||||||
@@ -207,7 +209,7 @@ export default class ByteBuf {
|
|||||||
}
|
}
|
||||||
else if (h < 0xf0) {
|
else if (h < 0xf0) {
|
||||||
this.ensureRead(4)
|
this.ensureRead(4)
|
||||||
// console.log(`== read ${buf.readInt32BE(this._readerIndex)}`)
|
// logger.log(`== read ${buf.readInt32BE(this._readerIndex)}`)
|
||||||
const x = buf.readInt32BE(this._readerIndex) & 0x0fffffff
|
const x = buf.readInt32BE(this._readerIndex) & 0x0fffffff
|
||||||
this._readerIndex += 4
|
this._readerIndex += 4
|
||||||
return x
|
return x
|
||||||
@@ -304,7 +306,7 @@ export default class ByteBuf {
|
|||||||
// TODO 是否要对 < Number.MAX_SAFE_INTEGER 优化处理?
|
// TODO 是否要对 < Number.MAX_SAFE_INTEGER 优化处理?
|
||||||
const xl = buf.readUInt32BE(this._readerIndex + 4)
|
const xl = buf.readUInt32BE(this._readerIndex + 4)
|
||||||
const xh = buf.readUInt32BE(this._readerIndex) & 0xffffff
|
const xh = buf.readUInt32BE(this._readerIndex) & 0xffffff
|
||||||
// console.log(`== read8 ${xl} ${xh}`)
|
// logger.log(`== read8 ${xl} ${xh}`)
|
||||||
this._readerIndex += 8
|
this._readerIndex += 8
|
||||||
return (BigInt(xh) << BigInt(32)) | BigInt(xl)
|
return (BigInt(xh) << BigInt(32)) | BigInt(xl)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { _decorator, Component, Node, Sprite, Label, Button } from 'cc';
|
import { _decorator, Component, Node, Sprite, Label, Button } from 'cc';
|
||||||
import { QRCodeGenerator } from '../../utils/qrcodeGenerator';
|
import { QRCodeGenerator } from '../../utils/qrcodeGenerator';
|
||||||
|
import { logger } from "db://assets/Scripts/Main/Common/Logger";
|
||||||
|
|
||||||
const { ccclass, property } = _decorator;
|
const { ccclass, property } = _decorator;
|
||||||
|
|
||||||
@@ -66,7 +67,7 @@ export class QRCodeGeneratorTest extends Component {
|
|||||||
this.updateStatus(`✓ 成功生成二维码 (${this.currentIndex + 1}/${this.testTexts.length})`);
|
this.updateStatus(`✓ 成功生成二维码 (${this.currentIndex + 1}/${this.testTexts.length})`);
|
||||||
|
|
||||||
// 打印一些调试信息
|
// 打印一些调试信息
|
||||||
console.log('QRCode生成成功:', {
|
logger.log('QRCode生成成功:', {
|
||||||
text: testText,
|
text: testText,
|
||||||
spriteFrame: qrSprite.spriteFrame,
|
spriteFrame: qrSprite.spriteFrame,
|
||||||
size: qrSprite.spriteFrame?.texture?.width + 'x' + qrSprite.spriteFrame?.texture?.height
|
size: qrSprite.spriteFrame?.texture?.width + 'x' + qrSprite.spriteFrame?.texture?.height
|
||||||
@@ -88,10 +89,10 @@ export class QRCodeGeneratorTest extends Component {
|
|||||||
|
|
||||||
// 演示方法3: 生成 Base64 字符串
|
// 演示方法3: 生成 Base64 字符串
|
||||||
// const base64 = QRCodeGenerator.generateQRCodeBase64(testText, 200, 8);
|
// const base64 = QRCodeGenerator.generateQRCodeBase64(testText, 200, 8);
|
||||||
// console.log('QRCode Base64:', base64.substring(0, 100) + '...');
|
// logger.log('QRCode Base64:', base64.substring(0, 100) + '...');
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('QRCode生成测试失败:', error);
|
logger.error('QRCode生成测试失败:', error);
|
||||||
this.updateStatus('✗ 生成失败: ' + error.message);
|
this.updateStatus('✗ 生成失败: ' + error.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -100,7 +101,7 @@ export class QRCodeGeneratorTest extends Component {
|
|||||||
if (this.statusLabel) {
|
if (this.statusLabel) {
|
||||||
this.statusLabel.string = message;
|
this.statusLabel.string = message;
|
||||||
}
|
}
|
||||||
console.log('QRCodeTest:', message);
|
logger.log('QRCodeTest:', message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -109,17 +110,17 @@ export class QRCodeGeneratorTest extends Component {
|
|||||||
public static createQRCodeExample() {
|
public static createQRCodeExample() {
|
||||||
// 示例1: 生成网址二维码(异步)
|
// 示例1: 生成网址二维码(异步)
|
||||||
QRCodeGenerator.generateQRCodeSprite('https://www.example.com', 256, 4, (urlQR) => {
|
QRCodeGenerator.generateQRCodeSprite('https://www.example.com', 256, 4, (urlQR) => {
|
||||||
console.log('URL二维码生成完成:', urlQR);
|
logger.log('URL二维码生成完成:', urlQR);
|
||||||
});
|
});
|
||||||
|
|
||||||
// 示例2: 生成文本二维码,自定义尺寸(异步)
|
// 示例2: 生成文本二维码,自定义尺寸(异步)
|
||||||
QRCodeGenerator.generateQRCodeSpriteFrame('Hello World!', 300, 10, (textQR) => {
|
QRCodeGenerator.generateQRCodeSpriteFrame('Hello World!', 300, 10, (textQR) => {
|
||||||
console.log('文本二维码生成完成:', textQR);
|
logger.log('文本二维码生成完成:', textQR);
|
||||||
});
|
});
|
||||||
|
|
||||||
// 示例3: 生成Base64格式二维码(同步)
|
// 示例3: 生成Base64格式二维码(同步)
|
||||||
const base64QR = QRCodeGenerator.generateQRCodeBase64('测试数据', 150, 5);
|
const base64QR = QRCodeGenerator.generateQRCodeBase64('测试数据', 150, 5);
|
||||||
console.log('Base64二维码生成完成:', base64QR.substring(0, 100) + '...');
|
logger.log('Base64二维码生成完成:', base64QR.substring(0, 100) + '...');
|
||||||
|
|
||||||
return { message: '二维码生成中,请查看控制台日志' };
|
return { message: '二维码生成中,请查看控制台日志' };
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user