修改ConfigManager,定义配置数据继承体系

This commit is contained in:
chen wei bo
2025-09-01 19:07:24 +08:00
parent c9817ea13e
commit 8eb3f01688
12 changed files with 457 additions and 10 deletions
@@ -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;
}
}
@@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "82e997ec-36ed-4663-88f5-dc6550348c5d",
"files": [],
"subMetas": {},
"userData": {}
}
@@ -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;
}
}
@@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "a6f7829d-6d80-405d-8f14-ede4365e8213",
"files": [],
"subMetas": {},
"userData": {}
}
@@ -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;
}
}
@@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "270f3a20-b633-4dd8-8e91-adc0a57a366c",
"files": [],
"subMetas": {},
"userData": {}
}
@@ -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;
}
}
@@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "69d3c6fa-3722-4d8d-adff-9c66f59e9484",
"files": [],
"subMetas": {},
"userData": {}
}
@@ -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;
}
}
@@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "750dc939-fc98-45ad-b3d2-2775cd26c445",
"files": [],
"subMetas": {},
"userData": {}
}