Skip to content

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

refactor(dsh-tauri-ui): replace the slots store with a section registry service

hairyfe1e04d0efc11
diff --git a/packages/dsh-tauri-ui/src/client/components/icon.tsx b/packages/dsh-tauri-ui/src/client/components/icon.tsx
index b78976ab..980c8226 100644
--- a/packages/dsh-tauri-ui/src/client/components/icon.tsx
+++ b/packages/dsh-tauri-ui/src/client/components/icon.tsx
@@ -1,6 +1,5 @@
import type { ComponentType, ReactElement, SVGProps } from 'react'
-/** Common props for a Gravity or primitives SVG component. */
export type IconComponent = ComponentType<SVGProps<SVGSVGElement>>
export interface IconProps extends Omit<SVGProps<SVGSVGElement>, 'as'> {
@@ -10,10 +9,6 @@ export interface IconProps extends Omit<SVGProps<SVGSVGElement>, 'as'> {
export type SharedIconProps = Omit<SVGProps<SVGSVGElement>, 'as'> & { size?: number }
-/**
- * Normalizes icon sizing without wrapping individual upstream icons.
- * The `as` component remains the source of the SVG path and metadata.
- */
export function Icon({ as: Component, size = 16, ...props }: IconProps): ReactElement {
return <Component {...props} width={size} height={size} />
}
diff --git a/packages/dsh-tauri-ui/src/client/components/icons.tsx b/packages/dsh-tauri-ui/src/client/components/icons.tsx
index 6e8ea21a..beb51d9e 100644
--- a/packages/dsh-tauri-ui/src/client/components/icons.tsx
+++ b/packages/dsh-tauri-ui/src/client/components/icons.tsx
@@ -1,9 +1,3 @@
-/**
- * Gravity UI icon barrel.
- *
- * Keep this file as a path-based re-export only. The shared `Icon` component
- * owns sizing; upstream components remain the authoritative SVG implementation.
- */
export { default as ArrowDownToLine } from '@gravity-ui/icons/ArrowDownToLine'
export { default as ArrowLeft } from '@gravity-ui/icons/ArrowLeft'
export { default as ArrowRight } from '@gravity-ui/icons/ArrowRight'
diff --git a/packages/dsh-tauri-ui/src/client/components/index.ts b/packages/dsh-tauri-ui/src/client/components/index.ts
index 498f54d0..71f64e4c 100644
--- a/packages/dsh-tauri-ui/src/client/components/index.ts
+++ b/packages/dsh-tauri-ui/src/client/components/index.ts
@@ -2,4 +2,5 @@ export * from './icon'
export type * from './icon'
export * from './icons'
export * from './menu-select'
+export * from './panel-width-sync'
export { circleTreeSvg, clockSvg, FishMark, IconPlaceholder, PanelLeftOutline } from './special-icons'
diff --git a/packages/dsh-tauri-ui/src/client/components/menu-select.cssr.ts b/packages/dsh-tauri-ui/src/client/components/menu-select.cssr.ts
index 43f8f929..0602cf4a 100644
--- a/packages/dsh-tauri-ui/src/client/components/menu-select.cssr.ts
+++ b/packages/dsh-tauri-ui/src/client/components/menu-select.cssr.ts
@@ -1,10 +1,9 @@
-import { styles as sharedStyles } from '../theme'
+import { styles as sharedStyles } from '../constants/theme'
import { cssr } from '../utils/cssr'
const { c, bem: { b, m } } = cssr
const { primary, secondary, hover, modulePlatform } = sharedStyles
-/** 共享 MenuSelect 触发按钮(default 36px 胶囊;pill 28px 浅触发)。 */
export default b('menu-select', {
display: 'inline-flex',
alignItems: 'center',
@@ -17,9 +16,6 @@ export default b('menu-select', {
background: modulePlatform,
color: primary,
cursor: 'pointer',
- // 对齐官方 .oY77xG_selector(PermissionRow.module.css):font 简写之后需显式
- // font-size/line-height,否则跨规则时 font:inherit 会抢占字号,导致依赖继承的
- // default 变体(如 dshp-session__menu-select)字体异常放大。
font: 'inherit',
fontSize: '14px',
lineHeight: '22px',
diff --git a/packages/dsh-tauri-ui/src/client/components/menu-select.tsx b/packages/dsh-tauri-ui/src/client/components/menu-select.tsx
index 27af04f1..ff747789 100644
--- a/packages/dsh-tauri-ui/src/client/components/menu-select.tsx
+++ b/packages/dsh-tauri-ui/src/client/components/menu-select.tsx
@@ -1,18 +1,14 @@
import type { MenuEntry } from '@deepseek-ai/dsh-client-ui-primitives'
import type { ReactElement } from 'react'
-import type { MenuSelectProps } from '../types'
+import type { MenuSelectProps } from './menu-select.types'
import { IconChevronDownOutline14 as ChevronDown, Menu } from '@deepseek-ai/dsh-client-ui-primitives'
+import { compact } from 'dsh-tauri/client'
import { useState } from 'react'
import { MENU_SELECT_STYLE_ID } from '../constants'
-import { useMountStyle } from '../utils/style'
+import { useMountStyle } from '../hooks/use-mount-style'
import { Icon } from './icon'
import menuSelectStyle from './menu-select.cssr'
-/**
- * Shared official-style select pattern: a button anchored to the primitives
- * Menu. `triggerClassName` keeps existing plugin class contracts stable while
- * the variant records the two official visual forms (pill/default).
- */
export function MenuSelect({
value,
options,
@@ -27,11 +23,11 @@ export function MenuSelect({
useMountStyle(menuSelectStyle, MENU_SELECT_STYLE_ID)
const current = options.find(option => option.id === value)
const items: MenuEntry[] = options.map(option => ({ id: option.id, label: option.label }))
- const triggerClass = [
+ const triggerClass = compact([
'dshp-menu-select',
- variant === 'pill' ? 'dshp-menu-select--pill' : '',
+ variant === 'pill' && 'dshp-menu-select--pill',
triggerClassName,
- ].filter(Boolean).join(' ')
+ ]).join(' ')
return (
<Menu
diff --git a/packages/dsh-tauri-ui/src/client/components/menu-select.types.ts b/packages/dsh-tauri-ui/src/client/components/menu-select.types.ts
new file mode 100644
index 00000000..23c0bbd0
--- /dev/null
+++ b/packages/dsh-tauri-ui/src/client/components/menu-select.types.ts
@@ -0,0 +1,15 @@
+export interface MenuSelectOption {
+ id: string
+ label: string
+}
+
+export interface MenuSelectProps {
+ value: string
+ options: readonly MenuSelectOption[]
+ onSelect: (id: string) => void
+ label: string
+ variant?: 'pill' | 'default'
+ triggerClassName?: string
+ labelClassName?: string
+ chevronClassName?: string
+}
diff --git a/packages/dsh-tauri-ui/src/client/components/nav-icon.cssr.ts b/packages/dsh-tauri-ui/src/client/components/nav-icon.cssr.ts
index 53a7fd46..f1e3876e 100644
--- a/packages/dsh-tauri-ui/src/client/components/nav-icon.cssr.ts
+++ b/packages/dsh-tauri-ui/src/client/components/nav-icon.cssr.ts
@@ -2,7 +2,6 @@ import { cssr } from '../utils/cssr'
const { bem: { b } } = cssr
-/** 设置导航行图标(官方 primitives 图标的外层对齐)。 */
export default b('settings-nav-icon', {
flex: 'none',
})
diff --git a/packages/dsh-tauri-ui/src/client/components/nav-icon.tsx b/packages/dsh-tauri-ui/src/client/components/nav-icon.tsx
index 3cf29090..bef733ec 100644
--- a/packages/dsh-tauri-ui/src/client/components/nav-icon.tsx
+++ b/packages/dsh-tauri-ui/src/client/components/nav-icon.tsx
@@ -5,31 +5,20 @@ import {
IconPersonalizationOutline16,
IconSettingsOutline16,
} from '@deepseek-ai/dsh-client-ui-primitives'
+import { get } from 'dsh-tauri/client'
import { SETTINGS_NAV_ICON_STYLE_ID } from '../constants'
-import { useMountStyle } from '../utils/style'
+import { useMountStyle } from '../hooks/use-mount-style'
import { Icon } from './icon'
import settingsNavIconStyle from './nav-icon.cssr'
-/**
- * nav-icon.tsx — 设置导航行的分区图标。
- *
- * `settings.section` 契约只携带 {id, order, label};官方 SettingsRoot 在壳内
- * 按 id 从闭集选图标(models / agent-presets / plugins,未知 id 回落设置齿轮)。
- * 本侧边栏镜像同一映射、复用同一图标组件(@deepseek-ai/dsh-client-ui-primitives
- * 经 ModuleLoader 解析,与官方视觉同源、自动跟随上游),保证停靠设置栏与官方
- * 设置弹窗的导航观感一致。
- */
-
-/** 官方 navIcon 同款闭集映射:已知分区 id → 图标组件。 */
const NAV_ICONS: Record<string, typeof IconSettingsOutline16> = {
'models': IconDataOutline16,
'agent-presets': IconAgentPresetOutline16,
'plugins': IconPersonalizationOutline16,
}
-/** 渲染分区导航图标(官方兜底语义:未知 id 显示设置齿轮)。 */
export function SettingsNavIcon({ id }: { id: string }): ReactElement {
useMountStyle(settingsNavIconStyle, SETTINGS_NAV_ICON_STYLE_ID)
- const NavIcon = NAV_ICONS[id] ?? IconSettingsOutline16
+ const NavIcon = get(NAV_ICONS, id, IconSettingsOutline16)
return <Icon as={NavIcon} size={16} className="dshp-settings-nav-icon" />
}
diff --git a/packages/dsh-tauri-ui/src/client/components/panel-width-sync.tsx b/packages/dsh-tauri-ui/src/client/components/panel-width-sync.tsx
new file mode 100644
index 00000000..35173d2f
--- /dev/null
+++ b/packages/dsh-tauri-ui/src/client/components/panel-width-sync.tsx
@@ -0,0 +1,68 @@
+import type { CSSProperties, ReactNode } from 'react'
+import { useEffect, useRef } from 'react'
+
+/** 官方会话根写入的拖拽宽度偏好键(`dsh-client-ui-conversation`)。 */
+const WIDTH_PREF_KEY = 'dsh.conversation.contentWidth'
+/** 官方内容宽下限;偏好值不得低于它。 */
+const CONTENT_MIN = 640
+/** 官方内容宽两侧留白预算:列宽减去它才是偏好上限。 */
+const CONTENT_EDGE_BUDGET = 176
+
+function readWidthPreference(): number | null {
+ if (typeof localStorage === 'undefined')
+ return null
+ const raw = localStorage.getItem(WIDTH_PREF_KEY)
+ if (raw === null)
+ return null
+ const value = Number(raw)
+ return Number.isFinite(value) && value > 0 ? value : null
+}
+
+/** 官方公式:有偏好时夹到 `[CONTENT_MIN, 列宽 - CONTENT_EDGE_BUDGET]`,否则自适应列宽的 64%。 */
+function resolveContentWidth(columnWidth: number, preference: number | null): number {
+ const max = Math.max(CONTENT_MIN, columnWidth - CONTENT_EDGE_BUDGET)
+ if (preference !== null)
+ return Math.min(Math.max(preference, CONTENT_MIN), max)
+ return Math.max(680, Math.min(columnWidth * 0.64, 920))
+}
+
+/**
+ * 面板宽度同步容器:让面板内容列与会话内容列逐像素对齐。
+ *
+ * 面板与会话根都是 `main` 槽的同级占位者,读不到会话根以行内样式发布的
+ * `--dsh-conversation-column-width` 与 `--dsh-chat-user-width`(用户拖拽偏好)。
+ * 只靠 `panelContainer` 的 `clamp(680px, 64%, 920px)` 会丢掉偏好那一层而与会话列错位,
+ * 因此这里用与官方相同的公式在自身上发布同一组变量,再交给 `panelContainer` 消费。
+ * 自身必须是未加 `max-width` 的满宽容器,否则测到的是收敛后的内容宽而非列宽。
+ */
+export function PanelWidthSync({ children }: { children: ReactNode }) {
+ const ref = useRef<HTMLDivElement>(null)
+
+ useEffect(() => {
+ const element = ref.current
+ if (element === null)
+ return
+ const publish = (): void => {
+ const column = element.offsetWidth
+ element.style.setProperty('--dsh-conversation-column-width', `${column}px`)
+ const preference = readWidthPreference()
+ if (preference === null)
+ element.style.removeProperty('--dsh-chat-user-width')
+ else
+ element.style.setProperty('--dsh-chat-user-width', `${resolveContentWidth(column, preference)}px`)
+ }
+ publish()
+ if (typeof ResizeObserver === 'undefined')
+ return
+ const observer = new ResizeObserver(publish)
+ observer.observe(element)
+ return () => observer.disconnect()
+ }, [])
+
+ const style = {
+ 'width': '100%',
+ '--dsh-chat-content-width': 'var(--dsh-chat-user-width, clamp(680px, calc(var(--dsh-conversation-column-width, 0px) * .64), 920px))',
+ } as CSSProperties
+
+ return <div ref={ref} style={style}>{children}</div>
+}
diff --git a/packages/dsh-tauri-ui/src/client/components/seat.ts b/packages/dsh-tauri-ui/src/client/components/seat.ts
index 572ff824..9f8aa04a 100644
--- a/packages/dsh-tauri-ui/src/client/components/seat.ts
+++ b/packages/dsh-tauri-ui/src/client/components/seat.ts
@@ -1,15 +1,3 @@
-/**
- * `shell.overlay` 条目组件(骨架占位):定制化 Tauri UI 的渲染落点。
- *
- * shell.overlay 是帧级浮动层(list/root):位于所有列之上、滚动容器之外,
- * 层本身 click-through,条目自行 opt-in pointer-events。将来桌面风格的自定义
- * chrome(顶部导航/窗口控件/状态胶囊等)在这里渲染;当前骨架不渲染任何
- * 可见内容,仅保证注册链路的类型合约完整可编译。
- *
- * 类型说明:register 的组件须满足 SlotComponent 合约(参数为四份合成 props,
- * 返回 ReactNode)。此处零参数、返回 null 亦合法(参数逆变 + 返回值是
- * ReactNode 子集);接入真实 UI 后改为消费 props 的常规函数组件即可。
- */
export function TauriUiSeat(): null {
return null
}
diff --git a/packages/dsh-tauri-ui/src/client/components/sidebar.cssr.ts b/packages/dsh-tauri-ui/src/client/components/sidebar.cssr.ts
index bbbe1aa3..3c28c5bb 100644
--- a/packages/dsh-tauri-ui/src/client/components/sidebar.cssr.ts
+++ b/packages/dsh-tauri-ui/src/client/components/sidebar.cssr.ts
@@ -1,10 +1,9 @@
-import { styles as sharedStyles } from '../theme'
+import { styles as sharedStyles } from '../constants/theme'
import { cssr } from '../utils/cssr'
const { c, bem: { b, e, m } } = cssr
const { primary, dimmed, borderL2, brand, layer1, hover } = sharedStyles
-/** 设置侧边栏:整窗 docked 左栏 + 内容区。 */
export default b('settings-sidebar', {
'--dsh-chat-content-width': '748px',
'--dsh-composer-card-max-width': 'calc(var(--dsh-chat-content-width) + 32px)',
@@ -46,8 +45,6 @@ export default b('settings-sidebar', {
}, [
c('&:hover', { background: hover }),
]),
- // 搜索框 = 官方 input 样式值(与 dsh-tauri-panel-scheduler 的 K.input 一致,
- // 复刻 ModelsSection.zGbnIq_input;令牌化,浅/深色自动适配)。
e('search', {
boxSizing: 'border-box',
border: '.5px solid var(--dsw-alias-border-l4)',
diff --git a/packages/dsh-tauri-ui/src/client/components/sidebar.tsx b/packages/dsh-tauri-ui/src/client/components/sidebar.tsx
index 2b828161..84257ea9 100644
--- a/packages/dsh-tauri-ui/src/client/components/sidebar.tsx
+++ b/packages/dsh-tauri-ui/src/client/components/sidebar.tsx
@@ -1,100 +1,78 @@
-import type { ReactElement } from 'react'
-import type { SettingsSidebarProps } from '../types'
+import type { CSSProperties, ReactElement, PointerEvent as ReactPointerEvent } from 'react'
+import type { SettingsSidebarProps } from './sidebar.types'
import { SlotOutlet } from '@deepseek-ai/dsh-client-ui-renderer'
-/**
- * sidebar.tsx — shell.overlay 里的设置侧边栏(id 'dsh-tauri-ui-settings')。
- *
- * 布局即需求方 ASCII:整窗左侧停靠 —— 左栏(← 返回应用 / 🔍 搜索设置…
- * / 设置项导航,只过滤左栏列表)+ 右侧内容区。内容区渲染当前激活分区:
- *
- * <SlotOutlet slotKey={SETTINGS_SECTION_SLOT} ownerProps={{ close }} opts={{ only: activeId }} />
- *
- * 与官方 SettingsPanel 的渲染调用逐参数一致(owner={close},only=active)。
- * shell.overlay 是 list/root 且层本身 click-through,本条目 opt-in pointer
- * events。Esc 与“返回应用”都走 closeSettings();打开时聚焦搜索框。
- *
- * 视觉对齐官方(用户反馈 m00308/m00310):
- * 1. 左栏背景 = 官方 sidebar(.hHd-Xa_root)的 --dsw-specific-sidebar-fill;
- * 2. 内容区背景 = 主界面(.wSkVaW_root / .wSkVaW_scrollBody)的 --dsw-alias-bg-base;
- * 3. 左栏宽度可拖拽调整(镜像官方 DragHandle:pointer capture + rAF 节流),
- * 开通与官方一致的合约区间 clamp [264, 420](官方默认 280、关闭即忘);
- * 打开时按官方 sidebar 槽([data-slot="sidebar"])的实际渲染宽度做一次同步。
- * 4. 内容区宽度与主界面 hero 行一致:
- * min(calc(var(--dsh-composer-card-max-width) + 2 * var(--dsh-composer-side-clearance)), 100%)
- * (这些 --dsh-composer-* 变量定义域在官方 .wSkVaW_root 容器,overlay 在其外,
- * 由本组件在根节点自带相同定义),左右留空与主界面对齐。
- * 无“最小化/折叠 rail”模式:返回应用/Esc 即整体隐藏(与 codex 同思路)。
- *
- * 职责边界:拖拽交互 → hooks/use-rail-drag.ts;下层/外部表面隐藏 →
- * dom/settings-obstructions.ts;本文件只保留组件状态 + JSX + 打开期副作用。
- */
-import { useEventListener } from 'dsh-tauri/client'
-import { useEffect, useRef } from 'react'
+import { clamp, isEmpty, useEventListener, useStore } from 'dsh-tauri/client'
+import { useEffect, useRef, useState } from 'react'
import {
+ RAIL_WIDTH_DEFAULT,
+ RAIL_WIDTH_MAX,
+ RAIL_WIDTH_MIN,
SETTINGS_SECTION_SLOT,
+ SETTINGS_SIDEBAR_CLASS,
SETTINGS_STYLE_ID,
} from '../constants'
-import { concealSettingsObstructions } from '../dom/settings-obstructions'
-import { useSettingsSectionRows } from '../hooks/sections'
-import { useRailDrag } from '../hooks/use-rail-drag'
-import { settingsText, useSettingsLocale } from '../locales'
-import {
- clampRailWidth,
- closeSettings,
- RAIL_WIDTH_DEFAULT,
- selectSection,
- setRailWidth,
- store,
- useSettingsUi,
-} from '../store'
-import { useMountStyle } from '../utils/style'
+import { useMountStyle } from '../hooks/use-mount-style'
+import { locale } from '../locales'
+import { store } from '../store'
import { Icon } from './icon'
import { ArrowLeft } from './icons'
import { SettingsNavIcon } from './nav-icon'
import settingsSidebarStyle from './sidebar.cssr'
-/**
- * 侧边栏组件:整窗 docked 左栏 + 右侧官方设置分区内容。
- * @param _props - 标准钩子(当前未消费 useSessions,保留以符合合成 props)。
- * @returns 侧边栏,或 null(未打开时 shell.overlay 条目不占位、不挡点击)。
- */
export function SettingsSidebar(_props: SettingsSidebarProps): ReactElement | null {
- const ui = useSettingsUi()
- const rows = useSettingsSectionRows()
- useSettingsLocale()
+ const ui = useStore(store.settings, { sync: true })
+ const { rows } = useStore(store.sections)
+ locale.useLocale()
useMountStyle(settingsSidebarStyle, SETTINGS_STYLE_ID)
const searchRef = useRef<HTMLInputElement>(null)
- const { dragging, onHandlePointerDown } = useRailDrag()
+ const [dragging, setDragging] = useState(false)
+ const draggingRef = useRef(false)
+ const originRef = useRef({ width: RAIL_WIDTH_DEFAULT, x: 0 })
const documentRef = useRef<Document | null | undefined>(
typeof document === 'undefined' ? undefined : document,
)
- // Esc 关闭:文档级 keydown 由 reause 托管(卸载自动移除;仅打开期间生效)。
+ const onHandlePointerDown = (event: ReactPointerEvent<HTMLElement>): void => {
+ event.preventDefault()
+ event.currentTarget.setPointerCapture(event.pointerId)
+ originRef.current = {
+ width: store.settings.railWidth ?? RAIL_WIDTH_DEFAULT,
+ x: event.clientX,
+ }
+ draggingRef.current = true
+ setDragging(true)
+ }
+
+ useEventListener('pointermove', (event) => {
+ if (!draggingRef.current)
+ return
+ store.settings.setRailWidth(
+ clamp(originRef.current.width + event.clientX - originRef.current.x, RAIL_WIDTH_MIN, RAIL_WIDTH_MAX),
+ )
+ })
+
+ useEventListener('pointerup', () => {
+ if (!draggingRef.current)
+ return
+ draggingRef.current = false
+ setDragging(false)
+ })
+
useEventListener(documentRef, 'keydown', (event: KeyboardEvent) => {
if (ui.open && event.key === 'Escape')
- closeSettings()
+ store.settings.close()
})
- // 打开时聚焦搜索框;并按官方 sidebar 槽的实际渲染宽度同步左栏宽度(item 3)。
useEffect(() => {
if (!ui.open)
return
const el = document.querySelector('[data-slot="sidebar"]')
const width = el?.getBoundingClientRect().width
- if (typeof width === 'number' && width >= 264)
- setRailWidth(clampRailWidth(width))
+ if (typeof width === 'number' && width >= RAIL_WIDTH_MIN)
+ store.settings.setRailWidth(clamp(width, RAIL_WIDTH_MIN, RAIL_WIDTH_MAX))
searchRef.current?.focus()
}, [ui.open])
- // 自定义主题可能让设置页背景半透明,独立挂载到 body 的第三方 overlay 也可能
- // 建立自己的层叠上下文。设置打开期间隐藏并禁用这些下层/外部表面,关闭时由
- // disposer 精确恢复插件或主题原先拥有的内联状态。
- useEffect(() => {
- if (!ui.open)
- return
- return concealSettingsObstructions()
- }, [ui.open])
-
if (!ui.open)
return null
@@ -111,57 +89,56 @@ export function SettingsSidebar(_props: SettingsSidebarProps): ReactElement | nu
: visible[0]?.id
return (
- <div className="dshp-settings-sidebar" data-slot-sidebar="dsh-tauri-ui">
+ <div className={SETTINGS_SIDEBAR_CLASS} data-slot-sidebar="dsh-tauri-ui">
<div
- className="dshp-settings-sidebar__rail"
- style={{ '--dsh-settings-rail-width': `${railWidth}px` } as React.CSSProperties}
+ className={`${SETTINGS_SIDEBAR_CLASS}__rail`}
+ style={{ '--dsh-settings-rail-width': `${railWidth}px` } as CSSProperties}
>
<button
type="button"
- className="dshp-settings-sidebar__back"
- onClick={() => closeSettings()}
+ className={`${SETTINGS_SIDEBAR_CLASS}__back`}
+ onClick={() => store.settings.close()}
>
<Icon as={ArrowLeft} />
- {settingsText('back')}
+ {locale.text('back')}
</button>
<input
ref={searchRef}
- className="dshp-settings-sidebar__search"
+ className={`${SETTINGS_SIDEBAR_CLASS}__search`}
value={ui.query}
- placeholder={settingsText('search')}
- aria-label={settingsText('search')}
- onChange={event =>
- store.settings.setQuery(event.target.value)}
+ placeholder={locale.text('search')}
+ aria-label={locale.text('search')}
+ onChange={event => store.settings.setQuery(event.target.value)}
/>
- <nav className="dshp-settings-sidebar__nav" aria-label={settingsText('settings')}>
+ <nav className={`${SETTINGS_SIDEBAR_CLASS}__nav`} aria-label={locale.text('settings')}>
{visible.map(row => (
<button
key={row.id}
type="button"
- className={`dshp-settings-sidebar__nav-item${row.id === activeId ? ' dshp-settings-sidebar__nav-item--active' : ''}`}
+ className={`${SETTINGS_SIDEBAR_CLASS}__nav-item${row.id === activeId ? ` ${SETTINGS_SIDEBAR_CLASS}__nav-item--active` : ''}`}
aria-current={row.id === activeId ? 'true' : undefined}
- onClick={() => selectSection(row.id)}
+ onClick={() => store.settings.select(row.id)}
>
<SettingsNavIcon id={row.id} />
- <span className="dshp-settings-sidebar__nav-label">{row.label}</span>
+ <span className={`${SETTINGS_SIDEBAR_CLASS}__nav-label`}>{row.label}</span>
</button>
))}
- {visible.length === 0 && <div className="dshp-settings-sidebar__empty">{settingsText('noResults')}</div>}
+ {isEmpty(visible) && <div className={`${SETTINGS_SIDEBAR_CLASS}__empty`}>{locale.text('noResults')}</div>}
</nav>
</div>
<div
role="separator"
aria-orientation="vertical"
- aria-label={settingsText('settings')}
- className={`dshp-settings-sidebar__handle${dragging ? ' dshp-settings-sidebar__handle--dragging' : ''}`}
+ aria-label={locale.text('settings')}
+ className={`${SETTINGS_SIDEBAR_CLASS}__handle${dragging ? ` ${SETTINGS_SIDEBAR_CLASS}__handle--dragging` : ''}`}
onPointerDown={onHandlePointerDown}
/>
- <div className="dshp-settings-sidebar__content-outer">
- <div className="dshp-settings-sidebar__content-inner">
+ <div className={`${SETTINGS_SIDEBAR_CLASS}__content-outer`}>
+ <div className={`${SETTINGS_SIDEBAR_CLASS}__content-inner`}>
{activeId !== undefined && (
<SlotOutlet
slotKey={SETTINGS_SECTION_SLOT}
- ownerProps={{ close: () => closeSettings() }}
+ ownerProps={{ close: () => store.settings.close() }}
opts={{ only: activeId }}
/>
)}
diff --git a/packages/dsh-tauri-ui/src/client/components/sidebar.types.ts b/packages/dsh-tauri-ui/src/client/components/sidebar.types.ts
new file mode 100644
index 00000000..4832a859
--- /dev/null
+++ b/packages/dsh-tauri-ui/src/client/components/sidebar.types.ts
@@ -0,0 +1,7 @@
+import type { SessionListState } from 'dsh-tauri/client'
+import type { SelectorHook } from '../types/selector'
+
+export interface SettingsSidebarProps {
+ useSessions: SelectorHook<SessionListState>
+ useWorkspaces?: unknown
+}
diff --git a/packages/dsh-tauri-ui/src/client/components/special-icons.tsx b/packages/dsh-tauri-ui/src/client/components/special-icons.tsx
index e29ae430..6649b65a 100644
--- a/packages/dsh-tauri-ui/src/client/components/special-icons.tsx
+++ b/packages/dsh-tauri-ui/src/client/components/special-icons.tsx
@@ -1,6 +1,5 @@
import type { ReactElement, SVGProps } from 'react'
-/** Brand fallback; Gravity UI has no equivalent for this mark. */
export function FishMark({ width = 24, height = 24, ...props }: SVGProps<SVGSVGElement> = {}): ReactElement {
return (
<svg {...props} width={width} height={height} viewBox="0 0 24 24" fill="none" aria-hidden="true">
@@ -19,7 +18,6 @@ export function PanelLeftOutline({ width = 16, height = 16, ...props }: SVGProps
)
}
-/** Placeholder clock-like mark retained as a local special icon. */
export function IconPlaceholder({ width = 24, height = 24, ...props }: SVGProps<SVGSVGElement> = {}): ReactElement {
return (
<svg {...props} width={width} height={height} viewBox="0 0 24 24" fill="none" aria-hidden="true">
diff --git a/packages/dsh-tauri-ui/src/client/components/trigger.cssr.ts b/packages/dsh-tauri-ui/src/client/components/trigger.cssr.ts
index 5f0b565c..5e84bafc 100644
--- a/packages/dsh-tauri-ui/src/client/components/trigger.cssr.ts
+++ b/packages/dsh-tauri-ui/src/client/components/trigger.cssr.ts
@@ -1,10 +1,9 @@
-import { styles as sharedStyles } from '../theme'
+import { styles as sharedStyles } from '../constants/theme'
import { cssr } from '../utils/cssr'
const { c, bem: { b, m } } = cssr
const { primary, hover } = sharedStyles
-/** 设置触发按钮(sidebar.settings shadow 官方齿轮;rail 为窄栏圆钮)。 */
export default b('settings-trigger', {
boxSizing: 'border-box',
cursor: 'pointer',
diff --git a/packages/dsh-tauri-ui/src/client/components/trigger.tsx b/packages/dsh-tauri-ui/src/client/components/trigger.tsx
index 7af6a49d..5c7274b7 100644
--- a/packages/dsh-tauri-ui/src/client/components/trigger.tsx
+++ b/packages/dsh-tauri-ui/src/client/components/trigger.tsx
@@ -1,69 +1,42 @@
import type { ReactElement } from 'react'
-import type { SettingsTriggerProps } from '../types'
+import type { SettingsTriggerProps } from './trigger.types'
import { SlotOutlet } from '@deepseek-ai/dsh-client-ui-renderer'
-/**
- * trigger.tsx — sidebar.settings 座位的新“赢家”(priority -1)。
- *
- * 官方 SettingsRoot 以默认 priority 0 注册进 sidebar.settings 单槽;同 cell
- * 内最低 priority 渲染,因此本条目将其 shadow——官方“齿轮按钮 + 居中 modal”
- * 整体不再渲染。本组件取而代之:
- * - 同款触发按钮(内容借 <SlotOutlet slotKey="settings.trigger"/> 复用官方的
- * TriggerContent = 齿轮图标 + label,样式由本组件实现);
- * - 宿主 onboarding(谓词与官方一致:phase==='ready' 且无会话或当前会话
- * blank),步骤经 <SlotOutlet slotKey="settings.onboarding"/> 渲染。
- *
- * 关键点:本条目**不声明任何 children**(声明的六列子槽归属于官方条目,
- * 再声明会 throw),所有“渲染他人声明的槽”都走 SlotOutlet —— 这也是
- * renderer 补丁(导出一行 SlotOutlet)存在的全部理由。
- *
- * 职责边界:槽位注册 → register/trigger.ts;本文件只保留组件状态 + JSX。
- */
+import { uniq, useStore } from 'dsh-tauri/client'
import { useCallback, useEffect, useState } from 'react'
import {
+ SETTINGS_ONBOARDING_SLOT,
SETTINGS_TRIGGER_SLOT,
SETTINGS_TRIGGER_STYLE_ID,
} from '../constants'
-
-import { useSettingsOnboardingSteps } from '../hooks/sections'
-import { openSettings, useSettingsUi } from '../store'
-
-import { useMountStyle } from '../utils/style'
+import { useMountStyle } from '../hooks/use-mount-style'
+import { store } from '../store'
import settingsTriggerStyle from './trigger.cssr'
-/**
- * 触发组件:侧栏脚部的齿轮按钮 + 空会话引导宿主。
- * @param props - 合成槽位 props。
- * @param props.wide - 侧栏展开态(折叠时渲染 rail 圆钮)。
- * @param props.useSessions - 框架标准钩子:会话列表快照(引导激活谓词)。
- * @returns 触发按钮(open 状态写入共享 store)与可能的引导步骤。
- */
export function SettingsTrigger({ wide, useSessions }: SettingsTriggerProps): ReactElement {
- const ui = useSettingsUi()
- const steps = useSettingsOnboardingSteps()
+ const { open } = useStore(store.settings)
+ const { onboarding } = useStore(store.sections)
useMountStyle(settingsTriggerStyle, SETTINGS_TRIGGER_STYLE_ID)
- const [completed, setCompleted] = useState<Set<string>>(() => new Set())
+ const [completed, setCompleted] = useState<string[]>([])
- // 官方同款引导谓词:就绪且(无当前会话 或 当前会话空日志)→ 引导激活。
const onboardingActive = useSessions(
state =>
state.phase === 'ready'
&& (state.current === undefined || state.byId[state.current]?.blank === true),
)
- // 引导退出时复位完成集(与官方一致)。
useEffect(() => {
if (!onboardingActive)
- setCompleted(new Set())
+ setCompleted([])
}, [onboardingActive])
- const step = onboardingActive ? steps.find(s => !completed.has(s.id)) : undefined
+ const step = onboardingActive ? onboarding.find(s => !completed.includes(s.id)) : undefined
const completeStep = useCallback((id: string) => {
- setCompleted(previous => (previous.has(id) ? previous : new Set([...previous, id])))
+ setCompleted(previous => uniq([...previous, id]))
}, [])
const openSection = useCallback((id: string) => {
- openSettings(id)
+ store.settings.openAt(id)
}, [])
return (
@@ -71,15 +44,15 @@ export function SettingsTrigger({ wide, useSessions }: SettingsTriggerProps): Re
<button
type="button"
aria-haspopup="dialog"
- aria-expanded={ui.open}
- onClick={() => openSettings()}
+ aria-expanded={open}
+ onClick={() => store.settings.openAt()}
className={`dshp-settings-trigger${wide ? '' : ' dshp-settings-trigger--rail'}`}
>
<SlotOutlet slotKey={SETTINGS_TRIGGER_SLOT} ownerProps={{ wide }} />
</button>
{step !== undefined && (
<SlotOutlet
- slotKey="settings.onboarding"
+ slotKey={SETTINGS_ONBOARDING_SLOT}
ownerProps={{
stepId: step.id,
complete: () => completeStep(step.id),
diff --git a/packages/dsh-tauri-ui/src/client/components/trigger.types.ts b/packages/dsh-tauri-ui/src/client/components/trigger.types.ts
new file mode 100644
index 00000000..424591e6
--- /dev/null
+++ b/packages/dsh-tauri-ui/src/client/components/trigger.types.ts
@@ -0,0 +1,8 @@
+import type { SessionListState } from 'dsh-tauri/client'
+import type { SelectorHook } from '../types/selector'
+
+export interface SettingsTriggerProps {
+ wide: boolean
+ useSessions: SelectorHook<SessionListState>
+ useWorkspaces?: unknown
+}
diff --git a/packages/dsh-tauri-ui/src/client/constants/index.ts b/packages/dsh-tauri-ui/src/client/constants/index.ts
index 43e07743..6325ec74 100644
--- a/packages/dsh-tauri-ui/src/client/constants/index.ts
+++ b/packages/dsh-tauri-ui/src/client/constants/index.ts
@@ -1,7 +1,7 @@
-/** Shared protocol and UI constants for the dsh-tauri-ui client plugin. */
+import { PLUGIN_NAME } from '../../shared/constants'
-export const SETTINGS_UI_PLUGIN = 'dsh-tauri-ui'
-export const SETTINGS_UI_NS = SETTINGS_UI_PLUGIN
+export const SETTINGS_REGISTRANT = PLUGIN_NAME
+export const SETTINGS_SHELL_SEAT_ID = PLUGIN_NAME
export const SETTINGS_SHELL_OVERLAY_SLOT = 'shell.overlay'
export const SETTINGS_SIDEBAR_SLOT = 'sidebar.settings'
@@ -9,37 +9,33 @@ export const SETTINGS_SECTION_SLOT = 'settings.section'
export const SETTINGS_TRIGGER_SLOT = 'settings.trigger'
export const SETTINGS_ONBOARDING_SLOT = 'settings.onboarding'
-export const SETTINGS_SHELL_SEAT_ID = SETTINGS_UI_PLUGIN
export const SETTINGS_SIDEBAR_ID = 'dsh-tauri-ui-settings'
+export const SETTINGS_SIDEBAR_CLASS = 'dshp-settings-sidebar'
export const SETTINGS_STYLE_ID = 'dsh-tauri-ui-settings-sidebar-styles'
export const SETTINGS_TRIGGER_STYLE_ID = 'dsh-tauri-ui-settings-trigger-styles'
export const SETTINGS_NAV_ICON_STYLE_ID = 'dsh-tauri-ui-settings-nav-icon-styles'
export const MENU_SELECT_STYLE_ID = 'dsh-tauri-ui-menu-select-styles'
export const TURN_NAVIGATION_STYLE_ID = 'dsh-tauri-ui-turn-navigation-styles'
+export const GLOBAL_STYLE_ID = 'dsh-tauri-ui-global-styles'
+
+export const STYLES_EFFECT = `${PLUGIN_NAME}: styles`
+export const LOCALE_EFFECT = `${PLUGIN_NAME}: locale`
+export const SEAT_EFFECT = `${PLUGIN_NAME}: shell.overlay seat`
+export const SECTIONS_EFFECT = `${PLUGIN_NAME}: settings sections projection`
+export const SETTINGS_EFFECT = `${PLUGIN_NAME}: settings panel`
+export const OBSTRUCTIONS_EFFECT = `${PLUGIN_NAME}: settings obstructions`
+
export const TURN_NAVIGATION_LABEL_ZH = '轮次导航'
export const TURN_NAVIGATION_LABEL_EN = 'Turn navigation'
export const TURN_NAVIGATION_SELECTOR = `:is(nav[aria-label="${TURN_NAVIGATION_LABEL_ZH}"], nav[aria-label="${TURN_NAVIGATION_LABEL_EN}"])`
export const TURN_NAVIGATION_NARROW_SELECTOR = `[data-sidebar-collapsed] ${TURN_NAVIGATION_SELECTOR}`
-export const SETTINGS_REGISTRANT = SETTINGS_UI_PLUGIN
+
export const SETTINGS_TRIGGER_PRIORITY = -1
export const SETTINGS_UNDERLAY_SLOT_KEYS = ['sidebar', 'conversation', 'details'] as const
export const SETTINGS_EXTERNAL_OVERLAY_SELECTORS = ['[data-dsh-better-sidebar]', '[data-dsh-panel]'] as const
+export const SIDEBAR_WIDTH_PROPERTY = '--dsh-sidebar-width'
export const RAIL_WIDTH_MIN = 264
export const RAIL_WIDTH_MAX = 420
export const RAIL_WIDTH_DEFAULT = 280
-
-export const DICT_ZH = {
- back: '返回应用',
- search: '搜索设置…',
- settings: '设置',
- noResults: '没有匹配的设置项',
-} as const
-
-export const DICT_EN: Record<keyof typeof DICT_ZH, string> = {
- back: 'Back to app',
- search: 'Search settings…',
- settings: 'Settings',
- noResults: 'No matching settings',
-}
diff --git a/packages/dsh-tauri-ui/src/client/theme.ts b/packages/dsh-tauri-ui/src/client/constants/theme.ts
similarity index 72%
rename from packages/dsh-tauri-ui/src/client/theme.ts
rename to packages/dsh-tauri-ui/src/client/constants/theme.ts
index c3072638..666179ed 100644
--- a/packages/dsh-tauri-ui/src/client/theme.ts
+++ b/packages/dsh-tauri-ui/src/client/constants/theme.ts
@@ -1,8 +1,3 @@
-/**
- * Shared design values extracted from the dsh web-frontend design tokens.
- * Keep values here (rather than a second CSS-variable constants layer) so
- * consumers use one stable namespace and theme changes remain centralized.
- */
export const styles = {
primary: 'var(--dsw-alias-label-primary)',
secondary: 'var(--dsw-alias-label-secondary)',
@@ -29,6 +24,19 @@ export const styles = {
boxShadow: '0 0 0 2px var(--dsw-alias-border-l3)',
outline: 'none',
},
- /** Official ModelsSection selectInput arrow data URI. */
chevronSelectSvg: `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%2381858C' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")`,
} as const
+
+/**
+ * 面板根容器:与官方会话内容列同宽的居中容器,并留出上下间距。
+ *
+ * `--dsh-chat-content-width` 由 `PanelWidthSync` 按官方公式发布在面板容器上(面板与会话根是
+ * `main` 槽同级占位者,继承不到会话根的行内变量),这里的 clamp 只是未经同步时的兜底。
+ */
+export const panelContainer = {
+ boxSizing: 'border-box',
+ width: '100%',
+ maxWidth: 'var(--dsh-chat-content-width, clamp(680px, 64%, 920px))',
+ marginInline: 'auto',
+ paddingBlock: '24px',
+} as const
diff --git a/packages/dsh-tauri-ui/src/client/dom/settings-obstructions.ts b/packages/dsh-tauri-ui/src/client/dom/settings-obstructions.ts
deleted file mode 100644
index 9a57b1a1..00000000
--- a/packages/dsh-tauri-ui/src/client/dom/settings-obstructions.ts
+++ /dev/null
@@ -1,138 +0,0 @@
-import {
- SETTINGS_EXTERNAL_OVERLAY_SELECTORS,
- SETTINGS_UNDERLAY_SLOT_KEYS,
-} from '../constants'
-
-interface SettingsObstructionState {
- displayPriority: string
- displayValue: string
- element: HTMLElement
- widthPriority: string
- widthValue: string
-}
-
-interface SidebarWidthState {
- hadInlineValue: boolean
- priority: string
- value: string
-}
-
-const SIDEBAR_WIDTH_PROPERTY = '--dsh-sidebar-width'
-
-/**
- * Finds host surfaces that could remain above or show through the settings overlay.
- * A set is required because an independently mounted overlay may also own a slot anchor.
- */
-export function getSettingsObstructionTargets(root: ParentNode): HTMLElement[] {
- const targets = new Set<HTMLElement>()
-
- for (const slotKey of SETTINGS_UNDERLAY_SLOT_KEYS) {
- const anchor = root.querySelector<HTMLElement>(`[data-slot="${slotKey}"]`)
- if (anchor)
- targets.add(anchor.parentElement ?? anchor)
- }
-
- for (const selector of SETTINGS_EXTERNAL_OVERLAY_SELECTORS) {
- for (const element of root.querySelectorAll<HTMLElement>(selector))
- targets.add(element)
- }
-
- return [...targets]
-}
-
-/**
- * Hides the underlying layout while the docked settings page is open.
- * better-sidebar reserves space through --dsh-sidebar-width, so both the
- * panel and that layout push must be removed for settings to use the full width.
- */
-export function concealSettingsObstructions(root: ParentNode = document): () => void {
- const documentRoot = document.documentElement
- const sidebarWidth = documentRoot.style.getPropertyValue(SIDEBAR_WIDTH_PROPERTY)
- const previousSidebarWidth: SidebarWidthState = {
- hadInlineValue: sidebarWidth !== '',
- priority: documentRoot.style.getPropertyPriority(SIDEBAR_WIDTH_PROPERTY),
- value: sidebarWidth,
- }
- const previous = new Map<HTMLElement, SettingsObstructionState>()
- let restored = false
-
- documentRoot.style.setProperty(SIDEBAR_WIDTH_PROPERTY, '0', 'important')
-
- const reconcile = (): void => {
- if (restored)
- return
-
- // Reapply this because better-sidebar may update its layout variable while
- // the settings page remains open.
- documentRoot.style.setProperty(SIDEBAR_WIDTH_PROPERTY, '0', 'important')
-
- for (const element of getSettingsObstructionTargets(root)) {
- if (!previous.has(element)) {
- previous.set(element, {
- displayPriority: element.style.getPropertyPriority('display'),
- displayValue: element.style.getPropertyValue('display'),
- element,
- widthPriority: element.style.getPropertyPriority('width'),
- widthValue: element.style.getPropertyValue('width'),
- })
- }
- element.style.setProperty('display', 'none', 'important')
- element.style.setProperty('width', '0', 'important')
- }
- }
-
- const ownerDocument = root instanceof Document
- ? root
- : (root as Node).ownerDocument
- const observerRoot = root instanceof Document
- ? root.documentElement
- : (root as Node)
- const Observer = ownerDocument?.defaultView?.MutationObserver ?? MutationObserver
- const observer = new Observer(reconcile)
-
- observer.observe(observerRoot, {
- attributeFilter: ['data-dsh-better-sidebar', 'data-slot'],
- attributes: true,
- childList: true,
- subtree: true,
- })
- reconcile()
-
- return () => {
- if (restored)
- return
-
- restored = true
- observer.disconnect()
-
- for (const {
- displayPriority,
- displayValue,
- element,
- widthPriority,
- widthValue,
- } of previous.values()) {
- if (displayValue !== '')
- element.style.setProperty('display', displayValue, displayPriority)
- else
- element.style.removeProperty('display')
- if (widthValue !== '')
- element.style.setProperty('width', widthValue, widthPriority)
- else
- element.style.removeProperty('width')
- }
-
- if (previousSidebarWidth.hadInlineValue) {
- documentRoot.style.setProperty(
- SIDEBAR_WIDTH_PROPERTY,
- previousSidebarWidth.value,
- previousSidebarWidth.priority,
- )
- }
- else {
- documentRoot.style.removeProperty(SIDEBAR_WIDTH_PROPERTY)
- }
-
- previous.clear()
- }
-}
diff --git a/packages/dsh-tauri-ui/src/client/hooks/sections.ts b/packages/dsh-tauri-ui/src/client/hooks/sections.ts
deleted file mode 100644
index 2963fab7..00000000
--- a/packages/dsh-tauri-ui/src/client/hooks/sections.ts
+++ /dev/null
@@ -1,76 +0,0 @@
-import type { SettingsRow } from '../types'
-import { useStore } from 'dsh-tauri/client'
-import { useMemo } from 'react'
-import { SETTINGS_ONBOARDING_SLOT, SETTINGS_SECTION_SLOT } from '../constants'
-import { useSettingsLocale } from '../locales'
-import { getSettingsSlots } from '../register/sections'
-import { store } from '../store'
-
-export type { SettingsRow } from '../types'
-/**
- * hooks/sections.ts — 设置分区/引导步骤的注册表投影(只读 hooks 半区)。
- *
- * 官方 SettingsRoot 用 inject hooks(sections / onboardingSteps)把
- * 'settings.section' / 'settings.onboarding' 两个 list 槽的注册条目投影为
- * 导航行。这里做同样的事:订阅槽位 revision + locale 变更,重算
- * `entries(key) -> {id, order, label}` 排序行。
- *
- * 槽位变更不经自建订阅器:注册中心的注册/声明通知由 register/sections.ts 在
- * apply 期订阅并推进 store.slots 的 revision,本文件经 useStore 按 key 订阅。
- *
- * label 与官方一致经 resolveSlotLabel 语义解析(函数型 label 即按当前
- * locale 求值,所以 locale 变更也要触发重算)。
- *
- * 槽注册中心引用不在此持有:由 register/sections.ts 的 registerSettingsSections
- * 在 apply 时存入(卸载即清),本文件经 getSettingsSlots() 读取——槽位
- * 所有权与卸载清理只存在一处。
- */
-
-/** 解析条目 label(镜像官方 resolveSlotLabel 语义;不依赖 ui-slots 运行时导出)。 */
-function resolveLabel(label: unknown): string | undefined {
- if (typeof label === 'function')
- return String((label as () => unknown)())
- return typeof label === 'string' ? label : undefined
-}
-
-/** 带 key/order/label 的条目行(按 order 升序)。 */
-function projectRows(slotKey: string): SettingsRow[] {
- const slots = getSettingsSlots()
- if (!slots)
- return []
- return slots
- .entries(slotKey as never)
- .map(e => ({
- id: e.options.id ?? '',
- order: e.options.order ?? 0,
- label: resolveLabel(e.options.label) ?? '',
- }))
- .filter(r => r.id !== '')
- .sort((a, b) => a.order - b.order)
-}
-
-/**
- * 订阅一个 list 槽的注册/声明变更。
- *
- * revision 由 register/sections.ts 的 apply 期订阅推进(见 store/modules/slots.ts),
- * 这里只经 useStore 读取并按 key 精确重渲染。
- * @param slotKey - 槽 key。
- * @returns 当前 revision。
- */
-function useSlotVersion(slotKey: string): number {
- const { revisions } = useStore(store.slots)
- return revisions[slotKey] ?? 0
-}
-
-/** 设置分区导航行('settings.section' 投影;订阅槽位与 locale 变更)。 */
-export function useSettingsSectionRows(): SettingsRow[] {
- const sectionVersion = useSlotVersion(SETTINGS_SECTION_SLOT)
- useSettingsLocale()
- return useMemo(() => projectRows(SETTINGS_SECTION_SLOT), [sectionVersion])
-}
-
-/** 引导步骤行('settings.onboarding' 投影,仅 id+order)。 */
-export function useSettingsOnboardingSteps(): SettingsRow[] {
- const onboardingVersion = useSlotVersion(SETTINGS_ONBOARDING_SLOT)
- return useMemo(() => projectRows(SETTINGS_ONBOARDING_SLOT), [onboardingVersion])
-}
diff --git a/packages/dsh-tauri-ui/src/client/hooks/use-mount-style.ts b/packages/dsh-tauri-ui/src/client/hooks/use-mount-style.ts
new file mode 100644
index 00000000..d0e6b9e8
--- /dev/null
+++ b/packages/dsh-tauri-ui/src/client/hooks/use-mount-style.ts
@@ -0,0 +1,14 @@
+import type { CNode } from 'css-render'
+import { useEffect, useRef } from 'react'
+import { mountStyle } from '../utils/style'
+
+export function useMountStyle(cnode: CNode, id?: string): void {
+ const disposerRef = useRef<(() => void) | null>(null)
+ useEffect(() => {
+ disposerRef.current = mountStyle(cnode, id)
+ return () => {
+ disposerRef.current?.()
+ disposerRef.current = null
+ }
+ }, [cnode, id])
+}
diff --git a/packages/dsh-tauri-ui/src/client/hooks/use-rail-drag.ts b/packages/dsh-tauri-ui/src/client/hooks/use-rail-drag.ts
deleted file mode 100644
index e555a059..00000000
--- a/packages/dsh-tauri-ui/src/client/hooks/use-rail-drag.ts
+++ /dev/null
@@ -1,49 +0,0 @@
-import type { PointerEvent as ReactPointerEvent } from 'react'
-import { useState } from 'react'
-import { RAIL_WIDTH_DEFAULT } from '../constants'
-import { clampRailWidth, setRailWidth, useSettingsUi } from '../store'
-
-/**
- * hooks/use-rail-drag.ts — 左栏宽度拖拽交互(pointer capture + rAF 节流)。
- *
- * 从 sidebar.tsx 拆出的独立交互钩子:拖拽句柄按 pointermove 实时写共享 store
- * 的 railWidth(调用方已按合约钳制),指针释放后结束拖拽。返回的 dragging 用于
- * 句柄的按压态样式(.dsh-tu-settingsHandleDragging)。
- */
-export interface RailDragState {
- /** 拖拽进行中(句柄按压态)。 */
- dragging: boolean
- /** 绑定到分隔句柄的 onPointerDown(镜像官方 DragHandle 交互)。 */
- onHandlePointerDown: (event: ReactPointerEvent<HTMLElement>) => void
-}
-
-/** 左栏宽度拖拽钩子(railWidth 合约 clamp 见 store.clampRailWidth)。 */
-export function useRailDrag(): RailDragState {
- const ui = useSettingsUi()
- const [dragging, setDragging] = useState(false)
-
- const onHandlePointerDown = (event: ReactPointerEvent<HTMLElement>): void => {
- event.preventDefault()
- event.currentTarget.setPointerCapture(event.pointerId)
- const startX = event.clientX
- const startWidth = ui.railWidth ?? RAIL_WIDTH_DEFAULT
- setDragging(true)
- let raf = 0
- const onMove = (moveEvent: PointerEvent): void => {
- if (raf)
- cancelAnimationFrame(raf)
- raf = requestAnimationFrame(() => {
- setRailWidth(clampRailWidth(startWidth + (moveEvent.clientX - startX)))
- })
- }
- const onUp = (): void => {
- window.removeEventListener('pointermove', onMove)
- window.removeEventListener('pointerup', onUp)
- setDragging(false)
- }
- window.addEventListener('pointermove', onMove)
- window.addEventListener('pointerup', onUp)
- }
-
- return { dragging, onHandlePointerDown }
-}
diff --git a/packages/dsh-tauri-ui/src/client/index.ts b/packages/dsh-tauri-ui/src/client/index.ts
index 0629d831..e5b44310 100644
--- a/packages/dsh-tauri-ui/src/client/index.ts
+++ b/packages/dsh-tauri-ui/src/client/index.ts
@@ -1,99 +1,42 @@
import type {} from '@deepseek-ai/dsh-client-ui-layout/client'
-/**
- * dsh-tauri-ui 客户端插件体(browser half):定制化 Tauri UI 的未来载体。
- *
- * 第一项功能:把 dsh 的设置弹窗(dialog)改为左侧停靠的侧边栏
- * (左栏 = 返回应用 + 搜索 + 设置项导航;右侧 = 官方各设置分区内容)。
- *
- * 关系:`dsh-tauri` 是纯消息桥(无 UI、无运行时依赖),只负责把宿主导航栏
- * 命令转发给 iframe 内的 dsh 应用并回报状态;本插件是它的 **UI 半区**——
- * 桌面风格的自定义 chrome 作为插件加载进 `shell.overlay` 帧级浮动层。
- *
- * 本功能的结构(全部 slot-shadow,零结构补丁,零新增依赖):
- * - components/trigger.tsx 注册进 sidebar.settings(priority -1)
- * shadow 官方 SettingsRoot:齿轮按钮 + onboarding 宿主;官方 dialog 被抑制。
- * (槽位注册在 register/trigger.ts)
- * - components/sidebar.tsx 注册进 shell.overlay(id dsh-tauri-ui-settings):
- * 整窗 docked 左栏 + 内容区,经 <SlotOutlet slotKey="settings.section"/>
- * 渲染官方各分区(SlotOutlet 由 renderer 的一行导出补丁提供)。
- * (槽位注册在 register/sidebar.ts;拖拽交互在 hooks/use-rail-drag.ts;
- * 下层/外部表面隐藏补丁在 dom/settings-obstructions.ts)
- * - store/ 触发器与侧边栏共享 {open, activeId, query}(valtio-define 域存储)。
- * - hooks/sections.ts + register/sections.ts 'settings.section' /
- * 'settings.onboarding' 注册条目的导航行投影(installer 持有 slotsRef
- * 并订阅槽位变更,hooks 读 store.slots 的 revision)。
- * - locales/ 本插件文案(返回应用/搜索设置…)双语注册。
- *
- * 保留了骨架期的 `shell.overlay` 条目(id dsh-tauri-ui)作为未来 chrome
- * 的落点,与设置侧边栏(id dsh-tauri-ui-settings)并行不冲突;注册一律走
- * register/ 下的 `defineRegister` feature,由 controller 托管卸载清理。
- */
import type { ClientContext } from 'dsh-tauri/client'
-import { SlotOutlet } from '@deepseek-ai/dsh-client-ui-renderer'
-import { SETTINGS_UI_PLUGIN, TURN_NAVIGATION_STYLE_ID } from './constants'
-import { registerSettingsLocale } from './locales'
+import { PLUGIN_NAME } from '../shared/constants'
+import {
+ LOCALE_EFFECT,
+ OBSTRUCTIONS_EFFECT,
+ SEAT_EFFECT,
+ SECTIONS_EFFECT,
+ SETTINGS_EFFECT,
+ STYLES_EFFECT,
+} from './constants'
+import { locale } from './locales'
+import { registerSettingsObstructions } from './register/obstructions'
import { registerShellSeat } from './register/seat'
import { registerSettingsSections } from './register/sections'
-import { registerSettingsSidebar } from './register/sidebar'
-import { registerSettingsTrigger } from './register/trigger'
-import globalStyle from './styles/global.cssr'
-import turnNavigationStyle from './styles/index.cssr'
-import { mountStyle } from './utils/style'
+import { registerSettings } from './register/settings'
+import { registerStyles } from './register/styles'
-/** 插件显示名(诊断元数据)。 */
-export const name = SETTINGS_UI_PLUGIN
+export * from './components'
+export type * from './components/menu-select.types'
+export type * from './components/sidebar.types'
+export type * from './components/trigger.types'
+export * from './constants/theme'
+export * from './hooks/use-mount-style'
+export type * from './store/modules/sections.types'
+export type * from './store/modules/settings.types'
+export type * from './types/sections'
+export type * from './types/selector'
+export * from './utils/cssr'
+export * from './utils/style'
-/** 需要的客户端服务:slots(注册点位)、layout(未来 chrome 的面板动作)、locale(双语文案)。 */
+export const name = PLUGIN_NAME
export const inject = ['slots', 'layout', 'locale']
-// The client entry is also the workspace-wide shared UI surface.
-export * from './components'
-export { styles } from './theme'
-export type * from './types'
-export { cssr } from './utils/cssr'
-export { mountStyle, useMountStyle } from './utils/style'
-
-/**
- * 插件体:注册未来 chrome 的落点座位 + 设置侧边栏功能。
- * @param ctx - 客户端根上下文。
- */
export function apply(ctx: ClientContext): void {
- // 骨架期落点:未来桌面 chrome(顶部导航/窗口控件等)在此渲染。
- // alpha 的 slot 必须先由父条目的 children 表声明才能注册进入;shell.overlay
- // 由 ui-layout 的 AppFrame 声明,故通过 inject 等其声明(live)后再注册,
- // 避免 `slot "shell.overlay" is not declared` 运行时报错。
- // (注册体在 register/seat.ts;controller 负责卸载时撤销 inject。)
- ctx.effect(registerShellSeat, 'dsh-tauri-ui: shell.overlay seat')
-
- // 第一项功能:设置弹窗 → 侧边栏。
- // 侧边栏依赖 renderer 补丁导出的 <SlotOutlet>(任意槽渲染的入口)。核心未带
- // 补丁时(旧安装),SlotOutlet 为 undefined —— 此时降级:不注册侧边栏与
- // 触发条目,官方设置 dialog 原样工作,绝不白屏(功能整体不生效即可)。
- // 设置侧边栏/触发器/导航图标样式由各自组件 useMountStyle 自动挂载。
- // The core turn rail is rendered inside a clipped conversation column. Keep
- // its semantic nav visible in the 56px sidebar rail by patching only the
- // stable bilingual aria label; core-owned children and scrolling stay intact.
- ctx.effect(
- () => mountStyle(turnNavigationStyle, TURN_NAVIGATION_STYLE_ID),
- 'dsh-tauri-ui: turn navigation styles',
- )
- ctx.effect(
- () => mountStyle(globalStyle, 'dsh-tauri-ui-global-styles'),
- 'dsh-tauri-ui: global styles',
- )
- registerSettingsLocale(ctx)
- // 设置分区投影:槽位订阅与引用清理也走 effect(插件卸载后订阅取消、slotsRef 复位)。
- ctx.effect(
- () => registerSettingsSections(ctx.slots as never),
- 'dsh-tauri-ui: settings sections projection',
- )
- if (typeof SlotOutlet === 'function') {
- ctx.effect(registerSettingsSidebar, 'dsh-tauri-ui: settings sidebar')
- ctx.effect(registerSettingsTrigger, 'dsh-tauri-ui: settings trigger')
- }
- else {
- console.warn(
- '[dsh-tauri-ui] <SlotOutlet> unavailable (renderer patch missing) — settings sidebar disabled, official dialog stays.',
- )
- }
+ ctx.effect(locale.registerLocale, LOCALE_EFFECT)
+ ctx.effect(registerStyles, STYLES_EFFECT)
+ ctx.effect(registerShellSeat, SEAT_EFFECT)
+ ctx.effect(registerSettingsSections, SECTIONS_EFFECT)
+ ctx.effect(registerSettings, SETTINGS_EFFECT)
+ ctx.effect(registerSettingsObstructions, OBSTRUCTIONS_EFFECT)
}
diff --git a/packages/dsh-tauri-ui/src/client/locales/index.ts b/packages/dsh-tauri-ui/src/client/locales/index.ts
index b949c1e2..c95f6020 100644
--- a/packages/dsh-tauri-ui/src/client/locales/index.ts
+++ b/packages/dsh-tauri-ui/src/client/locales/index.ts
@@ -1,47 +1,17 @@
-/**
- * locale.ts — 本插件自有的界面文案(返回应用 / 搜索设置… / 设置)。
- *
- * 用 locale 服务的**非类型化**注册面(register(ns, locale, dict))挂进
- * dsh 的 locale 表:zh/en 双语齐全即满足运行时“bilingual balance”约束,
- * 且无需增广 LocaleNamespaceMap(避免外部类型依赖)。
- *
- * 组件侧不引入框架的 `t` 座(那需要 register option locale + 增广),
- * 改用 store.locale 的 revision:apply 时订阅 locale 变更并 bump ->
- * 组件经 useStore(store.locale) 订阅 rev 重渲染,文案按当前 active locale
- * 从本地字典读取。
- */
-import type { ClientContext } from 'dsh-tauri/client'
-import type { SettingsUiKey } from '../types'
-import { useStore } from 'dsh-tauri/client'
-import { DICT_EN, DICT_ZH, SETTINGS_UI_NS } from '../constants'
-import { store } from '../store'
+import { defineLocale } from 'dsh-tauri/client'
+import { PLUGIN_NAME } from '../../shared/constants'
-export type { SettingsUiKey } from '../types'
-
-/** 活跃语言 id(module 级缓存,apply 时初始化并由订阅推进)。 */
-let activeLocale = 'en'
-
-/**
- * 在 apply 里安装:注册本插件的双语字典,并桥接 locale 变更到 store.locale。
- * @param ctx - 客户端根上下文(须已注入 locale 服务)。
- */
-export function registerSettingsLocale(ctx: ClientContext): void {
- activeLocale = ctx.locale.getLocale().active
- ctx.locale.register(SETTINGS_UI_NS, 'zh', DICT_ZH)
- ctx.locale.register(SETTINGS_UI_NS, 'en', DICT_EN)
- ctx.locale.subscribe(() => {
- activeLocale = ctx.locale.getLocale().active
- store.locale.bump()
- })
-}
-
-/** 按当前活跃语言取一条文案。 */
-export function settingsText(key: SettingsUiKey): string {
- return activeLocale === 'zh' ? DICT_ZH[key] : DICT_EN[key]
-}
-
-/** 组件内订阅 locale 变更(revision 前进即重渲染)。 */
-export function useSettingsLocale(): number {
- const { rev } = useStore(store.locale)
- return rev
-}
+export const locale = defineLocale(PLUGIN_NAME, {
+ zh: {
+ back: '返回应用',
+ search: '搜索设置…',
+ settings: '设置',
+ noResults: '没有匹配的设置项',
+ },
+ en: {
+ back: 'Back to app',
+ search: 'Search settings…',
+ settings: 'Settings',
+ noResults: 'No matching settings',
+ },
+})
diff --git a/packages/dsh-tauri-ui/src/client/register/obstructions.ts b/packages/dsh-tauri-ui/src/client/register/obstructions.ts
new file mode 100644
index 00000000..7988c633
--- /dev/null
+++ b/packages/dsh-tauri-ui/src/client/register/obstructions.ts
@@ -0,0 +1,114 @@
+import type { ClientContext } from 'dsh-tauri/client'
+import { compact, defineRegister, uniq } from 'dsh-tauri/client'
+import {
+ SETTINGS_EXTERNAL_OVERLAY_SELECTORS,
+ SETTINGS_SIDEBAR_CLASS,
+ SETTINGS_UNDERLAY_SLOT_KEYS,
+ SIDEBAR_WIDTH_PROPERTY,
+} from '../constants'
+
+interface ObstructionState {
+ displayPriority: string
+ displayValue: string
+ widthPriority: string
+ widthValue: string
+}
+
+interface SidebarWidthState {
+ hadInlineValue: boolean
+ priority: string
+ value: string
+}
+
+export const registerSettingsObstructions = defineRegister<ClientContext>((controller) => {
+ if (typeof document === 'undefined')
+ return
+
+ const documentRoot = document.documentElement
+ const previous = new Map<HTMLElement, ObstructionState>()
+ let previousSidebarWidth: SidebarWidthState | undefined
+
+ const conceal = (): void => {
+ for (const element of getObstructionTargets(document)) {
+ if (!previous.has(element)) {
+ previous.set(element, {
+ displayPriority: element.style.getPropertyPriority('display'),
+ displayValue: element.style.getPropertyValue('display'),
+ widthPriority: element.style.getPropertyPriority('width'),
+ widthValue: element.style.getPropertyValue('width'),
+ })
+ }
+ element.style.setProperty('display', 'none', 'important')
+ element.style.setProperty('width', '0', 'important')
+ }
+ documentRoot.style.setProperty(SIDEBAR_WIDTH_PROPERTY, '0', 'important')
+ }
+
+ const restore = (): void => {
+ for (const [element, state] of previous) {
+ restoreProperty(element.style, 'display', state.displayValue, state.displayPriority)
+ restoreProperty(element.style, 'width', state.widthValue, state.widthPriority)
+ }
+ previous.clear()
+
+ if (previousSidebarWidth === undefined)
+ return
+
+ if (previousSidebarWidth.hadInlineValue)
+ documentRoot.style.setProperty(SIDEBAR_WIDTH_PROPERTY, previousSidebarWidth.value, previousSidebarWidth.priority)
+ else
+ documentRoot.style.removeProperty(SIDEBAR_WIDTH_PROPERTY)
+ previousSidebarWidth = undefined
+ }
+
+ const reconcile = (): void => {
+ if (controller.isDisposed())
+ return
+
+ if (document.querySelector(`.${SETTINGS_SIDEBAR_CLASS}`) === null) {
+ restore()
+ return
+ }
+
+ if (previousSidebarWidth === undefined) {
+ const value = documentRoot.style.getPropertyValue(SIDEBAR_WIDTH_PROPERTY)
+ previousSidebarWidth = {
+ hadInlineValue: value !== '',
+ priority: documentRoot.style.getPropertyPriority(SIDEBAR_WIDTH_PROPERTY),
+ value,
+ }
+ }
+ conceal()
+ }
+
+ controller.observe(
+ documentRoot,
+ reconcile,
+ {
+ attributeFilter: ['data-dsh-better-sidebar', 'data-slot'],
+ attributes: true,
+ childList: true,
+ subtree: true,
+ },
+ )
+ controller.add(restore)
+ reconcile()
+})
+
+function getObstructionTargets(root: ParentNode): HTMLElement[] {
+ const anchors = SETTINGS_UNDERLAY_SLOT_KEYS
+ .map(slotKey => root.querySelector<HTMLElement>(`[data-slot="${slotKey}"]`))
+ .map(anchor => anchor?.parentElement ?? anchor)
+
+ const overlays = SETTINGS_EXTERNAL_OVERLAY_SELECTORS
+ .flatMap(selector => [...root.querySelectorAll<HTMLElement>(selector)])
+
+ return uniq(compact([...anchors, ...overlays]))
+}
+
+function restoreProperty(style: CSSStyleDeclaration, property: string, value: string, priority: string): void {
+ if (value !== '')
+ style.setProperty(property, value, priority)
+ else
+ style.removeProperty(property)
+}
diff --git a/packages/dsh-tauri-ui/src/client/register/seat.ts b/packages/dsh-tauri-ui/src/client/register/seat.ts
index 2fa64a62..5fc2d975 100644
--- a/packages/dsh-tauri-ui/src/client/register/seat.ts
+++ b/packages/dsh-tauri-ui/src/client/register/seat.ts
@@ -7,13 +7,6 @@ import {
SETTINGS_SHELL_SEAT_ID,
} from '../constants'
-/**
- * register/seat.ts — shell.overlay 落点座位注册(骨架占位,defineRegister)。
- *
- * 骨架期落点:未来桌面 chrome(顶部导航/窗口控件等)在此渲染。shell.overlay
- * 由 ui-layout 的 AppFrame 声明,故通过 inject 等其声明(live)后再注册;
- * 注册句柄交给 controller,插件卸载时随 effect 一并撤销。
- */
export const registerShellSeat = defineRegister<ClientContext>((controller, ctx) => {
controller.add(
ctx.slots.inject(SETTINGS_SHELL_OVERLAY_SLOT, () =>
diff --git a/packages/dsh-tauri-ui/src/client/register/sections.ts b/packages/dsh-tauri-ui/src/client/register/sections.ts
index 2aedcb21..6045df65 100644
--- a/packages/dsh-tauri-ui/src/client/register/sections.ts
+++ b/packages/dsh-tauri-ui/src/client/register/sections.ts
@@ -1,43 +1,16 @@
-import type { SlotRegistry } from '@deepseek-ai/dsh-client-ui-renderer/client'
+import type { ClientContext } from 'dsh-tauri/client'
+import { defineRegister } from 'dsh-tauri/client'
import { SETTINGS_ONBOARDING_SLOT, SETTINGS_SECTION_SLOT } from '../constants'
-import { store } from '../store'
+import { loadOnboardingSteps, loadSections } from '../service/sections'
-/**
- * register/sections.ts — 'settings.section' / 'settings.onboarding' 投影的
- * 安装器半区:持有槽注册中心的模块引用(slotsRef),供 hooks/sections.ts
- * 的只读投影 hooks 在 render 期经 getSettingsSlots() 读取。
- *
- * 引用所有权、变更订阅与卸载清理只存在本文件:registerSettingsSections 在
- * apply 时把 ctx.slots 写入并订阅两个 list 槽(变更即推进 store.slots 对应
- * revision),返回的卸载函数在插件卸载后取消订阅并清除模块引用,避免跨实例残留。
- */
-
-/** apply 时存入的槽注册中心(hooks/sections.ts 在 render 期经它投影)。 */
-type SettingsSlots = SlotRegistry
-
-/** 被投影的槽位 key(与 hooks/sections.ts 的两个投影一一对应)。 */
-const PROJECTED_SLOT_KEYS = [SETTINGS_SECTION_SLOT, SETTINGS_ONBOARDING_SLOT] as const
-
-let slotsRef: SettingsSlots | undefined
-
-/**
- * 在 apply 里安装:把 ctx.slots 引用留给投影 hooks,并订阅槽位变更推进 store。
- * @param slots - 客户端 slots 注册中心(ctx.slots)。
- * @returns 卸载函数(取消订阅并清除模块引用,避免跨实例残留)。
- */
-export function registerSettingsSections(slots: SettingsSlots): () => void {
- slotsRef = slots
- const unsubscribes = PROJECTED_SLOT_KEYS.map(key =>
- slots.subscribe(key as never, () => store.slots.bump(key)))
- return () => {
- for (const unsubscribe of unsubscribes)
- unsubscribe()
- if (slotsRef === slots)
- slotsRef = undefined
+export const registerSettingsSections = defineRegister<ClientContext>((controller, ctx) => {
+ const sync = (): void => {
+ void loadSections(ctx.slots)
+ void loadOnboardingSteps(ctx.slots)
}
-}
-/** 读取当前槽注册中心(hooks/sections.ts 投影只读半区用)。 */
-export function getSettingsSlots(): SettingsSlots | undefined {
- return slotsRef
-}
+ sync()
+ controller.add(ctx.slots.subscribe(SETTINGS_SECTION_SLOT as never, sync))
+ controller.add(ctx.slots.subscribe(SETTINGS_ONBOARDING_SLOT as never, sync))
+ controller.add(ctx.locale.subscribe(sync))
+})
diff --git a/packages/dsh-tauri-ui/src/client/register/settings.ts b/packages/dsh-tauri-ui/src/client/register/settings.ts
new file mode 100644
index 00000000..d4ce8fe0
--- /dev/null
+++ b/packages/dsh-tauri-ui/src/client/register/settings.ts
@@ -0,0 +1,36 @@
+import type { ClientContext } from 'dsh-tauri/client'
+import { SlotOutlet } from '@deepseek-ai/dsh-client-ui-renderer'
+import { defineRegister } from 'dsh-tauri/client'
+import { SettingsSidebar } from '../components/sidebar'
+import { SettingsTrigger } from '../components/trigger'
+import {
+ SETTINGS_REGISTRANT,
+ SETTINGS_SHELL_OVERLAY_SLOT,
+ SETTINGS_SIDEBAR_ID,
+ SETTINGS_SIDEBAR_SLOT,
+ SETTINGS_TRIGGER_PRIORITY,
+} from '../constants'
+
+export const registerSettings = defineRegister<ClientContext>((controller, ctx) => {
+ if (typeof SlotOutlet !== 'function') {
+ console.warn(
+ '[dsh-tauri-ui] <SlotOutlet> unavailable (renderer patch missing) — settings sidebar disabled, official dialog stays.',
+ )
+ return
+ }
+
+ controller.add(
+ ctx.slots.inject(SETTINGS_SHELL_OVERLAY_SLOT, () =>
+ ctx.slots.register(
+ { name: SETTINGS_SHELL_OVERLAY_SLOT, id: SETTINGS_SIDEBAR_ID, registrant: SETTINGS_REGISTRANT, inject: () => ({}) } as never,
+ SettingsSidebar as never,
+ )),
+ )
+ controller.add(
+ ctx.slots.inject(SETTINGS_SIDEBAR_SLOT as never, () =>
+ ctx.slots.register(
+ { name: SETTINGS_SIDEBAR_SLOT, priority: SETTINGS_TRIGGER_PRIORITY, registrant: SETTINGS_REGISTRANT } as never,
+ SettingsTrigger,
+ )),
+ )
+})
diff --git a/packages/dsh-tauri-ui/src/client/register/sidebar.ts b/packages/dsh-tauri-ui/src/client/register/sidebar.ts
deleted file mode 100644
index 5eabeb6f..00000000
--- a/packages/dsh-tauri-ui/src/client/register/sidebar.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-import type { ClientContext } from 'dsh-tauri/client'
-import { defineRegister } from 'dsh-tauri/client'
-import { SettingsSidebar } from '../components/sidebar'
-import {
- SETTINGS_REGISTRANT,
- SETTINGS_SHELL_OVERLAY_SLOT,
- SETTINGS_SIDEBAR_ID,
-} from '../constants'
-
-/**
- * register/sidebar.ts — shell.overlay 设置侧边栏条目注册(defineRegister)。
- *
- * shell.overlay 由 ui-layout 的 AppFrame 声明;alpha 要求注册进入前该槽已
- * 由父条目 children 表声明,故用 inject 等其声明 live 后再注册。inject 的
- * 撤销句柄交给 controller:插件卸载时随 effect 一并撤销(与旧 ctx.effect 同语义)。
- */
-export const registerSettingsSidebar = defineRegister<ClientContext>((controller, ctx) => {
- controller.add(
- ctx.slots.inject(SETTINGS_SHELL_OVERLAY_SLOT, () =>
- ctx.slots.register(
- { name: SETTINGS_SHELL_OVERLAY_SLOT, id: SETTINGS_SIDEBAR_ID, registrant: SETTINGS_REGISTRANT, inject: () => ({}) } as never,
- SettingsSidebar as never,
- )),
- )
-})
diff --git a/packages/dsh-tauri-ui/src/client/register/styles.ts b/packages/dsh-tauri-ui/src/client/register/styles.ts
new file mode 100644
index 00000000..80be637e
--- /dev/null
+++ b/packages/dsh-tauri-ui/src/client/register/styles.ts
@@ -0,0 +1,11 @@
+import type { ClientContext } from 'dsh-tauri/client'
+import { defineRegister } from 'dsh-tauri/client'
+import { GLOBAL_STYLE_ID, TURN_NAVIGATION_STYLE_ID } from '../constants'
+import globalStyle from '../styles/global.cssr'
+import turnNavigationStyle from '../styles/index.cssr'
+import { mountStyle } from '../utils/style'
+
+export const registerStyles = defineRegister<ClientContext>((controller) => {
+ controller.add(mountStyle(globalStyle, GLOBAL_STYLE_ID))
+ controller.add(mountStyle(turnNavigationStyle, TURN_NAVIGATION_STYLE_ID))
+})
diff --git a/packages/dsh-tauri-ui/src/client/register/trigger.ts b/packages/dsh-tauri-ui/src/client/register/trigger.ts
deleted file mode 100644
index 33b57cfb..00000000
--- a/packages/dsh-tauri-ui/src/client/register/trigger.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-import type { ClientContext } from 'dsh-tauri/client'
-import { defineRegister } from 'dsh-tauri/client'
-import { SettingsTrigger } from '../components/trigger'
-import {
- SETTINGS_REGISTRANT,
- SETTINGS_SIDEBAR_SLOT,
- SETTINGS_TRIGGER_PRIORITY,
-} from '../constants'
-
-/**
- * register/trigger.ts — sidebar.settings 触发条目注册(priority -1 shadow 官方)。
- *
- * 'sidebar.settings' 不属于本插件类型图的 SlotMap 键(声明权在 ui-sidebar,
- * 类型未提升到根 node_modules),此处对 options 显式 cast 以通过 K 收窄;
- * 组件 props 仍由本地 SettingsTriggerProps 提供类型保证。
- * inject 的撤销句柄交给 controller:插件卸载时随 effect 一并撤销。
- */
-export const registerSettingsTrigger = defineRegister<ClientContext>((controller, ctx) => {
- controller.add(
- ctx.slots.inject(SETTINGS_SIDEBAR_SLOT as never, () =>
- ctx.slots.register(
- { name: SETTINGS_SIDEBAR_SLOT, priority: SETTINGS_TRIGGER_PRIORITY, registrant: SETTINGS_REGISTRANT } as never,
- SettingsTrigger,
- )),
- )
-})
diff --git a/packages/dsh-tauri-ui/src/client/service/sections.ts b/packages/dsh-tauri-ui/src/client/service/sections.ts
new file mode 100644
index 00000000..5cca1950
--- /dev/null
+++ b/packages/dsh-tauri-ui/src/client/service/sections.ts
@@ -0,0 +1,38 @@
+import type { SlotRegistry } from 'dsh-tauri/client'
+import type { SettingsRow } from '../types/sections'
+import { isEqual, orderBy } from 'dsh-tauri/client'
+import { SETTINGS_ONBOARDING_SLOT, SETTINGS_SECTION_SLOT } from '../constants'
+import { sections } from '../store/modules/sections'
+
+export async function loadSections(slots: SlotRegistry): Promise<SettingsRow[]> {
+ const rows = projectRows(slots, SETTINGS_SECTION_SLOT)
+ if (!isEqual(sections.rows, rows))
+ sections.setRows(rows)
+ return rows
+}
+
+export async function loadOnboardingSteps(slots: SlotRegistry): Promise<SettingsRow[]> {
+ const rows = projectRows(slots, SETTINGS_ONBOARDING_SLOT)
+ if (!isEqual(sections.onboarding, rows))
+ sections.setOnboarding(rows)
+ return rows
+}
+
+function projectRows(slots: SlotRegistry, slotKey: string): SettingsRow[] {
+ const rows = slots
+ .entries(slotKey as never)
+ .map(entry => ({
+ id: entry.options.id ?? '',
+ order: entry.options.order ?? 0,
+ label: resolveLabel(entry.options.label),
+ }))
+ .filter(row => row.id !== '')
+
+ return orderBy(rows, 'order')
+}
+
+function resolveLabel(label: unknown): string {
+ if (typeof label === 'function')
+ return String((label as () => unknown)())
+ return typeof label === 'string' ? label : ''
+}
diff --git a/packages/dsh-tauri-ui/src/client/store/index.ts b/packages/dsh-tauri-ui/src/client/store/index.ts
index 5911d717..b4052c07 100644
--- a/packages/dsh-tauri-ui/src/client/store/index.ts
+++ b/packages/dsh-tauri-ui/src/client/store/index.ts
@@ -1,59 +1,7 @@
-import type { SettingsUiState } from '../types'
-import { useStore } from 'dsh-tauri/client'
-import { RAIL_WIDTH_MAX, RAIL_WIDTH_MIN } from '../constants'
-import { locale } from './modules/locale'
+import { sections } from './modules/sections'
import { settings } from './modules/settings'
-import { slots } from './modules/slots'
-export { RAIL_WIDTH_DEFAULT } from '../constants'
-export type { SettingsUiState } from '../types'
-
-/**
- * store/index.ts — dsh-tauri-ui 客户端共享状态的统一出口(valtio-define 域存储聚合)。
- *
- * 每个域一份 `modules/<domain>.ts`(state 只放数据、写入走 actions),本文件只做
- * 聚合与旧调用点兼容:触发器/侧边栏/拖拽 hooks 继续用下面这些薄包装函数名,
- * 组件内订阅统一走 `useStore(store.<domain>)`。
- */
export const store = {
- locale,
+ sections,
settings,
- slots,
-}
-
-/**
- * 钳制到左栏合约区间(镜像官方 clampWidth 语义)。
- */
-export function clampRailWidth(px: number): number {
- return Math.min(RAIL_WIDTH_MAX, Math.max(RAIL_WIDTH_MIN, px))
-}
-
-/** 打开侧边栏;可选直接跳到一个设置分区(onboarding 的 openSection 用)。 */
-export function openSettings(sectionId?: string): void {
- store.settings.openAt(sectionId)
-}
-
-/** 关闭侧边栏并复位视图状态(与官方 close 的复位语义一致;宽度也即忘)。 */
-export function closeSettings(): void {
- store.settings.close()
-}
-
-/** 切换左栏当前分区。 */
-export function selectSection(id: string): void {
- store.settings.select(id)
-}
-
-/** 拖拽中实时写入左栏宽度(调用方已按合约钳制)。 */
-export function setRailWidth(px: number): void {
- store.settings.setRailWidth(px)
-}
-
-/**
- * 组件内订阅共享 UI 状态。
- *
- * `sync: true`:搜索框是受控输入,valtio 默认的批量通知可能丢光标位置——
- * 这里保持旧 uSES 的同步语义。
- */
-export function useSettingsUi(): SettingsUiState {
- return useStore(store.settings, { sync: true })
}
diff --git a/packages/dsh-tauri-ui/src/client/store/modules/locale.ts b/packages/dsh-tauri-ui/src/client/store/modules/locale.ts
deleted file mode 100644
index 9d7d1b04..00000000
--- a/packages/dsh-tauri-ui/src/client/store/modules/locale.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-import { defineStore } from 'dsh-tauri/client'
-
-/**
- * store/modules/locale.ts — 活跃语言变更的 revision 推进器(valtio-define 域存储)。
- *
- * locale 服务是外部事件源:apply 时(registerSettingsLocale)订阅它,变更到达即
- * bump();组件经 useStore(store.locale) 订阅 rev,前进即重渲染并按当前 locale
- * 重读本地字典。这样组件侧不需要自造 uSES 订阅器。
- */
-export const locale = defineStore({
- state: () => ({ rev: 0 }),
- actions: {
- /** 推进 revision(订阅方随之重渲染)。 */
- bump() {
- this.rev++
- },
- },
-})
diff --git a/packages/dsh-tauri-ui/src/client/store/modules/sections.ts b/packages/dsh-tauri-ui/src/client/store/modules/sections.ts
new file mode 100644
index 00000000..fa6d578d
--- /dev/null
+++ b/packages/dsh-tauri-ui/src/client/store/modules/sections.ts
@@ -0,0 +1,20 @@
+import type { SettingsRow } from '../../types/sections'
+import type { SettingsSectionsState } from './sections.types'
+import { defineStore } from 'dsh-tauri/client'
+
+const NO_ROWS: SettingsRow[] = []
+
+export const sections = defineStore({
+ state: (): SettingsSectionsState => ({
+ rows: NO_ROWS,
+ onboarding: NO_ROWS,
+ }),
+ actions: {
+ setRows(rows: SettingsRow[]) {
+ this.rows = rows
+ },
+ setOnboarding(rows: SettingsRow[]) {
+ this.onboarding = rows
+ },
+ },
+})
diff --git a/packages/dsh-tauri-ui/src/client/store/modules/sections.types.ts b/packages/dsh-tauri-ui/src/client/store/modules/sections.types.ts
new file mode 100644
index 00000000..dae9b1df
--- /dev/null
+++ b/packages/dsh-tauri-ui/src/client/store/modules/sections.types.ts
@@ -0,0 +1,6 @@
+import type { SettingsRow } from '../../types/sections'
+
+export interface SettingsSectionsState {
+ rows: SettingsRow[]
+ onboarding: SettingsRow[]
+}
diff --git a/packages/dsh-tauri-ui/src/client/store/modules/settings.ts b/packages/dsh-tauri-ui/src/client/store/modules/settings.ts
index 4fed3610..59bb7100 100644
--- a/packages/dsh-tauri-ui/src/client/store/modules/settings.ts
+++ b/packages/dsh-tauri-ui/src/client/store/modules/settings.ts
@@ -1,19 +1,6 @@
-import type { SettingsUiState } from '../../types'
+import type { SettingsUiState } from './settings.types'
import { defineStore } from 'dsh-tauri/client'
-/**
- * store/modules/settings.ts — 设置侧边栏的共享 UI 状态(valtio-define 域存储)。
- *
- * 触发器(sidebar.settings 槽内)与侧边栏(shell.overlay 槽内)是同一插件
- * 的两个独立注册条目,凭一个模块级 store 共享开关/当前分区/搜索词:
- * - 触发器把 open 置 true(并可选跳到某分区);
- * - 侧边栏订阅 open/activeId/query 渲染,Esc 或“返回应用”置 false。
- *
- * state 只放数据,写入一律走 actions(`this` 即 state 代理)。
- * 左栏宽度合约与官方 sidebar 面板一致:
- * defineStore init sidebar:280,setSidebar clamp clampWidth(px, 264, 420),关闭即忘
- * (官方“closing a panel forgets its drag width”——不持久化,重开回默认)。
- */
export const settings = defineStore({
state: (): SettingsUiState => ({
open: false,
@@ -22,28 +9,23 @@ export const settings = defineStore({
railWidth: undefined,
}),
actions: {
- /** 打开侧边栏;可选直接跳到一个设置分区(onboarding 的 openSection 用)。 */
openAt(sectionId?: string) {
this.open = true
if (sectionId !== undefined)
this.activeId = sectionId
},
- /** 关闭侧边栏并复位视图状态(与官方 close 的复位语义一致;宽度也即忘)。 */
close() {
this.open = false
this.activeId = undefined
this.query = ''
this.railWidth = undefined
},
- /** 切换左栏当前分区。 */
select(id: string) {
this.activeId = id
},
- /** 写入搜索词(侧边栏搜索框的受控值)。 */
setQuery(query: string) {
this.query = query
},
- /** 拖拽中实时写入左栏宽度(调用方已按合约钳制)。 */
setRailWidth(px: number) {
this.railWidth = px
},
diff --git a/packages/dsh-tauri-ui/src/client/store/modules/settings.types.ts b/packages/dsh-tauri-ui/src/client/store/modules/settings.types.ts
new file mode 100644
index 00000000..7803625d
--- /dev/null
+++ b/packages/dsh-tauri-ui/src/client/store/modules/settings.types.ts
@@ -0,0 +1,8 @@
+export interface SettingsUiState {
+ open: boolean
+ activeId: string | undefined
+ query: string
+ railWidth: number | undefined
+}
+
+export type SettingsUiKey = 'back' | 'search' | 'settings' | 'noResults'
diff --git a/packages/dsh-tauri-ui/src/client/store/modules/slots.ts b/packages/dsh-tauri-ui/src/client/store/modules/slots.ts
deleted file mode 100644
index 4b67d9e2..00000000
--- a/packages/dsh-tauri-ui/src/client/store/modules/slots.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-import { defineStore } from 'dsh-tauri/client'
-import { SETTINGS_ONBOARDING_SLOT, SETTINGS_SECTION_SLOT } from '../../constants'
-
-/**
- * store/modules/slots.ts — 官方槽位注册中心投影的 revision 镜像。
- *
- * 'settings.section' / 'settings.onboarding' 的注册/注销由官方 slots 注册中心
- * 通知(register/sections.ts 在 apply 期订阅,注册中心引用的所有权与清理都留在
- * 那里);本 store 按槽 key 记 revision,投影 hooks 经 useStore 读取对应 key,
- * 变更即重算导航行。两个被投影的 key 预置为 0,读取路径不存在“缺失键”分支。
- */
-export const slots = defineStore({
- state: (): { revisions: Record<string, number> } => ({
- revisions: {
- [SETTINGS_SECTION_SLOT]: 0,
- [SETTINGS_ONBOARDING_SLOT]: 0,
- },
- }),
- actions: {
- /** 推进某个槽 key 的 revision(注册/声明变更通知到达时调用)。 */
- bump(key: string) {
- this.revisions[key] = (this.revisions[key] ?? 0) + 1
- },
- },
-})
diff --git a/packages/dsh-tauri-ui/src/client/styles/global.cssr.ts b/packages/dsh-tauri-ui/src/client/styles/global.cssr.ts
index a64c3d2b..9da19275 100644
--- a/packages/dsh-tauri-ui/src/client/styles/global.cssr.ts
+++ b/packages/dsh-tauri-ui/src/client/styles/global.cssr.ts
@@ -2,14 +2,6 @@ import { cssr } from '../utils/cssr'
const { c } = cssr
-/**
- * 全局样式(挂载于 `apply`:`mountStyle(globalStyle, 'dsh-tauri-ui-global-styles')`)。
- *
- * 其中「右侧面板开关簇」一节原先由桌面端注入脚本(Rust `IFRAME_STYLES_JS`)承担,
- * 现统一收敛到本插件:页面里「按 aria-label 隐藏左侧收起按钮」的规则会误伤右侧
- * 面板开关,这里只把面板开关簇恢复回来。`.nArs4W_toggleCluster` 是旧版 dsh 的生成
- * 类名,保留兼容(优先使用插件的稳定标记 `data-dsh-toggle-cluster`)。
- */
export default c([
c('[data-slot="sidebar.right.tab.guide"]', [
c('[class$="guide"]', {
@@ -29,7 +21,6 @@ export default c([
}),
c('[class$="entryTitle"]', {
fontSize: '14px',
-
}),
c('[class$="entryDescription"]', {
fontSize: '12px',
@@ -45,4 +36,7 @@ export default c([
borderRadius: '8px !important',
flexShrink: 0,
}),
+ c('[class$="_panelRow"], [class*="_panelRow "]', {
+ color: 'var(--dsw-alias-label-primary) !important',
+ }),
])
diff --git a/packages/dsh-tauri-ui/src/client/styles/index.cssr.ts b/packages/dsh-tauri-ui/src/client/styles/index.cssr.ts
index b6470550..76bb04fd 100644
--- a/packages/dsh-tauri-ui/src/client/styles/index.cssr.ts
+++ b/packages/dsh-tauri-ui/src/client/styles/index.cssr.ts
@@ -3,13 +3,6 @@ import { cssr } from '../utils/cssr'
const { c } = cssr
-/**
- * 轮次导航窄栏常驻(纯样式,无组件面)。
- * The core rail is inside the conversation column. That column is clipped,
- * and the core height can resolve to 0 when the available composer band is
- * tight. Only apply the viewport anchor while the shell reports a collapsed
- * sidebar; the core's inner scroller and mark geometry remain untouched.
- */
export default c(TURN_NAVIGATION_NARROW_SELECTOR, {
position: 'fixed',
top: 'max(32px, calc((100dvh - var(--dsh-composer-height, 152px)) / 2))',
diff --git a/packages/dsh-tauri-ui/src/client/types/index.ts b/packages/dsh-tauri-ui/src/client/types/index.ts
deleted file mode 100644
index b1a0d76d..00000000
--- a/packages/dsh-tauri-ui/src/client/types/index.ts
+++ /dev/null
@@ -1,64 +0,0 @@
-import type { SessionListState } from 'dsh-tauri/client'
-
-/** Selector hook shape shared by standard slot props. */
-export type SelectorHook<T> = <S>(sel: (state: T) => S) => S
-
-/** Props supplied to the settings trigger slot. */
-export interface SettingsTriggerProps {
- /** sidebar.settings owner: expanded sidebar state. */
- wide: boolean
- /** Framework standard hook: session list snapshot. */
- useSessions: SelectorHook<SessionListState>
- useWorkspaces?: unknown
-}
-
-/** Props supplied to the shell.overlay settings sidebar slot. */
-export interface SettingsSidebarProps {
- useSessions: SelectorHook<SessionListState>
- useWorkspaces?: unknown
-}
-
-/** Settings sidebar UI state. */
-export interface SettingsUiState {
- /** Whether the sidebar is open. */
- open: boolean
- /** Active settings section id. */
- activeId: string | undefined
- /** Search query used to filter the settings list. */
- query: string
- /** Current sidebar width in pixels, or undefined when unset. */
- railWidth: number | undefined
-}
-
-/** A settings section or onboarding step projected into a navigation row. */
-export interface SettingsRow {
- /** List slot entry id. */
- id: string
- /** Display order, defaulting to 0. */
- order: number
- /** Resolved display label. */
- label: string
-}
-
-/** Keys in the settings UI translation dictionary. */
-export type SettingsUiKey = 'back' | 'search' | 'settings' | 'noResults'
-
-/** One option displayed by the shared primitives Menu select. */
-export interface MenuSelectOption {
- id: string
- label: string
-}
-
-/** Props for the shared official-style Menu select trigger. */
-export interface MenuSelectProps {
- value: string
- options: readonly MenuSelectOption[]
- onSelect: (id: string) => void
- label: string
- /** `pill` matches LanguageRow; `default` matches regular form selectors. */
- variant?: 'pill' | 'default'
- /** Existing plugin classes can remain stable during migration. */
- triggerClassName?: string
- labelClassName?: string
- chevronClassName?: string
-}
diff --git a/packages/dsh-tauri-ui/src/client/types/sections.ts b/packages/dsh-tauri-ui/src/client/types/sections.ts
new file mode 100644
index 00000000..7419ffc4
--- /dev/null
+++ b/packages/dsh-tauri-ui/src/client/types/sections.ts
@@ -0,0 +1,5 @@
+export interface SettingsRow {
+ id: string
+ order: number
+ label: string
+}
diff --git a/packages/dsh-tauri-ui/src/client/types/selector.ts b/packages/dsh-tauri-ui/src/client/types/selector.ts
new file mode 100644
index 00000000..54adf4a8
--- /dev/null
+++ b/packages/dsh-tauri-ui/src/client/types/selector.ts
@@ -0,0 +1 @@
+export type SelectorHook<T> = <S>(sel: (state: T) => S) => S
diff --git a/packages/dsh-tauri-ui/src/client/utils/cssr.ts b/packages/dsh-tauri-ui/src/client/utils/cssr.ts
index ca38e7fd..4388f2f9 100644
--- a/packages/dsh-tauri-ui/src/client/utils/cssr.ts
+++ b/packages/dsh-tauri-ui/src/client/utils/cssr.ts
@@ -5,16 +5,6 @@ const root = CssRender()
const plugin = bem({ blockPrefix: '.dshp-' })
root.use(plugin)
-/**
- * workspace 统一 css-render 实例与 bem 助手。
- *
- * 消费方(本插件与所有内置插件)一律从 `dsh-tauri-ui/client` 获取:
- * cssr.c(...) 普通选择器
- * cssr.bem.b('block') -> .dshp-block
- * cssr.bem.e('elem') -> __elem
- * cssr.bem.m('mod') -> --mod
- * 不各自 new CssRender(),保证同一实例与 `cssr.find()` 去重。
- */
export const cssr = Object.assign(root, {
bem: {
b: plugin.cB,
diff --git a/packages/dsh-tauri-ui/src/client/utils/style.ts b/packages/dsh-tauri-ui/src/client/utils/style.ts
index 8745457d..f6f9eb52 100644
--- a/packages/dsh-tauri-ui/src/client/utils/style.ts
+++ b/packages/dsh-tauri-ui/src/client/utils/style.ts
@@ -1,16 +1,5 @@
import type { CNode } from 'css-render'
-import { useEffect, useRef } from 'react'
-/**
- * 命令式挂载 css-render 节点;返回卸载 disposer。
- *
- * 统一挂载路线:
- * - 组件:useMountStyle(cnode, id)
- * - Controller / ctx.effect:mountStyle(cnode, id)(由调用方把 disposer
- * 交给 controller.add 或 ctx.effect 返回)
- * 幂等:同一 CNode 实例多挂载只生效一次;引用计数保证最后一位持有者
- * 卸载时才真正 unmount。
- */
const mountCounts = new Map<CNode, number>()
export function mountStyle(cnode: CNode, id?: string): () => void {
@@ -32,15 +21,3 @@ export function mountStyle(cnode: CNode, id?: string): () => void {
mountCounts.set(cnode, count + 1)
return release
}
-
-/** React hook:组件挂载时自动挂载、卸载时自动卸载。 */
-export function useMountStyle(cnode: CNode, id?: string): void {
- const disposerRef = useRef<(() => void) | null>(null)
- useEffect(() => {
- disposerRef.current = mountStyle(cnode, id)
- return () => {
- disposerRef.current?.()
- disposerRef.current = null
- }
- }, [cnode, id])
-}
diff --git a/packages/dsh-tauri-ui/src/host/apply.ts b/packages/dsh-tauri-ui/src/host/apply.ts
new file mode 100644
index 00000000..355ced46
--- /dev/null
+++ b/packages/dsh-tauri-ui/src/host/apply.ts
@@ -0,0 +1 @@
+export function apply(): void {}
diff --git a/packages/dsh-tauri-ui/src/index.ts b/packages/dsh-tauri-ui/src/index.ts
index 02314b64..37395067 100644
--- a/packages/dsh-tauri-ui/src/index.ts
+++ b/packages/dsh-tauri-ui/src/index.ts
@@ -1,6 +1,5 @@
-/**
- * dsh-tauri-ui 宿主侧(node half):纯浏览器插件,无宿主行为。
- * loader 按行名导入包根时需要一个可挂载的插件入口;与官方浏览器插件
- * (如 dsh-client-ui-layout)一致,这里提供空 apply。
- */
-export function apply(): void {}
+import { PLUGIN_NAME } from './shared/constants'
+
+export { apply } from './host/apply'
+
+export const name = PLUGIN_NAME
diff --git a/packages/dsh-tauri-ui/src/shared/constants.ts b/packages/dsh-tauri-ui/src/shared/constants.ts
new file mode 100644
index 00000000..b68e9b74
--- /dev/null
+++ b/packages/dsh-tauri-ui/src/shared/constants.ts
@@ -0,0 +1 @@
+export const PLUGIN_NAME = 'dsh-tauri-ui'