请求AI角色配置

This commit is contained in:
chen wei bo
2025-09-20 20:37:31 +08:00
parent 70791a0ce2
commit 3a52e51c39
4 changed files with 66 additions and 2 deletions
+15
View File
@@ -33,6 +33,7 @@ import DeviceIdService from "db://assets/Scripts/chat18x/foundation/identity/Dev
import { AccountData } from "../../chat18x/data/AccountData";
import { EnvData } from "../../chat18x/data/EnvData";
import { GlobalData } from "../../chat18x/data/GlobalData";
import { AiCharacterData } from "../../chat18x/data/AiCharacterData";
import { LoginData } from "../../chat18x/data/LoginData";
import { PlayerData } from "../../chat18x/data/PlayerData";
import { WalletData } from "../../chat18x/data/WalletData";
@@ -215,6 +216,7 @@ export class PreloadUI extends Component {
this.loginFinish = true;
this.reqMyInfo();
this.reqGlobalData();
this.reqAiCharacterData();
}
}
@@ -244,6 +246,19 @@ export class PreloadUI extends Component {
}
}
// 请求Ai角色配置
private async reqAiCharacterData() {
const reqData = {
resName: "TbAiCharacters",
};
let res = await CommonService.I.reqResConfig(reqData);
if (res && res.code === proto.cs.EnmRetCode.SUCCESS) {
// 保存数据
const aiCharacterData = DataManager.I.getDataById<AiCharacterData>(DataId.AiCharacter);
aiCharacterData.aiCharacter = res.data;
}
}
private enterGame() {
this.mainScene.init();
this.node.destroy();
@@ -0,0 +1,37 @@
/**
* Ai角色配置
*/
import { BaseData } from "./BaseData";
import proto from "db://assets/Scripts/proto/proto.pb.js";
export class AiCharacterData extends BaseData {
// api键
private _apiKey: string = "";
public reset(): void {
this._apiKey = "";
}
public clear(): void {
this._apiKey = "";
}
public destroy(): void {
super.destroy();
this._apiKey = null;
}
/** 设置Ai角色配置*/
public set aiCharacter(data: proto.cs.ICSGetResConfigRes) {
const parsed = JSON.parse(data.data);
console.log("请求Ai角色配置的解析数据:", parsed);
}
/** 获取api键 */
public getApiKey(): string {
return this._apiKey;
}
}
@@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "919de17f-ee9c-4c82-a303-cd33cea81178",
"files": [],
"subMetas": {},
"userData": {}
}
+5 -2
View File
@@ -15,6 +15,7 @@ import { OrderData } from "./OrderData";
import { GirlData } from "./GirlData";
import { EnvData } from "./EnvData";
import { GlobalData } from "./GlobalData";
import { AiCharacterData } from "./AiCharacterData";
/**
* 集中定义数据ID,避免写错字符串
@@ -35,8 +36,9 @@ export enum DataId {
GirlUnlock = "girlUnlock", // 技师的解锁数据
GirlChat = "girlChat", // 技师的聊天数据
GirlFavorability = "girlFavorability", // 技师的好感度数据
Env = "env", // 环境数据
Global = "global", // 全局数据
Env = "env", // 环境数据
Global = "global", // 全局数据
AiCharacter = "aiCharacter", // Ai角色配置
}
/** 构造器类型 */
@@ -81,6 +83,7 @@ export class DataManager {
this.register(DataId.Girl, GirlData);
this.register(DataId.Env, EnvData);
this.register(DataId.Global, GlobalData);
this.register(DataId.AiCharacter, AiCharacterData);
}
/**