Merge branch 'main' of 47.107.44.202:xionglijia/18xchat
# Conflicts: # assets/Scripts/chat18x/core/ChatAIService.ts # assets/Scripts/chat18x/utils/ErrorHandler.ts # xchat_cfg
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
*/
|
||||
import { BaseData } from "./BaseData";
|
||||
import proto from "db://assets/Scripts/proto/proto.pb.js";
|
||||
import { logger } from "db://assets/Scripts/Main/Common/Logger";
|
||||
|
||||
// 数据结构
|
||||
export interface AiCharacters {
|
||||
@@ -65,10 +66,24 @@ export class AiCharacterData extends BaseData {
|
||||
|
||||
/** 设置Ai角色配置*/
|
||||
public set aiCharacter(data: proto.cs.ICSGetResConfigRes) {
|
||||
const parsed = JSON.parse(data.data);
|
||||
console.log("请求Ai角色配置的解析数据:", parsed);
|
||||
|
||||
|
||||
let parsed: any;
|
||||
try {
|
||||
parsed = JSON.parse(data.data);
|
||||
} catch (e) {
|
||||
logger.warn("AiCharacterData JSON 解析失败", e);
|
||||
return;
|
||||
}
|
||||
// 解析数据
|
||||
let allData = this.parseAllAiCharacters(parsed);
|
||||
// 保存数据
|
||||
for (const oneData of allData) {
|
||||
if (!oneData) continue;
|
||||
// 覆盖或新增
|
||||
if (!this._dataMap.has(oneData.id)) {
|
||||
this._ids.push(oneData.id);
|
||||
}
|
||||
this._dataMap.set(oneData.id, oneData);
|
||||
}
|
||||
}
|
||||
|
||||
/** 获取所有 id */
|
||||
|
||||
@@ -3,6 +3,7 @@ import { Dialog } from "./DialogData";
|
||||
import { ConfigManager } from "../manager/ConfigManager";
|
||||
import { DataId, DataManager } from "./DataManager";
|
||||
import { GirlData } from "./GirlData";
|
||||
import { logger } from "db://assets/Scripts/Main/Common/Logger";
|
||||
|
||||
/**
|
||||
* 单个角色的聊天数据结构
|
||||
@@ -44,7 +45,7 @@ export class ChatModel {
|
||||
*/
|
||||
public initializeRole(categoryId: string, girlId: number): boolean {
|
||||
if (girlId <= 0) {
|
||||
console.error("ChatModel: Invalid roleId provided");
|
||||
logger.error("ChatModel: Invalid roleId provided");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -52,7 +53,7 @@ export class ChatModel {
|
||||
if (this.rolesData.has(girlId)) {
|
||||
this.currentGirlId = girlId;
|
||||
this.updateLastActiveTime(girlId);
|
||||
console.log(`ChatModel: Switched to existing role ${girlId}`);
|
||||
logger.log(`ChatModel: Switched to existing role ${girlId}`);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -64,7 +65,7 @@ export class ChatModel {
|
||||
|
||||
this.rolesData.set(girlId, newRoleData);
|
||||
this.currentGirlId = girlId;
|
||||
console.log(`ChatModel: Initialized new role ${girlId}`);
|
||||
logger.log(`ChatModel: Initialized new role ${girlId}`);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -107,7 +108,7 @@ export class ChatModel {
|
||||
//const roleDetail = ConfigManager.tables.TbGirlsDetail.get(roleId);
|
||||
|
||||
if (!girlData) {
|
||||
console.error(`ChatModel: Role data not found for roleId ${girlId}`);
|
||||
logger.error(`ChatModel: Role data not found for roleId ${girlId}`);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -123,7 +124,7 @@ export class ChatModel {
|
||||
|
||||
return newRoleData;
|
||||
} catch (error) {
|
||||
console.error(
|
||||
logger.error(
|
||||
`ChatModel: Failed to create role data for ${girlId}:`,
|
||||
error
|
||||
);
|
||||
@@ -152,7 +153,7 @@ export class ChatModel {
|
||||
|
||||
if (oldestRoleId !== null) {
|
||||
this.rolesData.delete(oldestRoleId);
|
||||
console.log(`ChatModel: Cleaned up unused role ${oldestRoleId} data`);
|
||||
logger.log(`ChatModel: Cleaned up unused role ${oldestRoleId} data`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,18 +208,18 @@ export class ChatModel {
|
||||
public addDialog(isPlayer: boolean, content: string, roleId?: number): void {
|
||||
const targetRoleId = roleId || this.currentGirlId;
|
||||
if (!targetRoleId) {
|
||||
console.warn("ChatModel: Cannot add dialog - no active role");
|
||||
logger.warn("ChatModel: Cannot add dialog - no active role");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!content || content.trim() === "") {
|
||||
console.warn("ChatModel: Cannot add empty dialog content");
|
||||
logger.warn("ChatModel: Cannot add empty dialog content");
|
||||
return;
|
||||
}
|
||||
|
||||
const roleData = this.rolesData.get(targetRoleId);
|
||||
if (!roleData) {
|
||||
console.warn(`ChatModel: Role data not found for roleId ${targetRoleId}`);
|
||||
logger.warn(`ChatModel: Role data not found for roleId ${targetRoleId}`);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -238,7 +239,7 @@ export class ChatModel {
|
||||
public clearDialogs(roleId?: number): void {
|
||||
const targetRoleId = roleId || this.currentGirlId;
|
||||
if (!targetRoleId) {
|
||||
console.warn("ChatModel: Cannot clear dialogs - no active role");
|
||||
logger.warn("ChatModel: Cannot clear dialogs - no active role");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -246,7 +247,7 @@ export class ChatModel {
|
||||
if (roleData) {
|
||||
roleData.dialogs = [];
|
||||
this.updateLastActiveTime(targetRoleId);
|
||||
console.log(`ChatModel: Dialogs cleared for role ${targetRoleId}`);
|
||||
logger.log(`ChatModel: Dialogs cleared for role ${targetRoleId}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -272,13 +273,13 @@ export class ChatModel {
|
||||
public setCurrentEmotion(emotion: VideoEmotion, roleId?: number): void {
|
||||
const targetRoleId = roleId || this.currentGirlId;
|
||||
if (!targetRoleId) {
|
||||
console.warn("ChatModel: Cannot set emotion - no active role");
|
||||
logger.warn("ChatModel: Cannot set emotion - no active role");
|
||||
return;
|
||||
}
|
||||
|
||||
const roleData = this.rolesData.get(targetRoleId);
|
||||
if (!roleData) {
|
||||
console.warn(`ChatModel: Role data not found for roleId ${targetRoleId}`);
|
||||
logger.warn(`ChatModel: Role data not found for roleId ${targetRoleId}`);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -286,7 +287,7 @@ export class ChatModel {
|
||||
const oldEmotion = roleData.currentEmotion;
|
||||
roleData.currentEmotion = emotion;
|
||||
this.updateLastActiveTime(targetRoleId);
|
||||
console.log(
|
||||
logger.log(
|
||||
`ChatModel: Role ${targetRoleId} emotion changed from ${VideoEmotion[oldEmotion]} to ${VideoEmotion[emotion]}`
|
||||
);
|
||||
}
|
||||
@@ -423,7 +424,7 @@ export class ChatModel {
|
||||
public reset(): void {
|
||||
this.rolesData.clear();
|
||||
this.currentGirlId = null;
|
||||
console.log(
|
||||
logger.log(
|
||||
"ChatModel: All role data cleared and model reset to initial state"
|
||||
);
|
||||
}
|
||||
@@ -441,7 +442,7 @@ export class ChatModel {
|
||||
this.currentGirlId = null;
|
||||
}
|
||||
|
||||
console.log(`ChatModel: Role ${roleId} data cleared`);
|
||||
logger.log(`ChatModel: Role ${roleId} data cleared`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -452,13 +453,13 @@ export class ChatModel {
|
||||
public validate(roleId?: number): boolean {
|
||||
const targetRoleId = roleId || this.currentGirlId;
|
||||
if (!targetRoleId) {
|
||||
console.error("ChatModel: No active role");
|
||||
logger.error("ChatModel: No active role");
|
||||
return false;
|
||||
}
|
||||
|
||||
const roleData = this.rolesData.get(targetRoleId);
|
||||
if (!roleData) {
|
||||
console.error(`ChatModel: Role data not found for ${targetRoleId}`);
|
||||
logger.error(`ChatModel: Role data not found for ${targetRoleId}`);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -500,7 +501,7 @@ export class ChatModel {
|
||||
public setMaxCachedRoles(maxCount: number): void {
|
||||
if (maxCount > 0) {
|
||||
this.maxCachedRoles = maxCount;
|
||||
console.log(`ChatModel: Max cached roles set to ${maxCount}`);
|
||||
logger.log(`ChatModel: Max cached roles set to ${maxCount}`);
|
||||
|
||||
// 如果当前缓存超过新限制,清理多余的
|
||||
this.manageMemory();
|
||||
|
||||
@@ -16,6 +16,7 @@ import { GirlData } from "./GirlData";
|
||||
import { EnvData } from "./EnvData";
|
||||
import { GlobalData } from "./GlobalData";
|
||||
import { AiCharacterData } from "./AiCharacterData";
|
||||
import { logger } from "db://assets/Scripts/Main/Common/Logger";
|
||||
|
||||
/**
|
||||
* 集中定义数据ID,避免写错字符串
|
||||
@@ -63,7 +64,7 @@ export class DataManager {
|
||||
* 初始化:注册 数据ID → 构造器
|
||||
*/
|
||||
public init(): void {
|
||||
console.log("[DataManager] 数据管理器初始化");
|
||||
logger.log("[DataManager] 数据管理器初始化");
|
||||
this.registerAll();
|
||||
}
|
||||
|
||||
@@ -91,7 +92,7 @@ export class DataManager {
|
||||
*/
|
||||
private register<T extends BaseData>(dataId: string, ctor: DataCtor<T>): void {
|
||||
if (this._config.has(dataId)) {
|
||||
console.warn(`[DataManager] 重复注册数据ID: ${dataId},将覆盖旧构造器`);
|
||||
logger.warn(`[DataManager] 重复注册数据ID: ${dataId},将覆盖旧构造器`);
|
||||
}
|
||||
this._config.set(dataId, ctor);
|
||||
}
|
||||
@@ -107,7 +108,7 @@ export class DataManager {
|
||||
// 缓存没有→ 查找构造器
|
||||
const Ctor = this._config.get(dataId) as DataCtor<T> | undefined;
|
||||
if (!Ctor) {
|
||||
console.warn(`[DataManager] 未找到 dataId 的构造器配置: ${dataId}`);
|
||||
logger.warn(`[DataManager] 未找到 dataId 的构造器配置: ${dataId}`);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import { BaseData } from "./BaseData";
|
||||
import proto from 'db://assets/Scripts/proto/proto.pb.js';
|
||||
import Utils from "../../Main/Common/Utils";
|
||||
import { InnerMsgCode } from "../../Main/Config/InnerMsgCode";
|
||||
import { logger } from "db://assets/Scripts/Main/Common/Logger";
|
||||
|
||||
export class GirlChatData extends BaseData {
|
||||
// id
|
||||
@@ -75,7 +76,7 @@ export class GirlChatData extends BaseData {
|
||||
chatTotalCount: this.chatTotalCount,
|
||||
};
|
||||
Utils.sendInnerMsg(InnerMsgCode.ChatTotalCountChange, msgData);
|
||||
console.log("当前技师 ", this.id, " ,总聊天次数:", this.chatTotalCount);
|
||||
logger.log("当前技师 ", this.id, " ,总聊天次数:", this.chatTotalCount);
|
||||
}
|
||||
|
||||
/** 获取剩余聊天次数 */
|
||||
@@ -86,7 +87,7 @@ export class GirlChatData extends BaseData {
|
||||
/** 保存剩余聊天次数 */
|
||||
public setChatRemainCount(value: number): void {
|
||||
this.chatRemainCount = value;
|
||||
console.log("当前技师 ", this.id, " ,剩余聊天次数:", this.chatRemainCount);
|
||||
logger.log("当前技师 ", this.id, " ,剩余聊天次数:", this.chatRemainCount);
|
||||
}
|
||||
|
||||
/** 更新剩余聊天次数 */
|
||||
@@ -143,7 +144,7 @@ export class GirlChatData extends BaseData {
|
||||
// 排序:根据 msgId 从大到小排序
|
||||
this.chatRecordIds.sort((a, b) => b - a);
|
||||
|
||||
console.log("当前技师 ", this.id, " ,聊天记录:", this.chatRecord);
|
||||
logger.log("当前技师 ", this.id, " ,聊天记录:", this.chatRecord);
|
||||
}
|
||||
|
||||
/** 获取聊天记录的所有 id */
|
||||
|
||||
@@ -10,6 +10,7 @@ import { GirlFavorabilityData } from "./GirlFavorabilityData";
|
||||
import { DataId } from "./DataManager";
|
||||
import proto from "db://assets/Scripts/proto/proto.pb.js";
|
||||
import { PriceType } from "../../schema/schema";
|
||||
import { logger } from "db://assets/Scripts/Main/Common/Logger";
|
||||
|
||||
// 分类的数据结构
|
||||
interface CategoryBucket {
|
||||
@@ -90,7 +91,7 @@ export class GirlData extends BaseData {
|
||||
this.setGirlFavorability(categoryId, data.girls);
|
||||
|
||||
const bucket = this.ensureBucket(categoryId);
|
||||
console.log("保存类别 ", categoryId, " 的技师列表: ", bucket);
|
||||
logger.log("保存类别 ", categoryId, " 的技师列表: ", bucket);
|
||||
}
|
||||
|
||||
/** 保存技师详细数据 */
|
||||
@@ -108,7 +109,7 @@ export class GirlData extends BaseData {
|
||||
this.setGirlFavorability(categoryId, details);
|
||||
|
||||
const bucket = this.ensureBucket(categoryId);
|
||||
console.log("保存类别 ", categoryId, " 的详细数据: ", bucket);
|
||||
logger.log("保存类别 ", categoryId, " 的详细数据: ", bucket);
|
||||
}
|
||||
|
||||
/** --------------------------------------------------------- 技师的简要数据 --------------------------------------------------------- */
|
||||
@@ -967,7 +968,7 @@ export class GirlData extends BaseData {
|
||||
if (!data) return;
|
||||
this.mergeOneBrief(DAILY_BUCKET, data.girl);
|
||||
const bucket = this.ensureBucket(DAILY_BUCKET);
|
||||
console.log("保存每日推荐: ", bucket);
|
||||
logger.log("保存每日推荐: ", bucket);
|
||||
}
|
||||
|
||||
/** 判断每日推荐是否存在 */
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
*/
|
||||
import { BaseData } from "./BaseData";
|
||||
import proto from 'db://assets/Scripts/proto/proto.pb.js';
|
||||
import { logger } from "db://assets/Scripts/Main/Common/Logger";
|
||||
|
||||
export class GirlUnlockData extends BaseData {
|
||||
// id
|
||||
@@ -81,7 +82,7 @@ export class GirlUnlockData extends BaseData {
|
||||
if (!exists) {
|
||||
this.unlockedImageIds.push(id);
|
||||
}
|
||||
console.log("技师 ", this.id, " 当前解锁图片的所有id:",this.unlockedImageIds);
|
||||
logger.log("技师 ", this.id, " 当前解锁图片的所有id:",this.unlockedImageIds);
|
||||
}
|
||||
|
||||
/** 获取所有解锁图片的 id */
|
||||
@@ -113,7 +114,7 @@ export class GirlUnlockData extends BaseData {
|
||||
if (!exists) {
|
||||
this.unlockedVideoIds.push(id);
|
||||
}
|
||||
console.log("技师 ", this.id, " 当前解锁视频的所有id:",this.unlockedVideoIds);
|
||||
logger.log("技师 ", this.id, " 当前解锁视频的所有id:",this.unlockedVideoIds);
|
||||
}
|
||||
|
||||
/** 获取所有解锁视频的 id */
|
||||
|
||||
@@ -93,7 +93,6 @@ export class GlobalData extends BaseData {
|
||||
this._gameName = obj.GameName;
|
||||
this._emotionBasePrompt = obj.EmotionBasePrompt;
|
||||
this._girlBasePrompt = obj.girlBasePrompt;
|
||||
console.log("设置全局数据: ", this._gameName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import proto from 'db://assets/Scripts/proto/proto.pb.js';
|
||||
import type { OrderVO, OrderStatus } from 'db://assets/Scripts/chat18x/payment/types';
|
||||
import { mapQueryOrderStatus, shouldPoll } from 'db://assets/Scripts/chat18x/payment/PaymentUtil';
|
||||
import { sys } from "cc";
|
||||
import { logger } from "db://assets/Scripts/Main/Common/Logger";
|
||||
|
||||
const ORDER_STORAGE_KEY = "order_data_v1";
|
||||
|
||||
@@ -44,7 +45,7 @@ export class OrderData extends BaseData {
|
||||
createdAt: Date.now(), // 订单创建时间,毫秒
|
||||
};
|
||||
this._orders.set(orderId, vo);
|
||||
console.log("保存订单数据:", this._orders);
|
||||
logger.log("保存订单数据:", this._orders);
|
||||
}
|
||||
|
||||
/** 根据订单 id 获取订单数据 */
|
||||
@@ -68,7 +69,7 @@ export class OrderData extends BaseData {
|
||||
vo.status = mapQueryOrderStatus(res.status);
|
||||
vo.retCode = res.retCode ?? 0;
|
||||
this._orders.set(orderId, vo);
|
||||
console.log("更新订单数据:", vo);
|
||||
logger.log("更新订单数据:", vo);
|
||||
}
|
||||
|
||||
/** 获取所有需要继续轮询查询的订单 id */
|
||||
@@ -172,9 +173,9 @@ export class OrderData extends BaseData {
|
||||
map.set(vo.orderId, vo);
|
||||
}
|
||||
}
|
||||
console.log("加载本地订单数据:", map);
|
||||
logger.log("加载本地订单数据:", map);
|
||||
} catch (e) {
|
||||
console.warn("[OrderData] loadStorage parse error:", e);
|
||||
logger.warn("[OrderData] loadStorage parse error:", e);
|
||||
this.ensureMap().clear();
|
||||
}
|
||||
}
|
||||
@@ -190,9 +191,9 @@ export class OrderData extends BaseData {
|
||||
orders,
|
||||
};
|
||||
sys.localStorage.setItem(ORDER_STORAGE_KEY, JSON.stringify(payload));
|
||||
console.log("保存本地订单数据:", payload);
|
||||
logger.log("保存本地订单数据:", payload);
|
||||
} catch (e) {
|
||||
console.warn("[OrderData] saveStorage error:", e);
|
||||
logger.warn("[OrderData] saveStorage error:", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
*/
|
||||
import { BaseData } from "./BaseData";
|
||||
import proto from 'db://assets/Scripts/proto/proto.pb.js';
|
||||
import { logger } from "db://assets/Scripts/Main/Common/Logger";
|
||||
|
||||
export class ShopData extends BaseData {
|
||||
// 商品数据
|
||||
@@ -41,7 +42,7 @@ export class ShopData extends BaseData {
|
||||
this._goods.set(vo.id, vo);
|
||||
this._goodIds.push(vo.id);
|
||||
}
|
||||
console.log("设置商品数据:", this._goods);
|
||||
logger.log("设置商品数据:", this._goods);
|
||||
}
|
||||
|
||||
/** 获取所有商品数据 */
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
*/
|
||||
import { BaseData } from "./BaseData";
|
||||
import proto from 'db://assets/Scripts/proto/proto.pb.js';
|
||||
import { logger } from "db://assets/Scripts/Main/Common/Logger";
|
||||
|
||||
export class ThemeData extends BaseData {
|
||||
// 主题数据
|
||||
@@ -43,7 +44,7 @@ export class ThemeData extends BaseData {
|
||||
this._themes.set(vo.id, vo);
|
||||
this._themeIds.push(vo.id);
|
||||
}
|
||||
console.log("设置主题数据:", this._themes);
|
||||
logger.log("设置主题数据:", this._themes);
|
||||
}
|
||||
|
||||
/** 获取所有主题数据 */
|
||||
|
||||
Reference in New Issue
Block a user