收藏功能&排行榜功能
This commit is contained in:
@@ -28,6 +28,7 @@ export class MainController {
|
||||
private isDailyRecommendPreloaded: boolean = false;
|
||||
private isRecommendListPreloaded: boolean = false;
|
||||
private isShopListPreloaded: boolean = false;
|
||||
private isBookmarkListPreloaded: boolean = false;
|
||||
|
||||
/**
|
||||
* 初始化并预加载数据
|
||||
@@ -41,6 +42,7 @@ export class MainController {
|
||||
//this.preloadDailyRecommend(),
|
||||
this.preloadRecommendList(true, 1, 10),
|
||||
this.preloadShopList(),
|
||||
this.preloadBookmarkList(),
|
||||
]);
|
||||
|
||||
logger.log("[MainController] 数据预加载完成");
|
||||
@@ -180,6 +182,37 @@ export class MainController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 预加载收藏列表
|
||||
*/
|
||||
async preloadBookmarkList(): Promise<boolean> {
|
||||
if (this.isBookmarkListPreloaded) {
|
||||
logger.log("[MainController] 收藏列表数据已预加载");
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
logger.log("[MainController] 开始预加载收藏列表数据");
|
||||
const reqData = {};
|
||||
const res = await GirlService.I.reqBookmarkGirlList(reqData);
|
||||
|
||||
if (res && res.code === proto.cs.EnmRetCode.SUCCESS) {
|
||||
// 保存数据到DataManager
|
||||
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
|
||||
girlData.setBookmarkGirlList(res.data);
|
||||
this.isBookmarkListPreloaded = true;
|
||||
logger.log("[MainController] 收藏列表数据预加载成功");
|
||||
return true;
|
||||
} else {
|
||||
logger.warn("[MainController] 收藏列表数据预加载失败:", res);
|
||||
return false;
|
||||
}
|
||||
} catch (error) {
|
||||
logger.error("[MainController] 收藏列表数据预加载异常:", error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查数据是否已预加载
|
||||
*/
|
||||
@@ -188,7 +221,8 @@ export class MainController {
|
||||
this.isThemeDataPreloaded &&
|
||||
this.isDailyRecommendPreloaded &&
|
||||
this.isRecommendListPreloaded &&
|
||||
this.isShopListPreloaded
|
||||
this.isShopListPreloaded &&
|
||||
this.isBookmarkListPreloaded
|
||||
);
|
||||
}
|
||||
|
||||
@@ -201,6 +235,7 @@ export class MainController {
|
||||
dailyRecommend: this.isDailyRecommendPreloaded,
|
||||
recommendList: this.isRecommendListPreloaded,
|
||||
shopList: this.isShopListPreloaded,
|
||||
bookmarkList: this.isBookmarkListPreloaded,
|
||||
allComplete: this.isDataPreloaded(),
|
||||
};
|
||||
}
|
||||
@@ -213,6 +248,7 @@ export class MainController {
|
||||
this.isDailyRecommendPreloaded = false;
|
||||
this.isRecommendListPreloaded = false;
|
||||
this.isShopListPreloaded = false;
|
||||
this.isBookmarkListPreloaded = false;
|
||||
logger.log("[MainController] 预加载状态已重置");
|
||||
}
|
||||
|
||||
@@ -296,4 +332,30 @@ export class MainController {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 强制刷新收藏列表数据
|
||||
*/
|
||||
async refreshBookmarkList(): Promise<boolean> {
|
||||
logger.log("[MainController] 开始强制刷新收藏列表数据");
|
||||
try {
|
||||
const reqData = {};
|
||||
const res = await GirlService.I.reqBookmarkGirlList(reqData);
|
||||
|
||||
if (res && res.code === proto.cs.EnmRetCode.SUCCESS) {
|
||||
// 保存数据到DataManager
|
||||
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
|
||||
girlData.setBookmarkGirlList(res.data);
|
||||
this.isBookmarkListPreloaded = true;
|
||||
logger.log("[MainController] 收藏列表数据刷新成功");
|
||||
return true;
|
||||
} else {
|
||||
logger.warn("[MainController] 收藏列表数据刷新失败:", res);
|
||||
return false;
|
||||
}
|
||||
} catch (error) {
|
||||
logger.error("[MainController] 收藏列表数据刷新异常:", error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user