Merge branch 'main' of 47.107.44.202:xionglijia/18xchat
This commit is contained in:
@@ -26,6 +26,7 @@ export class MainController {
|
|||||||
// 数据预加载状态标记
|
// 数据预加载状态标记
|
||||||
private isThemeDataPreloaded: boolean = false;
|
private isThemeDataPreloaded: boolean = false;
|
||||||
private isDailyRecommendPreloaded: boolean = false;
|
private isDailyRecommendPreloaded: boolean = false;
|
||||||
|
private isRecommendListPreloaded: boolean = false;
|
||||||
private isShopListPreloaded: boolean = false;
|
private isShopListPreloaded: boolean = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -38,6 +39,7 @@ export class MainController {
|
|||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.preloadThemeData(),
|
this.preloadThemeData(),
|
||||||
this.preloadDailyRecommend(),
|
this.preloadDailyRecommend(),
|
||||||
|
this.preloadRecommendList(true, 1, 10),
|
||||||
this.preloadShopList(),
|
this.preloadShopList(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -106,6 +108,47 @@ export class MainController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请求技师推荐列表
|
||||||
|
* @param isFirstReq 是否首次请求(true 表示首次请求,将覆盖旧数据;false 表示分页加载,追加数据)
|
||||||
|
* @param page 当前页码,从 1 开始
|
||||||
|
* @param limit 每页数据条数,最少10条
|
||||||
|
*/
|
||||||
|
async preloadRecommendList(isFirstReq: boolean, page: number, limit: number): Promise<boolean> {
|
||||||
|
if (this.isRecommendListPreloaded) {
|
||||||
|
logger.log("[MainController] 推荐列表已预加载");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
logger.log("[MainController] 开始预加载推荐列表");
|
||||||
|
const reqData = {
|
||||||
|
page,
|
||||||
|
limit,
|
||||||
|
};
|
||||||
|
const res = await GirlService.I.reqRecommendList(reqData);
|
||||||
|
if (res && res.code === proto.cs.EnmRetCode.SUCCESS) {
|
||||||
|
const resData = res.data;
|
||||||
|
// 保存数据
|
||||||
|
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
|
||||||
|
if (isFirstReq) {
|
||||||
|
girlData.setRecommendList(resData);
|
||||||
|
} else {
|
||||||
|
girlData.addRecommendList(resData);
|
||||||
|
}
|
||||||
|
this.isRecommendListPreloaded = true;
|
||||||
|
logger.log("[MainController] 推荐列表预加载成功");
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
logger.warn("[MainController] 推荐列表预加载失败:", res);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
logger.error("[MainController] 推荐列表预加载异常:", error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 预加载商品列表
|
* 预加载商品列表
|
||||||
*/
|
*/
|
||||||
@@ -144,6 +187,7 @@ export class MainController {
|
|||||||
return (
|
return (
|
||||||
this.isThemeDataPreloaded &&
|
this.isThemeDataPreloaded &&
|
||||||
this.isDailyRecommendPreloaded &&
|
this.isDailyRecommendPreloaded &&
|
||||||
|
this.isRecommendListPreloaded &&
|
||||||
this.isShopListPreloaded
|
this.isShopListPreloaded
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -155,6 +199,7 @@ export class MainController {
|
|||||||
return {
|
return {
|
||||||
themeData: this.isThemeDataPreloaded,
|
themeData: this.isThemeDataPreloaded,
|
||||||
dailyRecommend: this.isDailyRecommendPreloaded,
|
dailyRecommend: this.isDailyRecommendPreloaded,
|
||||||
|
recommendList: this.isRecommendListPreloaded,
|
||||||
shopList: this.isShopListPreloaded,
|
shopList: this.isShopListPreloaded,
|
||||||
allComplete: this.isDataPreloaded(),
|
allComplete: this.isDataPreloaded(),
|
||||||
};
|
};
|
||||||
@@ -166,6 +211,7 @@ export class MainController {
|
|||||||
resetPreloadStatus(): void {
|
resetPreloadStatus(): void {
|
||||||
this.isThemeDataPreloaded = false;
|
this.isThemeDataPreloaded = false;
|
||||||
this.isDailyRecommendPreloaded = false;
|
this.isDailyRecommendPreloaded = false;
|
||||||
|
this.isRecommendListPreloaded = false;
|
||||||
this.isShopListPreloaded = false;
|
this.isShopListPreloaded = false;
|
||||||
logger.log("[MainController] 预加载状态已重置");
|
logger.log("[MainController] 预加载状态已重置");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user