refactor: extract workspace context loading and improve reinit flow#20
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
重构 workspace 上下文加载逻辑,提取公共函数,优化 reinit 流程,修复切换 workspace 时的空白页问题。
Changes
New:
WorkspaceContexttype &loadWorkspaceContext()WorkspaceContext接口,统一承载 workspace 相关全部对象(client, window, workspace, activeTab, layout, workspaceTabs, workspaceLayouts)initWave()和reinitWave()中的对象加载逻辑提取到loadWorkspaceContext()中,消除重复代码New:
applyWorkspaceContext()tabContext参数区分 "own"(初始 tab)和 "active"(workspace 当前激活 tab)两种模式New:
WorkspaceSubscriptionclassunsubscribeWorkspace全局变量封装为类,提供setWorkspace()和dispose()方法,消除手动管理 unsubscribe 函数的风险Improved:
reinitWave()flowwaitForNextPaint()工具函数,等待双倍 requestAnimationFrame(带 50ms 超时回退),确保 DOM 就绪setWindowInitStatus("wave-ready")延迟到下一帧之后,消除切换 workspace 时的空白页闪烁问题Removed
reloadWorkspaceTabsAndLayouts()函数,其逻辑已整合到loadWorkspaceContext()中Bug Fix
reinitWave()现在使用"active" tabContext(即 workspace 的 activeTabId),initWave()使用"own" tabContext(即当前 tabId)