Skip to content

fix: avoid Tauri window access in browser mode - #166

Closed
squarepots wants to merge 3 commits into
Lampese:mainfrom
squarepots:fix/browser-runtime-safe
Closed

squarepots wants to merge 3 commits into
Lampese:mainfrom
squarepots:fix/browser-runtime-safe

Conversation

@squarepots

@squarepots squarepots commented Sep 18, 2026 •

Copy link
Copy Markdown

本 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-like window
  • pnpm 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 no window and a plain browser-like window
  • pnpm test:desktop-reopen: 7 passed
  • pnpm test:close-preference: 3 passed
  • pnpm test:reset-credits: 3 passed
  • pnpm build: passed

Closes #145

@squarepots
squarepots marked this pull request as ready for review September 18, 2026 15:44
@squarepots squarepots closed this by deleting the head repository Sep 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Web/LAN mode renders a blank page: getCurrentWindow() called at module scope

1 participant