Files
deepseek-harness/apps/desktop/src/preload-platform.ts
T
Yif 8019d37d3f feat(client): frame-owned macOS window chrome with single drag owner
One 52px leadingBand in the AppFrame (frame's first child) plus the sidebar
logoRow are the only -webkit-app-region drag surfaces; everything interactive
subtracts itself through two global base.css rules (interactive elements and
body > :not(#root) overlay portals), so header controls, breadcrumb chips, and
strip tabs stay clickable under the band. A ui-theme stylesheet gate pins the
two-file drag allowlist. The frame publishes --dsh-frame-top-clearance (48px)
for entry pages (plugin manager list and detail) beside the existing
--dsh-frame-leading-clearance, replacing per-page hardcoded insets. The
shell.leading window-chrome seat moves the collapsed-sidebar reopen controls
from the conversation header to the frame. Sidebar vibrancy tint drops the
blue cast in dark mode and halves its fill opacity, light mode softens the
blue mix, and the logo row tightens 4px above New Session.
2026-09-18 11:08:13 +08:00

33 lines
1.3 KiB
TypeScript

/** Marks the document root with the host platform so shared Web UI CSS can scope desktop-only rules. */
import { ipcRenderer } from 'electron'
import { DESKTOP_IPC } from './ipc.ts'
/**
* Sets `data-platform` (e.g. `darwin`) on `<html>`, deferring to DOMContentLoaded
* when the preload runs before the document root exists.
*/
export function markDocumentPlatform(): void {
const mark = (): void => { document.documentElement.dataset.platform = process.platform }
// lib.dom types documentElement non-null, but a preload runs before the
// document root exists.
const root = document.documentElement as HTMLElement | null
if (root === null) window.addEventListener('DOMContentLoaded', mark)
else mark()
}
/**
* Mirrors the window's macOS fullscreen state onto `<html data-fullscreen>` so
* CSS drops the traffic-light clearance while the lights are hidden. The main
* process sends the state on every transition and after each load.
*/
export function syncWindowFullscreen(): void {
if (process.platform !== 'darwin') return
ipcRenderer.on(DESKTOP_IPC.windowFullscreen, (_event, fullscreen: boolean) => {
const root = document.documentElement as HTMLElement | null
if (root === null) return
if (fullscreen) root.dataset.fullscreen = 'true'
else delete root.dataset.fullscreen
})
}