feat: 侧边栏新增位置兼容模式,为 Windows 原生标题栏预留顶部空间

新增 SidebarPrefs.titleBarCompat 设置项(默认关闭):开启后 toggle cluster
下移 40px、右侧面板内容从标题栏条带下方开始,避免被 Windows 无边框窗口
右上角的原生标题栏遮挡。底部面板不受影响。设置页「常规」新增一行开关,
zh/en 双语,读写下穿既有 settings 路由。测试覆盖 parsePrefs 回退、schema
默认值、设置页渲染与开关状态。
This commit is contained in:
Menghuan1918
2026-08-15 15:37:31 +08:00
parent 5c27882995
commit 1e7c72ccbe
11 changed files with 104 additions and 5 deletions
+15
View File
@@ -167,6 +167,21 @@ export function Sidebar(props: { ctx: Context; store: SidebarStore }) {
return () => { document.body.removeAttribute('data-dsh-sidebar-collapsed') }
}, [collapsed])
// Position compatibility mode (titleBarCompat pref): Windows frameless
// windows draw the native title bar (minimize/maximize/close) at the
// window's top-right corner, OVER the web content. When the user enables
// the pref, the body attribute lets sidebar.module.css drop the toggle
// cluster below the strip and push the right panel's content below it.
// The attribute rides the snapshot's prefs, so flipping the setting
// re-renders and re-applies immediately; the cleanup removes it on
// unmount/boundary swap so a crashed sidebar never leaves it behind.
const titleBarCompat = snapshot.prefs.titleBarCompat
useEffect(() => {
if (titleBarCompat) document.body.setAttribute('data-dsh-title-bar-compat', '')
else document.body.removeAttribute('data-dsh-title-bar-compat')
return () => { document.body.removeAttribute('data-dsh-title-bar-compat') }
}, [titleBarCompat])
/**
* Bottom-panel merge on narrow viewports: whenever a session is current
* while narrow (mount, session switch, or a desktop→narrow transition),