DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.
fix(shell): 预加载文档应用前隐藏 iframe,消除深色系统启动白底 (#1191)
XXXINuo03d225c33d71
diff --git a/src/layout/components/iframe.test.tsx b/src/layout/components/iframe.test.tsxindex 327b538a..18c81b7e 100644--- a/src/layout/components/iframe.test.tsx+++ b/src/layout/components/iframe.test.tsx@@ -103,6 +103,7 @@ it('preloads before health, hands live boot to the same frame, and falls back onwindow.dispatchEvent(new MessageEvent('message', { source: frame.contentWindow, origin: 'http://127.0.0.1:3081', data: { type: 7 } }))})expect(frame.getAttribute('src')).toBe(src)+ expect(frame.style.visibility).toBe('hidden')expect(store.harness.serviceHealthy).toBe(false)expect(store.harness.iframeAlive).toBe(false)async function report(type: string, origin = 'http://127.0.0.1:3081', id = '7') {@@ -124,6 +125,7 @@ it('preloads before health, hands live boot to the same frame, and falls back onexpect(post).toHaveBeenCalledWith({ source: 'dsh-desktop', type: 'dsh://frontend-preload:boot', id: '7', html: store.harness.frontendBootHtml }, 'http://127.0.0.1:3081')expect(store.harness.iframeAlive).toBe(false)await report('dsh://frontend-preload:applied')+ expect(frame.style.visibility).toBe('visible')await act(async () => {await vi.advanceTimersByTimeAsync(9000)})@@ -199,7 +201,7 @@ it.each([expect(store.harness.serviceRunning).toBe(true)})-it('diagnoses remote frame visibility across local health and error transitions without changing it', async () => {+it('diagnoses remote frame visibility across local health and error transitions without hiding the remote document', async () => {render(<Iframe iframeRef={createRef()} srcOverride="https://example.test/?token=secret" />)expect(screen.getByTestId('dsh-shell-iframe').getAttribute('src')).toBe('https://example.test/?token=secret')expect(screen.queryByRole('status')).toBeNull()@@ -214,13 +216,14 @@ it('diagnoses remote frame visibility across local health and error transitionsstore.harness.serviceHealthy = truestore.harness.markIframeError()})- expect(frame.style.visibility).toBe('hidden')+ // 本地诊断标记不能藏远端文档:远端这里没有错误覆盖层,藏掉只剩一整片空白。+ expect(frame.style.visibility).toBe('visible')expect(screen.queryByText('ui.iframe_error')).toBeNull()expect(console.warn).toHaveBeenLastCalledWith('[Iframe] view', expect.objectContaining({branch: 'remote-frame',serviceHealthy: true,iframeError: true,- iframeHidden: true,+ iframeHidden: false,}))expect(JSON.stringify(vi.mocked(console.warn).mock.calls)).not.toContain('secret')})diff --git a/src/layout/components/iframe.tsx b/src/layout/components/iframe.tsxindex ecfd5942..89fb7d1e 100644--- a/src/layout/components/iframe.tsx+++ b/src/layout/components/iframe.tsx@@ -248,10 +248,11 @@ export function Iframe({ iframeRef, srcOverride = null, borderTint = null }: Ifrconst post = useIframePost(iframeRef)// 握手兜底:帧内接收器异常时不能让 iframe 永久藏住,超时后按「未确认」直接揭开。const appearancePending = translucent && bootFrame !== frameKey- const iframeHidden = appearancePending || remoteLoading || harness.showIframeErrorconst mounted = remoteMode || activePreload !== null || harness.serviceHealthyconst showIframeError = !remoteMode && harness.showIframeErrorconst documentWaiting = !remoteMode && mounted && !harness.iframeAlive && !showIframeError && !appearancePending+ const preloadPending = activePreload !== null && !activePreload.applied+ const iframeHidden = appearancePending || preloadPending || remoteLoading || showIframeErrorconst branch = !mounted ? 'service-wait' : showIframeError ? 'iframe-error' : remoteLoading ? 'remote-loading' : appearancePending ? 'appearance-wait' : documentWaiting ? 'document-wait' : remoteMode ? 'remote-frame' : 'local-frame'useWatch([branch, harness.status, remoteMode, mounted, harness.serviceHealthy, harness.serviceRunning, harness.iframeKey, harness.iframeLoaded, harness.iframeAlive, harness.iframeError, harness.startupPhase, harness.busyAction, appearancePending, documentWaiting, iframeHidden], () => {console.warn('[Iframe] view', {@@ -734,7 +735,7 @@ export function Iframe({ iframeRef, srcOverride = null, borderTint = null }: Ifr// 未确认收到启动期外观前先藏起来:帧内 boot 页(HARNESS + Loading plugins…)// 会先按不透明画一帧,露出那一下比等待更刺眼。上面的 Loadable 与之逐项同构,// 揭开时视觉无跳变,且有 4s 兜底不会永久藏住。- style={{ visibility: appearancePending || remoteLoading || harness.showIframeError ? 'hidden' : 'visible' }}+ style={{ visibility: iframeHidden ? 'hidden' : 'visible' }}src={frameSrc}allow="accelerometer; ambient-light-sensor; autoplay; battery; camera; clipboard-read; clipboard-write; display-capture; document-domain; encrypted-media; fullscreen; gamepad; geolocation; gyroscope; hid; idle-detection; keyboard-map; magnetometer; microphone; midi; payment; picture-in-picture; publickey-credentials-get; screen-wake-lock; serial; speaker-selection; usb; web-share; xr-spatial-tracking"sandbox="allow-same-origin allow-scripts allow-popups allow-forms allow-modals allow-downloads allow-storage-access-by-user-activation"@@ -748,6 +749,13 @@ export function Iframe({ iframeRef, srcOverride = null, borderTint = null }: Ifr/></If>+ {/* 预加载静态页/外观握手期间用同构 Loadable 盖住,避免露出白底 */}+ <If cond={!remoteMode && mounted && iframeHidden && !showIframeError}>+ <div className="absolute inset-0 z-[1]">+ <Loadable subtitle={t(harness.startupStatusKey)} />+ </div>+ </If>+{/* 远端机器勾选「边框着色」时,用标识色给内容区描边:当前处于远端一眼可辨 */}<If cond={borderTint !== null}><div