Skip to content

DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.

feat(dsh-tauri): report harness host styles to the shell

hairyf4109c516ba5a
diff --git a/packages/dsh-tauri/src/client/apply.ts b/packages/dsh-tauri/src/client/apply.ts
index a941c027..25dad4a5 100644
--- a/packages/dsh-tauri/src/client/apply.ts
+++ b/packages/dsh-tauri/src/client/apply.ts
@@ -14,6 +14,7 @@ import type { ClientContext } from './types'
import { navigationFeature } from './register/navigation'
import { sidebarFeature } from './register/sidebar'
import { sidebarTweaksFeature } from './register/sidebar-tweaks'
+import { registerStyle } from './register/style'
import { zoomShortcutFeature } from './register/zoom-shortcut'
/** effect 标签(只有本文件消费,按常量归属规则留在消费方)。 */
@@ -21,9 +22,10 @@ const SIDEBAR_TOGGLE_EFFECT = 'dsh-tauri: sidebar (toggle command + collapsed re
const NAVIGATION_EFFECT = 'dsh-tauri: navigation (new session, add workspace)'
const ZOOM_SHORTCUT_EFFECT = 'dsh-tauri: zoom shortcuts (ctrl/cmd +/-/0)'
const SIDEBAR_TWEAKS_EFFECT = 'dsh-tauri: sidebar tweaks (hide collapse toggle, center brand)'
-
+const STYLE_EFFECT = 'dsh-tauri: style (sidebar background)'
/** 插件体:注册侧边栏桥、导航命令、缩放快捷键与侧边栏 UI 微调。 */
export function apply(ctx: ClientContext): void {
+ ctx.effect(registerStyle, STYLE_EFFECT)
ctx.effect(sidebarFeature, SIDEBAR_TOGGLE_EFFECT)
ctx.effect(navigationFeature, NAVIGATION_EFFECT)
ctx.effect(zoomShortcutFeature, ZOOM_SHORTCUT_EFFECT)
diff --git a/packages/dsh-tauri/src/client/register/style.ts b/packages/dsh-tauri/src/client/register/style.ts
new file mode 100644
index 00000000..9cde3179
--- /dev/null
+++ b/packages/dsh-tauri/src/client/register/style.ts
@@ -0,0 +1,23 @@
+import type { ClientContext } from '../types'
+import { defineRegister } from '.'
+import { invokeParent } from '../service/invoke-parent'
+import { getFrameStyle, getOverlayMarkedStyle, getSidebarStyle } from './style.utils'
+
+export const registerStyle = defineRegister<ClientContext>((controller) => {
+ function reportSidebarBackground() {
+ invokeParent({
+ type: 'dsh://style',
+ sidebar: getSidebarStyle(),
+ marked: getOverlayMarkedStyle(),
+ frame: getFrameStyle(),
+ colorScheme: document.documentElement.style.colorScheme,
+ })
+ }
+
+ controller.observe(document.body, reportSidebarBackground, {
+ childList: true,
+ subtree: true,
+ attributes: true,
+ attributeFilter: ['style', 'class'], // 过滤:只关注这两个属性
+ })
+})
diff --git a/packages/dsh-tauri/src/client/register/style.utils.ts b/packages/dsh-tauri/src/client/register/style.utils.ts
new file mode 100644
index 00000000..02e4334d
--- /dev/null
+++ b/packages/dsh-tauri/src/client/register/style.utils.ts
@@ -0,0 +1,33 @@
+export function getSidebarStyle() {
+ const sidebar = document.querySelector('[data-slot="sidebar"] > div')
+ if (!sidebar)
+ return null
+ const computedStyle = getComputedStyle(sidebar)
+ return {
+ background: computedStyle.background,
+ }
+}
+
+export function getOverlayMarkedStyle() {
+ const overlay = document.querySelector('div[class^="_mask_"]')
+ if (!overlay)
+ return null
+ const computedStyle = getComputedStyle(overlay)
+
+ return {
+ inset: computedStyle.inset,
+ background: computedStyle.background,
+ backdropFilter: computedStyle.backdropFilter,
+ bottom: '-1px',
+ }
+}
+
+export function getFrameStyle() {
+ const frame = document.querySelector('div[class$="_frame"]')
+ if (!frame)
+ return null
+ const computedStyle = getComputedStyle(frame)
+ return {
+ background: computedStyle.background,
+ }
+}