From 411ca8c772eb4d540843d06dd031cf9ba13c8a9c Mon Sep 17 00:00:00 2001 From: richarjiang Date: Mon, 1 Jun 2026 11:40:05 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=AF=8F=E6=AC=A1=E8=BF=9B=E5=85=A5=20?= =?UTF-8?q?write=20level=20=E9=A1=B5=E9=9D=A2=E9=83=BD=E6=8B=89=E5=8F=96?= =?UTF-8?q?=E6=9C=80=E6=96=B0=E7=9A=84=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AGENTS.md | 14 +++++----- assets/prefabs/PageWriteLevels.ts | 43 ++++++++++++++++++++++++++----- 2 files changed, 43 insertions(+), 14 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 5788640..efe6a4c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -40,13 +40,13 @@ Git 历史采用 Conventional Commits,且摘要多为中文,例如 `feat: # Memory Context -# [mp-xieyingeng] recent context, 2026-06-01 11:17am GMT+8 +# [mp-xieyingeng] recent context, 2026-06-01 11:37am GMT+8 Legend: 🎯session 🔴bugfix 🟣feature 🔄refactor ✅change 🔵discovery ⚖️decision 🚨security_alert 🔐security_note Format: ID TIME TYPE TITLE Fetch details: get_observations([IDs]) | Search: mem-search skill -Stats: 50 obs (15,406t read) | 2,405,914t work | 99% savings +Stats: 50 obs (15,736t read) | 2,461,717t work | 99% savings ### Apr 26, 2026 S1309 移除 PageLevel.ts 进入关卡时弹出体力扣减 toast (Apr 26 at 5:16 PM) @@ -55,11 +55,8 @@ S1308 移除进入游戏关卡时弹出体力扣减的 toast 提示 (Apr 27 at 9 S1310 移除进入游戏体力扣减 toast 并在首页添加体力显示 (Apr 27 at 9:22 AM) S1311 移除体力扣减 toast 并完善首页体验 (Apr 27 at 9:23 AM) S1313 Implement object-fit: cover image scaling in Cocos Creator to prevent downloaded images from being distorted (Apr 27 at 9:26 AM) -1362 9:45a 🟣 Image Cover Mode Scaling in Cocos Creator S1312 Fix image distortion in PageLevel.ts by implementing object-fit: cover behavior for downloaded images (Apr 27 at 9:45 AM) -1360 " ✅ Cocos Creator animation imports added to PageHome.ts -1361 " ✅ Animation constants added to PageHome class -1363 " ✅ Start game button integrated with stamina check and animation flow +1363 9:45a ✅ Start game button integrated with stamina check and animation flow 1364 " 🟣 Stamina consumption animation fully implemented in PageHome S1314 Implement stamina consumption animation in Cocos Creator game - when clicking StarGame button, IconLive node flies to button with floating "-1" text, then navigates to level (Apr 27 at 9:45 AM) 1365 9:46a 🔴 Animation completes but navigation to PageLevel fails @@ -113,7 +110,10 @@ S1317 Implement CSS cover-mode image scaling for PageLevel.ts mainImage nodes (A 1779 " 🔵 PageWriteLevels Layout Node Tree Verified After Widget Changes 1780 11:16a 🔵 TypeScript Check Requires Cocos Creator to Generate temp/declarations First 1781 " 🔵 New Widget Bottom Inset Produces Shorter Viewport on Small Screens vs Old Minimum +1783 " 🔵 PageWriteLevels Bottom Control Layout Constraints Mapped +1784 " ✅ ScrollView Widget Bottom Inset Revised from 559.076 to 752.53 1782 " 🔵 PageWriteLevels Prefab __id__ Reference Integrity Confirmed Valid +1785 11:19a ✅ PageWriteLevels Widget Layout Refactor Complete — Final Diff Confirmed -Access 2406k tokens of past work via get_observations([IDs]) or mem-search skill. +Access 2462k tokens of past work via get_observations([IDs]) or mem-search skill. diff --git a/assets/prefabs/PageWriteLevels.ts b/assets/prefabs/PageWriteLevels.ts index 4b83555..2fe781e 100644 --- a/assets/prefabs/PageWriteLevels.ts +++ b/assets/prefabs/PageWriteLevels.ts @@ -80,6 +80,7 @@ export class PageWriteLevels extends BaseView { private _levelCount: number = 0; private _itemNodes: Node[] = []; private _scrollViewComp: ScrollView | null = null; + private _levelListLoadToken: number = 0; /** 缓存 view 节点的 UITransform,避免每次 _updateContentSize 重复查找 */ private _viewTransform: UITransform | null = null; @@ -140,11 +141,7 @@ export class PageWriteLevels extends BaseView { console.log('[PageWriteLevels] onViewShow'); this._resizeScrollViewport(); this._updateContentSize(); - - // 仅首次初始化列表,从预览页返回时保留选中状态 - if (this._itemNodes.length === 0) { - void this._initLevelList(); - } + void this._initLevelList(); } private _resizeScrollViewport(): void { @@ -170,23 +167,32 @@ export class PageWriteLevels extends BaseView { } private async _initLevelList(): Promise { - this._clearList(); + const loadToken = ++this._levelListLoadToken; + const selectedLevelIds = this._getSelectedLevelIdSet(); // 拉取当前用户所有已通关关卡 - const levels = await CompletedLevelsManager.instance.fetch(); + const levels = await CompletedLevelsManager.instance.fetch(true); + if (loadToken !== this._levelListLoadToken) { + return; + } + if (levels === null) { console.warn('[PageWriteLevels] 获取已通关关卡失败'); ToastManager.instance.show('获取关卡列表失败,请稍后重试'); return; } + this._clearList(); this._levels = levels; this._levelCount = this._levels.length; + this._restoreSelectedIndices(selectedLevelIds); console.log('[PageWriteLevels] 已通关关卡总数:', this._levelCount); if (this._levelCount === 0) { console.warn('[PageWriteLevels] 用户尚未通关任何关卡'); ToastManager.instance.show('还没有已通关的关卡,快去玩几关吧'); + this._updateContentSize(); + this._updateSelectionUI(); return; } @@ -198,6 +204,29 @@ export class PageWriteLevels extends BaseView { } } + private _getSelectedLevelIdSet(): Set { + const selectedLevelIds = new Set(); + for (const index of this._selectedIndices) { + const level = this._levels[index] ?? null; + if (level) { + selectedLevelIds.add(level.id); + } + } + return selectedLevelIds; + } + + private _restoreSelectedIndices(selectedLevelIds: Set): void { + if (selectedLevelIds.size === 0) { + return; + } + + for (let index = 0; index < this._levels.length; index++) { + if (selectedLevelIds.has(this._levels[index].id)) { + this._selectedIndices.add(index); + } + } + } + private _clearList(): void { for (const node of this._itemNodes) { if (node && node.isValid) {