From 8eb3f0168863b39c568a3fd67eca2b8e7ccc908d Mon Sep 17 00:00:00 2001 From: chen wei bo <1025839511@qq.com> Date: Mon, 1 Sep 2025 19:07:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9ConfigManager=EF=BC=8C?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E9=85=8D=E7=BD=AE=E6=95=B0=E6=8D=AE=E7=BB=A7?= =?UTF-8?q?=E6=89=BF=E4=BD=93=E7=B3=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chat18x/config/AiCharacterConfig.ts | 50 +++++++++ .../chat18x/config/AiCharacterConfig.ts.meta | 9 ++ assets/Scripts/chat18x/config/GirlConfig.ts | 85 ++++++++++++++ .../Scripts/chat18x/config/GirlConfig.ts.meta | 9 ++ .../chat18x/config/GirlDetailConfig.ts | 105 ++++++++++++++++++ .../chat18x/config/GirlDetailConfig.ts.meta | 9 ++ assets/Scripts/chat18x/config/GlobalConfig.ts | 97 ++++++++++++++++ .../chat18x/config/GlobalConfig.ts.meta | 9 ++ .../Scripts/chat18x/config/PurchaseConfig.ts | 50 +++++++++ .../chat18x/config/PurchaseConfig.ts.meta | 9 ++ assets/Scripts/chat18x/data/DataManager.ts | 18 +-- .../Scripts/chat18x/manager/ConfigManager.ts | 17 ++- 12 files changed, 457 insertions(+), 10 deletions(-) create mode 100644 assets/Scripts/chat18x/config/AiCharacterConfig.ts create mode 100644 assets/Scripts/chat18x/config/AiCharacterConfig.ts.meta create mode 100644 assets/Scripts/chat18x/config/GirlConfig.ts create mode 100644 assets/Scripts/chat18x/config/GirlConfig.ts.meta create mode 100644 assets/Scripts/chat18x/config/GirlDetailConfig.ts create mode 100644 assets/Scripts/chat18x/config/GirlDetailConfig.ts.meta create mode 100644 assets/Scripts/chat18x/config/GlobalConfig.ts create mode 100644 assets/Scripts/chat18x/config/GlobalConfig.ts.meta create mode 100644 assets/Scripts/chat18x/config/PurchaseConfig.ts create mode 100644 assets/Scripts/chat18x/config/PurchaseConfig.ts.meta diff --git a/assets/Scripts/chat18x/config/AiCharacterConfig.ts b/assets/Scripts/chat18x/config/AiCharacterConfig.ts new file mode 100644 index 00000000..88738217 --- /dev/null +++ b/assets/Scripts/chat18x/config/AiCharacterConfig.ts @@ -0,0 +1,50 @@ +/** + * Ai角色配置 + */ +import { BaseConfig } from "./BaseConfig"; +import { ConfigManager } from "../manager/ConfigManager"; + +export class AiCharacterConfig extends BaseConfig { + + public reset(): void { + + } + + public clear(): void { + + } + + public destroy(): void { + super.destroy(); + } + + /** + * 获取所有配置 + */ + protected getAllConfig(): any | null { + return ConfigManager.tables.TbAiCharacters; + } + + /** + * 获取配置,根据 id + */ + protected getConfigById(id: number): any | null { + let allData = this.getAllConfig(); + if (!allData) return null; + return allData.get(id); + } + + /** 根据 id 获取基础提示 */ + public getBasePromptById(id: number): string | null { + let oneData = this.getConfigById(id); + if (!oneData) return null; + return oneData.basePrompt; + } + + /** 根据 id 获取额外提示 */ + public getAdditionPromptById(id: number): string | null { + let oneData = this.getConfigById(id); + if (!oneData) return null; + return oneData.additionPrompt; + } +} \ No newline at end of file diff --git a/assets/Scripts/chat18x/config/AiCharacterConfig.ts.meta b/assets/Scripts/chat18x/config/AiCharacterConfig.ts.meta new file mode 100644 index 00000000..440fc7f0 --- /dev/null +++ b/assets/Scripts/chat18x/config/AiCharacterConfig.ts.meta @@ -0,0 +1,9 @@ +{ + "ver": "4.0.24", + "importer": "typescript", + "imported": true, + "uuid": "82e997ec-36ed-4663-88f5-dc6550348c5d", + "files": [], + "subMetas": {}, + "userData": {} +} diff --git a/assets/Scripts/chat18x/config/GirlConfig.ts b/assets/Scripts/chat18x/config/GirlConfig.ts new file mode 100644 index 00000000..5ddc3a02 --- /dev/null +++ b/assets/Scripts/chat18x/config/GirlConfig.ts @@ -0,0 +1,85 @@ +/** + * 技师的简要配置 + */ +import { BaseConfig } from "./BaseConfig"; +import { ConfigManager } from "../manager/ConfigManager"; + +export class GirlConfig extends BaseConfig { + + public reset(): void { + + } + + public clear(): void { + + } + + public destroy(): void { + super.destroy(); + } + + /** + * 获取所有配置 + */ + protected getAllConfig(): any | null { + return ConfigManager.tables.TbGirls; + } + + /** + * 获取配置,根据 id + */ + protected getConfigById(id: number): any | null { + let allData = this.getAllConfig(); + if (!allData) return null; + return allData.get(id); + } + + /** 根据 id 获取名字 */ + public getNameById(id: number): string | null { + let oneData = this.getConfigById(id); + if (!oneData) return null; + return oneData.nameKey; + } + + /** 根据 id 获取年龄 */ + public getAgeById(id: number): string | null { + let oneData = this.getConfigById(id); + if (!oneData) return null; + return oneData.age; + } + + /** 根据 id 获取分类 */ + public getCategoryById(id: number): number | null { + let oneData = this.getConfigById(id); + if (!oneData) return null; + return oneData.category; + } + + /** 根据 id 获取标签键 */ + public getTagKeyById(id: number): string | null { + let oneData = this.getConfigById(id); + if (!oneData) return null; + return oneData.tagKey; + } + + /** 根据 id 获取付费类型 */ + public getPriceTypeById(id: number): number | null { + let oneData = this.getConfigById(id); + if (!oneData) return null; + return oneData.priceType; + } + + /** 根据 id 获取头像路径 */ + public getAvatarPathById(id: number): string | null { + let oneData = this.getConfigById(id); + if (!oneData) return null; + return oneData.avatarPath; + } + + /** 根据 id 获取头像路径 */ + public getListAvatarPathPathById(id: number): string | null { + let oneData = this.getConfigById(id); + if (!oneData) return null; + return oneData.listAvatarPath; + } +} \ No newline at end of file diff --git a/assets/Scripts/chat18x/config/GirlConfig.ts.meta b/assets/Scripts/chat18x/config/GirlConfig.ts.meta new file mode 100644 index 00000000..3f562046 --- /dev/null +++ b/assets/Scripts/chat18x/config/GirlConfig.ts.meta @@ -0,0 +1,9 @@ +{ + "ver": "4.0.24", + "importer": "typescript", + "imported": true, + "uuid": "a6f7829d-6d80-405d-8f14-ede4365e8213", + "files": [], + "subMetas": {}, + "userData": {} +} diff --git a/assets/Scripts/chat18x/config/GirlDetailConfig.ts b/assets/Scripts/chat18x/config/GirlDetailConfig.ts new file mode 100644 index 00000000..aec2477a --- /dev/null +++ b/assets/Scripts/chat18x/config/GirlDetailConfig.ts @@ -0,0 +1,105 @@ +/** + * 技师的详细配置 + */ +import { BaseConfig } from "./BaseConfig"; +import { ConfigManager } from "../manager/ConfigManager"; + +export class GirlDetailConfig extends BaseConfig { + + public reset(): void { + + } + + public clear(): void { + + } + + public destroy(): void { + super.destroy(); + } + + /** + * 获取所有配置 + */ + protected getAllConfig(): any | null { + return ConfigManager.tables.TbGirlsDetail; + } + + /** + * 获取配置,根据 id + */ + protected getConfigById(id: number): any | null { + let allData = this.getAllConfig(); + if (!allData) return null; + return allData.get(id); + } + + /** 根据 id 获取详细描述 */ + public getDetailDescById(id: number): string | null { + let oneData = this.getConfigById(id); + if (!oneData) return null; + return oneData.detailDesc; + } + + /** 根据 id 获取 commercialImages */ + private getCommercialImagesById(id: number): any | null { + let oneData = this.getConfigById(id); + if (!oneData) return null; + return oneData.commercialImages; + } + + /** 根据 id 和 index 获取图片类型 */ + public getImageTypeById(id: number, index: number): number | null { + let oneData = this.getCommercialImagesById(id); + if (!oneData) return null; + if (index < 0 || index >= oneData.length) return null; + return oneData[index].imageType; + } + + /** 根据 id 和 index 获取图片价格 */ + public getImagePriceById(id: number, index: number): number | null { + let oneData = this.getCommercialImagesById(id); + if (!oneData) return null; + if (index < 0 || index >= oneData.length) return null; + return oneData[index].imagePrice; + } + + /** 根据 id 和 index 获取图片路径 */ + public getImagePathById(id: number, index: number): string | null { + let oneData = this.getCommercialImagesById(id); + if (!oneData) return null; + if (index < 0 || index >= oneData.length) return null; + return oneData[index].path; + } + + /** 根据 id 获取 commercialVideos */ + private getCommercialVideosById(id: number): any | null { + let oneData = this.getConfigById(id); + if (!oneData) return null; + return oneData.commercialVideos; + } + + /** 根据 id 和 index 获取视频路径 */ + public getVideoPathById(id: number, index: number): string | null { + let oneData = this.getCommercialVideosById(id); + if (!oneData) return null; + if (index < 0 || index >= oneData.length) return null; + return oneData[index].path; + } + + /** 根据 id 和 index 获取关联情绪 */ + public getVideoEmotionById(id: number, index: number): number | null { + let oneData = this.getCommercialVideosById(id); + if (!oneData) return null; + if (index < 0 || index >= oneData.length) return null; + return oneData[index].emotion; + } + + /** 根据 id 和 index 获取视频价格 */ + public getVideoPriceById(id: number, index: number): number | null { + let oneData = this.getCommercialVideosById(id); + if (!oneData) return null; + if (index < 0 || index >= oneData.length) return null; + return oneData[index].videoPrice; + } +} \ No newline at end of file diff --git a/assets/Scripts/chat18x/config/GirlDetailConfig.ts.meta b/assets/Scripts/chat18x/config/GirlDetailConfig.ts.meta new file mode 100644 index 00000000..a5154802 --- /dev/null +++ b/assets/Scripts/chat18x/config/GirlDetailConfig.ts.meta @@ -0,0 +1,9 @@ +{ + "ver": "4.0.24", + "importer": "typescript", + "imported": true, + "uuid": "270f3a20-b633-4dd8-8e91-adc0a57a366c", + "files": [], + "subMetas": {}, + "userData": {} +} diff --git a/assets/Scripts/chat18x/config/GlobalConfig.ts b/assets/Scripts/chat18x/config/GlobalConfig.ts new file mode 100644 index 00000000..a371f88f --- /dev/null +++ b/assets/Scripts/chat18x/config/GlobalConfig.ts @@ -0,0 +1,97 @@ +/** + * 全局配置 + */ +import { BaseConfig } from "./BaseConfig"; +import { ConfigManager } from "../manager/ConfigManager"; + +export class GlobalConfig extends BaseConfig { + + public reset(): void { + + } + + public clear(): void { + + } + + public destroy(): void { + super.destroy(); + } + + /** + * 获取所有配置 + */ + protected getAllConfig(): any | null { + return ConfigManager.tables.TbGlobalConfig; + } + + /** 获取api键 */ + public getApiKey(): string | null { + let oneData = this.getAllConfig(); + if (!oneData) return null; + return oneData.ApiKey; + } + + /** 获取情绪判断机器人api */ + public getEmotionApiKey(): string | null { + let oneData = this.getAllConfig(); + if (!oneData) return null; + return oneData.emotionApiKey; + } + + /** 获取情绪判断机器人api */ + public getModel(): string | null { + let oneData = this.getAllConfig(); + if (!oneData) return null; + return oneData.Model; + } + + /** Temperature */ + public getTemperature(): number | null { + let oneData = this.getAllConfig(); + if (!oneData) return null; + return oneData.Temperature; + } + + /** 单次聊天最大token */ + public getMaxTokens(): number | null { + let oneData = this.getAllConfig(); + if (!oneData) return null; + return oneData.MaxTokens; + } + + /** 超时时间(微秒) */ + public getTimeout(): number | null { + let oneData = this.getAllConfig(); + if (!oneData) return null; + return oneData.Timeout; + } + + /** 单个角色免费聊天次数 */ + public getFreeChatTimes(): number | null { + let oneData = this.getAllConfig(); + if (!oneData) return null; + return oneData.FreeChatTimes; + } + + /** 游戏名 */ + public getGameName(): string | null { + let oneData = this.getAllConfig(); + if (!oneData) return null; + return oneData.GameName; + } + + /** 情绪评分机器人system_prompt,需拼接角色prompt */ + public getEmotionRating(): string | null { + let oneData = this.getAllConfig(); + if (!oneData) return null; + return oneData.EmotionRating; + } + + /** ai机器人基础规则 */ + public getGirlBasePrompt(): string | null { + let oneData = this.getAllConfig(); + if (!oneData) return null; + return oneData.girlBasePrompt; + } +} \ No newline at end of file diff --git a/assets/Scripts/chat18x/config/GlobalConfig.ts.meta b/assets/Scripts/chat18x/config/GlobalConfig.ts.meta new file mode 100644 index 00000000..bfd2b975 --- /dev/null +++ b/assets/Scripts/chat18x/config/GlobalConfig.ts.meta @@ -0,0 +1,9 @@ +{ + "ver": "4.0.24", + "importer": "typescript", + "imported": true, + "uuid": "69d3c6fa-3722-4d8d-adff-9c66f59e9484", + "files": [], + "subMetas": {}, + "userData": {} +} diff --git a/assets/Scripts/chat18x/config/PurchaseConfig.ts b/assets/Scripts/chat18x/config/PurchaseConfig.ts new file mode 100644 index 00000000..c97f2fc5 --- /dev/null +++ b/assets/Scripts/chat18x/config/PurchaseConfig.ts @@ -0,0 +1,50 @@ +/** + * 商城配置 + */ +import { BaseConfig } from "./BaseConfig"; +import { ConfigManager } from "../manager/ConfigManager"; + +export class PurchaseConfig extends BaseConfig { + + public reset(): void { + + } + + public clear(): void { + + } + + public destroy(): void { + super.destroy(); + } + + /** + * 获取所有配置 + */ + protected getAllConfig(): any | null { + return ConfigManager.tables.TbPurchaseConfig; + } + + /** + * 获取配置,根据 id + */ + protected getConfigById(id: number): any | null { + let allData = this.getAllConfig(); + if (!allData) return null; + return allData.get(id); + } + + /** 根据商品 id 获取商品名字 */ + public getNameById(id: number): string | null { + let oneData = this.getConfigById(id); + if (!oneData) return null; + return oneData.name; + } + + /** 根据商品 id 获取商品数量 */ + public getCountById(id: number): number | null { + let oneData = this.getConfigById(id); + if (!oneData) return null; + return oneData.count; + } +} \ No newline at end of file diff --git a/assets/Scripts/chat18x/config/PurchaseConfig.ts.meta b/assets/Scripts/chat18x/config/PurchaseConfig.ts.meta new file mode 100644 index 00000000..8df41971 --- /dev/null +++ b/assets/Scripts/chat18x/config/PurchaseConfig.ts.meta @@ -0,0 +1,9 @@ +{ + "ver": "4.0.24", + "importer": "typescript", + "imported": true, + "uuid": "750dc939-fc98-45ad-b3d2-2775cd26c445", + "files": [], + "subMetas": {}, + "userData": {} +} diff --git a/assets/Scripts/chat18x/data/DataManager.ts b/assets/Scripts/chat18x/data/DataManager.ts index 348d4224..3ed67a4b 100644 --- a/assets/Scripts/chat18x/data/DataManager.ts +++ b/assets/Scripts/chat18x/data/DataManager.ts @@ -17,15 +17,15 @@ import { OrderData } from "./OrderData"; * 集中定义数据ID,避免写错字符串 */ export enum DataId { - Login = "login", - Player = "player", - Account = "account", - Meta = "meta", - NetTime = "netTime", - Theme = "theme", - Wallet = "wallet", - Shop = "shop", - Order = "order", + Login = "login", // 登录数据 + Player = "player", // 玩家数据 + Account = "account", // 账号数据 + Meta = "meta", // 元数据 + NetTime = "netTime", // 网络时间数据 + Theme = "theme", // 主题数据 + Wallet = "wallet", // 钱包数据 + Shop = "shop", // 商城数据 + Order = "order", // 订单数据 } /** 构造器类型 */ diff --git a/assets/Scripts/chat18x/manager/ConfigManager.ts b/assets/Scripts/chat18x/manager/ConfigManager.ts index 3a78a16d..283132ea 100644 --- a/assets/Scripts/chat18x/manager/ConfigManager.ts +++ b/assets/Scripts/chat18x/manager/ConfigManager.ts @@ -8,12 +8,22 @@ import * as cfg from "../../schema/schema"; import ByteBuf from "db://assets/Scripts/luban/ByteBuf"; import { BaseConfig } from "../config/BaseConfig"; import { ThemeConfig } from "../config/ThemeConfig"; +import { PurchaseConfig } from "../config/PurchaseConfig"; +import { GlobalConfig } from "../config/GlobalConfig"; +import { GirlConfig } from "../config/GirlConfig"; +import { GirlDetailConfig } from "../config/GirlDetailConfig"; +import { AiCharacterConfig } from "../config/AiCharacterConfig"; /** * 集中定义数据ID,避免写错字符串 */ export enum ConfigId { - Theme = "theme", // 主题配置 + Theme = "theme", // 主题配置 + Purchase = "purchase", // 商城配置 + Global = "global", // 全局配置 + Girl = "girl", // 技师的简要配置 + GirlDetail = "girlDetail", // 技师的详细配置 + AiCharacter = "aiCharacter", // 技师的详细配置 } /** 构造器类型 */ @@ -109,6 +119,11 @@ export class ConfigManager { */ private registerAll(): void { this.register(ConfigId.Theme, ThemeConfig); + this.register(ConfigId.Purchase, PurchaseConfig); + this.register(ConfigId.Global, GlobalConfig); + this.register(ConfigId.Girl, GirlConfig); + this.register(ConfigId.GirlDetail, GirlDetailConfig); + this.register(ConfigId.AiCharacter, AiCharacterConfig); } /**