Merge branch 'main' of 47.107.44.202:xionglijia/18xchat

This commit is contained in:
2025-10-10 18:21:37 +08:00
10 changed files with 256 additions and 34 deletions
@@ -38,6 +38,7 @@ export enum DataId {
GirlChat = "girlChat", // 技师的聊天数据
GirlFavorability = "girlFavorability", // 技师的好感度数据
GirlRank = "girlRank", // 技师的排行榜数据
GirlRecommend = "girlRecommend", // 技师的推荐数据
GirlOther = "girlOther", // 技师的其他数据
Env = "env", // 环境数据
Global = "global", // 全局数据
+96
View File
@@ -8,6 +8,7 @@ import { GirlUnlockData } from "./GirlUnlockData";
import { GirlChatData } from "./GirlChatData";
import { GirlFavorabilityData } from "./GirlFavorabilityData";
import { GirlRankData } from "./GirlRankData";
import { GirlRecommendData } from "./GirlRecommendData";
import { GirlOtherData } from "./GirlOtherData";
import { DataId } from "./DataManager";
import proto from "db://assets/Scripts/proto/proto.pb.js";
@@ -40,27 +41,34 @@ export class GirlData extends BaseData {
private _categories = new Map<string, CategoryBucket>();
// 排行榜数据
private _rankData: GirlRankData;
// 推荐数据
private _recommendData: GirlRecommendData;
constructor() {
super();
this._rankData = new GirlRankData();
this._rankData.init?.(DataId.GirlRank);
this._recommendData = new GirlRecommendData();
this._recommendData.init?.(DataId.GirlRecommend);
}
public reset(): void {
this._categories.clear();
this._rankData.clear();
this._recommendData.clear();
}
public clear(): void {
this._categories.clear();
this._rankData.clear();
this._recommendData.clear();
}
public destroy(): void {
super.destroy();
this._categories = null;
this._rankData = null;
this._recommendData = null;
}
/** 保障 _categories 存在 */
@@ -90,6 +98,39 @@ export class GirlData extends BaseData {
return bucket;
}
/** 清空分类桶,单个 */
private clearOneBucket(categoryId: string): void {
const cats = this.ensureCategories();
const bucket = cats.get(categoryId);
if (bucket) {
// 清空具体分类的所有数据
bucket.briefs.clear();
bucket.details.clear();
bucket.unlocks.clear();
bucket.chats.clear();
bucket.favorability.clear();
bucket.other.clear();
bucket.girlIds.splice(0); // 使用 splice 清空 girlIds 数组
logger.log(`清空分类桶 ${categoryId}`);
}
}
/** 清空分类桶,所有 */
private clearAllBucket(): void {
const cats = this.ensureCategories();
// 遍历所有分类桶并清空
cats.forEach((bucket, categoryId) => {
bucket.briefs.clear();
bucket.details.clear();
bucket.unlocks.clear();
bucket.chats.clear();
bucket.favorability.clear();
bucket.other.clear();
bucket.girlIds.splice(0); // 使用 splice 清空 girlIds 数组
});
logger.log("清空所有分类桶");
}
/** 取分类下的全部 girlIds(若分类不存在返回空数组) */
public getGirlIds(categoryId: string): number[] {
const b = this.ensureCategories().get(categoryId);
@@ -206,6 +247,61 @@ export class GirlData extends BaseData {
return oneData.getGrilAvatar();
}
/** --------------------------------------------------------- 技师的推荐数据 --------------------------------------------------------- */
/** 清空 推荐数据 */
public clearRecommendData(): void {
if (!this._recommendData) return;
this._recommendData.clear();
}
/** 保存 推荐列表 */
public setRecommendList(data: proto.cs.ICSRecommendRes): void {
if (!data) return;
let arrayData = data.girls;
// 遍历
for (const oneData of arrayData) {
let briefData = oneData.girl;
let categoryId = briefData.category;
this.mergeOneBrief(categoryId.toString(), briefData);
let theArray = [];
theArray.push(oneData);
this.setGirlUnlock(categoryId.toString(), theArray);
this.setGirlFavorability(categoryId.toString(), theArray);
this.setGirlOther(categoryId.toString(), theArray);
}
this._recommendData.setRecommendList(arrayData);
const cats = this.ensureCategories();
logger.log("保存推荐列表后,大分类的数据: ", cats);
}
/** 添加 推荐列表 */
public addRecommendList(data: proto.cs.ICSRecommendRes): void {
if (!data) return;
let arrayData = data.girls;
// 遍历
for (const oneData of arrayData) {
let briefData = oneData.girl;
let categoryId = briefData.category;
this.mergeOneBrief(categoryId.toString(), briefData);
let theArray = [];
theArray.push(oneData);
this.setGirlUnlock(categoryId.toString(), theArray);
this.setGirlFavorability(categoryId.toString(), theArray);
this.setGirlOther(categoryId.toString(), theArray);
}
this._recommendData.addRecommendList(arrayData);
const cats = this.ensureCategories();
logger.log("添加推荐列表后,大分类的数据: ", cats);
}
/** 获取 推荐列表 id */
public getRecommendListIds(): number[] {
if (!this._recommendData) return [];
const ids = this._recommendData.getRecommendListIds();
return ids;
}
/** --------------------------------------------------------- 技师的排行榜数据 --------------------------------------------------------- */
/** 清空 排行榜数据 */
@@ -0,0 +1,72 @@
/**
* 技师的推荐数据
*/
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 GirlRecommendData extends BaseData {
// 推荐列表,id
private idList: number[];
constructor() {
super();
this.idList = [];
}
public reset(): void {
this.idList = [];
}
public clear(): void {
this.idList = [];
}
public destroy(): void {
super.destroy();
this.idList = null;
}
/** 保存 推荐列表 */
public setRecommendList(data: proto.cs.IGirlData[]): void {
if (!data || data.length === 0) return;
// 清空现有 idList
this.idList = [];
// 使用 Set 去重并提取 id
const idSet = new Set<number>();
for (const item of data) {
if (item && item.id != null) {
idSet.add(item.id); // 添加到 Set 中去重
}
}
// 将去重后的 id 转换为数组并赋值给 idList
this.idList = Array.from(idSet);
logger.log("保存推荐列表:", this.idList);
}
/** 添加 推荐列表 */
public addRecommendList(data: proto.cs.IGirlData[]): void {
if (!data || data.length === 0) return;
// 使用 Set 来去重
const idSet = new Set(this.idList); // 创建一个基于当前 idList 的 Set
// 依次添加新的 id(保持顺序 + 去重)
for (const item of data) {
if (item && item.id != null && !idSet.has(item.id)) {
idSet.add(item.id); // 添加到 Set 中去重
this.idList.push(item.id); // 添加到 idList 中
}
}
logger.log("添加推荐列表:", this.idList);
}
/** 获取 推荐列表 id */
public getRecommendListIds(): number[] {
return this.idList;
}
}
@@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "38b5e732-c4b2-45e1-825f-1dc189c4f630",
"files": [],
"subMetas": {},
"userData": {}
}
@@ -29,6 +29,11 @@ export class GirlService implements IGirlService {
return this.impl.reqDailyRecommend(req);
}
// 推荐列表
public async reqRecommendList(req: proto.cs.ICSRecommendReq): Promise<ApiResponse<proto.cs.ICSRecommendRes>> {
return this.impl.reqRecommendList(req);
}
// 获取技师列表
public async reqGetGirlList(req: proto.cs.ICSGetGirlListReq): Promise<ApiResponse<proto.cs.ICSGetGirlListRes>> {
return this.impl.reqGetGirlList(req);
@@ -18,6 +18,17 @@ export class HttpGirlService implements IGirlService {
return this.api.call(epData, req);
}
// 推荐列表
async reqRecommendList(req: proto.cs.ICSRecommendReq): Promise<ApiResponse<proto.cs.ICSRecommendRes>> {
let epData: Endpoint<proto.cs.ICSRecommendReq, proto.cs.ICSRecommendRes> = {
path: "api/logic/recommend",
method: "POST",
codec: "json",
needsAuth: true
};
return this.api.call(epData, req);
}
// 获取技师列表
async reqGetGirlList(req: proto.cs.ICSGetGirlListReq): Promise<ApiResponse<proto.cs.ICSGetGirlListRes>> {
let epData: Endpoint<proto.cs.ICSGetGirlListReq, proto.cs.ICSGetGirlListRes> = {
@@ -4,6 +4,8 @@ import proto from "db://assets/Scripts/proto/proto.pb.js";
export interface IGirlService {
// 每日推荐
reqDailyRecommend(req: proto.cs.ICSDailyRecommendReq): Promise<ApiResponse<proto.cs.ICSDailyRecommendRes>>;
// 推荐列表
reqRecommendList(req: proto.cs.ICSRecommendReq): Promise<ApiResponse<proto.cs.ICSRecommendRes>>;
// 获取技师列表
reqGetGirlList(req: proto.cs.ICSGetGirlListReq): Promise<ApiResponse<proto.cs.ICSGetGirlListRes>>;
// 获取技师详细信息
@@ -102,6 +102,20 @@ export class MockGirlService implements IGirlService {
return this.ok(res);
}
// 推荐列表
async reqRecommendList(req: proto.cs.ICSRecommendReq): Promise<ApiResponse<proto.cs.ICSRecommendRes>> {
// 延时
await this.delay(180);
// TODO
// 返回数据
const res: proto.cs.ICSRecommendRes = {
girls: [],
};
return this.ok(res);
}
// 获取技师列表
async reqGetGirlList(req: proto.cs.ICSGetGirlListReq): Promise<ApiResponse<proto.cs.ICSGetGirlListRes>> {
// 延时
@@ -304,6 +318,9 @@ export class MockGirlService implements IGirlService {
// 获取可聊天的技师数据
async reqCanChatGirlData(req: proto.cs.ICSGetLastChatListReq): Promise<ApiResponse<proto.cs.ICSGetLastChatListRes>> {
// 延时
await this.delay(180);
// TODO
// 返回数据
@@ -326,6 +343,9 @@ export class MockGirlService implements IGirlService {
// 查看图片或者视频上报,用于排行榜
async reqViewGirl(req: proto.cs.ICSViewGirlReq): Promise<ApiResponse<proto.cs.ICSViewGirlRes>> {
// 延时
await this.delay(180);
// TODO
// 返回数据
@@ -337,6 +357,9 @@ export class MockGirlService implements IGirlService {
// 收藏技师
async reqBookmarkGirl(req: proto.cs.ICSBookmarkReq): Promise<ApiResponse<proto.cs.ICSBookmarkRes>> {
// 延时
await this.delay(180);
// TODO
// 返回数据
@@ -348,6 +371,9 @@ export class MockGirlService implements IGirlService {
// 获取收藏列表
async reqBookmarkGirlList(req: proto.cs.ICSGetBookmarkReq): Promise<ApiResponse<proto.cs.ICSGetBookmarkRes>> {
// 延时
await this.delay(180);
// TODO
// 返回数据
+4 -4
View File
@@ -4509,8 +4509,8 @@ static getTypeUrl(typeUrlPrefix?: string): string;
/** Properties of a CSRecommendRes. */
interface ICSRecommendRes {
/** CSRecommendRes girl */
girl?: (cs.IGirls[]|null);
/** CSRecommendRes girls */
girls?: (cs.IGirlData[]|null);
}
/** Represents a CSRecommendRes. */
@@ -4522,8 +4522,8 @@ static getTypeUrl(typeUrlPrefix?: string): string;
*/
constructor(properties?: cs.ICSRecommendRes);
/** CSRecommendRes girl. */
girl: cs.IGirls[];
/** CSRecommendRes girls. */
girls: cs.IGirlData[];
/**
* Creates a new CSRecommendRes instance using the specified properties.
+30 -30
View File
@@ -10495,7 +10495,7 @@ $root.cs = (function() {
* Properties of a CSRecommendRes.
* @memberof cs
* @interface ICSRecommendRes
* @property {Array.<cs.IGirls>|null} [girl] CSRecommendRes girl
* @property {Array.<cs.IGirlData>|null} [girls] CSRecommendRes girls
*/
/**
@@ -10507,7 +10507,7 @@ $root.cs = (function() {
* @param {cs.ICSRecommendRes=} [properties] Properties to set
*/
function CSRecommendRes(properties) {
this.girl = [];
this.girls = [];
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
@@ -10515,12 +10515,12 @@ $root.cs = (function() {
}
/**
* CSRecommendRes girl.
* @member {Array.<cs.IGirls>} girl
* CSRecommendRes girls.
* @member {Array.<cs.IGirlData>} girls
* @memberof cs.CSRecommendRes
* @instance
*/
CSRecommendRes.prototype.girl = $util.emptyArray;
CSRecommendRes.prototype.girls = $util.emptyArray;
/**
* Creates a new CSRecommendRes instance using the specified properties.
@@ -10546,9 +10546,9 @@ $root.cs = (function() {
CSRecommendRes.encode = function encode(message, writer) {
if (!writer)
writer = $Writer.create();
if (message.girl != null && message.girl.length)
for (var i = 0; i < message.girl.length; ++i)
$root.cs.Girls.encode(message.girl[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim();
if (message.girls != null && message.girls.length)
for (var i = 0; i < message.girls.length; ++i)
$root.cs.GirlData.encode(message.girls[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim();
return writer;
};
@@ -10586,9 +10586,9 @@ $root.cs = (function() {
break;
switch (tag >>> 3) {
case 1: {
if (!(message.girl && message.girl.length))
message.girl = [];
message.girl.push($root.cs.Girls.decode(reader, reader.uint32()));
if (!(message.girls && message.girls.length))
message.girls = [];
message.girls.push($root.cs.GirlData.decode(reader, reader.uint32()));
break;
}
default:
@@ -10626,13 +10626,13 @@ $root.cs = (function() {
CSRecommendRes.verify = function verify(message) {
if (typeof message !== "object" || message === null)
return "object expected";
if (message.girl != null && message.hasOwnProperty("girl")) {
if (!Array.isArray(message.girl))
return "girl: array expected";
for (var i = 0; i < message.girl.length; ++i) {
var error = $root.cs.Girls.verify(message.girl[i]);
if (message.girls != null && message.hasOwnProperty("girls")) {
if (!Array.isArray(message.girls))
return "girls: array expected";
for (var i = 0; i < message.girls.length; ++i) {
var error = $root.cs.GirlData.verify(message.girls[i]);
if (error)
return "girl." + error;
return "girls." + error;
}
}
return null;
@@ -10650,14 +10650,14 @@ $root.cs = (function() {
if (object instanceof $root.cs.CSRecommendRes)
return object;
var message = new $root.cs.CSRecommendRes();
if (object.girl) {
if (!Array.isArray(object.girl))
throw TypeError(".cs.CSRecommendRes.girl: array expected");
message.girl = [];
for (var i = 0; i < object.girl.length; ++i) {
if (typeof object.girl[i] !== "object")
throw TypeError(".cs.CSRecommendRes.girl: object expected");
message.girl[i] = $root.cs.Girls.fromObject(object.girl[i]);
if (object.girls) {
if (!Array.isArray(object.girls))
throw TypeError(".cs.CSRecommendRes.girls: array expected");
message.girls = [];
for (var i = 0; i < object.girls.length; ++i) {
if (typeof object.girls[i] !== "object")
throw TypeError(".cs.CSRecommendRes.girls: object expected");
message.girls[i] = $root.cs.GirlData.fromObject(object.girls[i]);
}
}
return message;
@@ -10677,11 +10677,11 @@ $root.cs = (function() {
options = {};
var object = {};
if (options.arrays || options.defaults)
object.girl = [];
if (message.girl && message.girl.length) {
object.girl = [];
for (var j = 0; j < message.girl.length; ++j)
object.girl[j] = $root.cs.Girls.toObject(message.girl[j], options);
object.girls = [];
if (message.girls && message.girls.length) {
object.girls = [];
for (var j = 0; j < message.girls.length; ++j)
object.girls[j] = $root.cs.GirlData.toObject(message.girls[j], options);
}
return object;
};