From 5088bcce733820093f565616f5d8767805e66bf7 Mon Sep 17 00:00:00 2001 From: chen wei bo <1025839511@qq.com> Date: Fri, 5 Sep 2025 09:42:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A8=A1=E6=8B=9F=E6=95=B0=E6=8D=AE=EF=BC=9A?= =?UTF-8?q?=E6=8A=80=E5=B8=88=E7=9A=84=E8=AF=A6=E7=BB=86=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/Scripts/chat18x/data/GirlData.ts | 21 +++++++++++++++++++ .../chat18x/ui/panels/GirlDetailPanel.ts | 6 ++---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/assets/Scripts/chat18x/data/GirlData.ts b/assets/Scripts/chat18x/data/GirlData.ts index 4669df19..f10e0cd0 100644 --- a/assets/Scripts/chat18x/data/GirlData.ts +++ b/assets/Scripts/chat18x/data/GirlData.ts @@ -183,6 +183,27 @@ export class GirlData extends BaseData { return oneData.category; } + /** 获取主题枚举,根据 id */ + public getGrilCategoryById(girlId: number): number { + const cats = this.ensureCategories(); + + for (const bucket of cats.values()) { + // 先查简要信息 + const brief = bucket.briefs.get(girlId); + if (brief && brief.category) { + return brief.category; + } + // 兜底:若只缓存了详情,也从详情里的 brief 取 + const detail = bucket.details.get(girlId); + if (detail?.brief && typeof detail.brief.category) { + return detail.brief.category; + } + } + + // 未找到 + return 0; + } + /** 获取list头像路径 */ public getGrilListAvatar(categoryId: string, girlId: number): string { let oneData = this.getGrilBrief(categoryId, girlId); diff --git a/assets/Scripts/chat18x/ui/panels/GirlDetailPanel.ts b/assets/Scripts/chat18x/ui/panels/GirlDetailPanel.ts index ba95508b..f82f19d3 100644 --- a/assets/Scripts/chat18x/ui/panels/GirlDetailPanel.ts +++ b/assets/Scripts/chat18x/ui/panels/GirlDetailPanel.ts @@ -137,9 +137,8 @@ export class GirlDetailPanel extends li_BaseView { tagKey: string; category: number; async refresh(index: number) { - // TODO,暂时这样获取,修改后从GirlData获取 - const girlConfig = ConfigManager.tables.TbGirls.get(this.id); - this.category = girlConfig.category; + const girlData = DataManager.I.getDataById(DataId.Girl); + this.category = girlData.getGrilCategoryById(this.id); // 请求详细数据 const reqData = { id: this.id, @@ -147,7 +146,6 @@ export class GirlDetailPanel extends li_BaseView { let res = await GirlService.I.reqGetGirlDetail(reqData); if (res && res.code === proto.cs.EnmRetCode.SUCCESS) { // 保存数据 - const girlData = DataManager.I.getDataById(DataId.Girl); girlData.setGirlDetails(this.category.toString(), res.data); // 根据数据,刷新界面 this.nameKey = girlData.getGrilName(this.category.toString(), this.id);