fix: avoid Tauri window access in browser mode - #166
Closed
squarepots wants to merge 3 commits into
Closed
squarepots wants to merge 3 commits into
squarepots wants to merge 3 commits into
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.
本 PR 修复 plain browser/LAN 模式在 React mount 前访问 Tauri window API 导致的空白页。所有原生窗口操作现在都通过 lazy runtime boundary:只有检测到
window.__TAURI_INTERNALS__后才解析并缓存 Tauri window。drag、双击 maximize、resize listener、minimize、maximize 和 close 都使用该 helper;浏览器模式不渲染原生窗口控件,Tauri desktop 保留现有窗口交互。
验证
pnpm test:browser-runtime:2 项通过,覆盖无window和 plain browser-likewindowpnpm test:desktop-reopen:7 项通过pnpm test:close-preference:3 项通过pnpm test:reset-credits:3 项通过pnpm build:通过Closes #145
This PR fixes the blank page in plain browser/LAN mode caused by accessing the Tauri window API before React mounts. Native window operations now go through a lazy runtime boundary that resolves and caches the Tauri window only when
window.__TAURI_INTERNALS__is present.Dragging, double-click maximize, resize listeners, minimize, maximize, and close all use the helper. Browser mode does not render native window controls, while the Tauri desktop keeps its existing window interactions.
Validation
pnpm test:browser-runtime: 2 passed, covering nowindowand a plain browser-likewindowpnpm test:desktop-reopen: 7 passedpnpm test:close-preference: 3 passedpnpm test:reset-credits: 3 passedpnpm build: passedCloses #145