feat(数据同步): 重构云端数据同步机制,引入防抖与本地缓存
- 新增 GameDataSync 类,封装数据同步逻辑,支持防抖与时间戳冲突解决 - 重构 SingletonModuleComp 的云端同步方法,统一调用 GameDataSync - 优化 TalentsComp 天赋升级流程,使用新的同步机制 - 添加本地缓存支持,提升离线体验与数据恢复能力
This commit is contained in:
@@ -202,15 +202,15 @@ export class TalentsComp extends CCComp {
|
||||
let points = collection.talent_points || 0;
|
||||
|
||||
if (points >= cost && currentLevel < 5) {
|
||||
// 扣除天赋点
|
||||
// 1. 扣除消耗
|
||||
collection.talent_points -= cost;
|
||||
// 增加天赋等级
|
||||
// 2. 更新等级
|
||||
collection.talents[talentId] = currentLevel + 1;
|
||||
|
||||
// 同步到云端
|
||||
// 3. 同步数据(通过 SingletonModuleComp 新增的机制,这里会触发标记脏数据并自动尝试云端同步)
|
||||
smc.updateCloudData();
|
||||
|
||||
// 刷新界面
|
||||
// 4. 刷新 UI
|
||||
this.refreshUI();
|
||||
|
||||
oops.gui.toast("天赋升级成功");
|
||||
|
||||
Reference in New Issue
Block a user