Skip to content

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

refactor(plugins): migrate rightclick and panel styles to bem cssr

hairyfded649cee2c3
diff --git a/packages/dsh-tauri-panel/src/client/constants/index.ts b/packages/dsh-tauri-panel/src/client/constants/index.ts
index 5d53146d..d0ab1838 100644
--- a/packages/dsh-tauri-panel/src/client/constants/index.ts
+++ b/packages/dsh-tauri-panel/src/client/constants/index.ts
@@ -18,34 +18,34 @@ export const WORKSPACE_GROUP_SELECTOR = '[role="treeitem"][aria-expanded]'
export const SIDEBAR_KEEP_OPEN_SELECTOR = 'button[aria-label="视图选项"],button[aria-label="View options"],button[aria-label="添加工作区"],button[aria-label="Add workspace"]'
export const PANEL_CLASSES = {
- root: 'dshp-root',
- collapsed: 'dshp-collapsed',
- railIn: 'dshp-railIn',
- fading: 'dshp-fading',
- quietBars: 'dshp-quietBars',
- wide: 'dshp-wide',
- logoRow: 'dshp-logoRow',
- brand: 'dshp-brand',
- brandIdentity: 'dshp-brandIdentity',
- brandMark: 'dshp-brandMark',
- brandName: 'dshp-brandName',
- fallbackBrandName: 'dshp-fallbackBrandName',
- iconButton: 'dshp-iconButton',
- toggle: 'dshp-toggle',
- railMark: 'dshp-railMark',
- panelArea: 'dshp-panelArea',
- menuItem: 'dshp-menuItem',
- menuItemSelected: 'dshp-menuItemSelected',
- newSession: 'dshp-newSession',
- menuItemIcon: 'dshp-menuItemIcon',
- menuItemLabel: 'dshp-menuItemLabel',
- regionArea: 'dshp-regionArea',
- footArea: 'dshp-footArea',
- footerActions: 'dshp-footerActions',
- settingsArea: 'dshp-settingsArea',
- panelView: 'dshp-panelView',
- panelViewColumn: 'dshp-panelViewColumn',
- widthHandle: 'dshp-widthHandle',
+ root: 'dshp-panel',
+ collapsed: 'dshp-panel--collapsed',
+ railIn: 'dshp-panel--rail-in',
+ fading: 'dshp-panel--fading',
+ quietBars: 'dshp-panel--quiet-bars',
+ wide: 'dshp-panel--wide',
+ logoRow: 'dshp-panel__logo-row',
+ brand: 'dshp-panel__brand',
+ brandIdentity: 'dshp-panel__brand-identity',
+ brandMark: 'dshp-panel__brand-mark',
+ brandName: 'dshp-panel__brand-name',
+ fallbackBrandName: 'dshp-panel__fallback-brand-name',
+ iconButton: 'dshp-panel__icon-button',
+ toggle: 'dshp-panel__toggle',
+ railMark: 'dshp-panel__rail-mark',
+ panelArea: 'dshp-panel__panel-area',
+ menuItem: 'dshp-panel__menu-item',
+ menuItemSelected: 'dshp-panel__menu-item--selected',
+ newSession: 'dshp-panel__new-session',
+ menuItemIcon: 'dshp-panel__menu-item-icon',
+ menuItemLabel: 'dshp-panel__menu-item-label',
+ regionArea: 'dshp-panel__region-area',
+ footArea: 'dshp-panel__foot-area',
+ footerActions: 'dshp-panel__footer-actions',
+ settingsArea: 'dshp-panel__settings-area',
+ panelView: 'dshp-panel__panel-view',
+ panelViewColumn: 'dshp-panel__panel-view-column',
+ widthHandle: 'dshp-panel__width-handle',
} as const
export const PANEL_DATA_ATTRIBUTES = {
diff --git a/packages/dsh-tauri-panel/src/client/index.ts b/packages/dsh-tauri-panel/src/client/index.ts
index 0ae4ceac..88c30e4f 100644
--- a/packages/dsh-tauri-panel/src/client/index.ts
+++ b/packages/dsh-tauri-panel/src/client/index.ts
@@ -17,10 +17,12 @@ import type {} from '@deepseek-ai/dsh-client-ui-layout/client'
*/
import type { ClientContext } from 'dsh-tauri/client'
import { SlotOutlet } from '@deepseek-ai/dsh-client-ui-renderer'
+import { mountStyle } from 'dsh-tauri-ui/client'
+import { PANEL_STYLE_ID } from './constants'
import { installPanelLocale } from './locales'
import { installPanelService } from './register/panel-service'
import { installSidebarRoot } from './register/sidebar'
-import { mountPanelStyles } from './styles'
+import panelStyle from './styles/panel.cssr'
export { PANEL_PROTOCOL_SERVICE } from './constants'
export type { PanelActionItemProps, PanelContentSpec, SidebarRootProps } from './types'
@@ -44,7 +46,7 @@ export const inject = ['slots', 'layout', 'locale']
*/
export function apply(ctx: ClientContext): void {
ctx.effect(
- () => mountPanelStyles(),
+ () => mountStyle(panelStyle, PANEL_STYLE_ID),
'dsh-tauri-panel: styles',
)
installPanelLocale(ctx)
diff --git a/packages/dsh-tauri-panel/src/client/styles/index.ts b/packages/dsh-tauri-panel/src/client/styles/index.ts
deleted file mode 100644
index e0cb26ff..00000000
--- a/packages/dsh-tauri-panel/src/client/styles/index.ts
+++ /dev/null
@@ -1,171 +0,0 @@
-/** CSS generated as css-render nodes so every declaration remains structured. */
-import { CssRender } from 'dsh-tauri/client'
-import { PANEL_DATA_ATTRIBUTES, PANEL_STYLE_ID } from '../constants'
-
-const cssr = CssRender()
-const { c } = cssr
-
-const panelStyle = c([
- c('.dshp-sectionHeader', {
- boxSizing: 'border-box',
- height: '36px',
- color: 'var(--dsw-alias-label-tertiary)',
- borderRadius: '12px',
- flex: 'none',
- alignItems: 'center',
- gap: '4px',
- marginBottom: '4px',
- paddingLeft: '8px',
- display: 'flex',
- overflow: 'hidden',
- }),
- c('.dshp-sectionHeaderTitle', {
- whiteSpace: 'nowrap',
- opacity: 1,
- visibility: 'visible',
- minWidth: 0,
- maxWidth: '45%',
- transition: 'max-width .18s var(--ds-ease-in-out), margin-right .18s var(--ds-ease-in-out), opacity .12s var(--ds-ease-in-out), transform .18s var(--ds-ease-in-out), visibility 0s linear',
- flex: 'none',
- lineHeight: '20px',
- overflow: 'hidden',
- }),
- c('.dshp-collapsed .dshp-sectionHeaderTitle', { opacity: 0, visibility: 'hidden', maxWidth: 0 }),
- c('.dshp-root', {
- '--dshp-padding': '12px',
- 'height': '100%',
- 'padding': '6px var(--dshp-padding)',
- 'boxSizing': 'border-box',
- 'background': 'var(--dsw-specific-sidebar-fill)',
- 'color': 'var(--dsw-alias-label-primary)',
- '--dsh-scrollbar-thumb': 'var(--dsw-alias-scrollbar-bg-l2)',
- '--dsh-scrollbar-thumb-hover': 'var(--dsw-alias-scrollbar-hover-l2)',
- 'flexDirection': 'column',
- 'fontSize': '14px',
- 'display': 'flex',
- '--dsh-sidebar-inline-padding': 'var(--dshp-padding)',
- }),
- c('.dshp-root.dshp-collapsed', { padding: '18px 10px 6px' }),
- c('.dshp-root.dshp-wide', { width: 'var(--dshp-width)' }),
- c('.dshp-root.dshp-quietBars', { '--dsh-scrollbar-thumb': 'transparent', '--dsh-scrollbar-thumb-hover': 'transparent' }),
- c('.dshp-fading>*', { opacity: 0, transition: 'opacity .15s var(--ds-ease-in-out)' }),
- c('.dshp-logoRow', { boxSizing: 'border-box', flex: 'none', justifyContent: 'flex-end', alignItems: 'center', gap: '8px', height: '60px', marginBottom: '4px', padding: '4px 0 4px 4px', display: 'flex', overflow: 'hidden' }),
- c('.dshp-collapsed .dshp-logoRow', { justifyContent: 'flex-start', height: '40px', marginBottom: '4px', padding: 0 }),
- c('.dshp-brand', { minWidth: 0, color: 'inherit', cursor: 'pointer', background: 'transparent', border: 'none', flex: 1, alignItems: 'center', padding: 0, display: 'inline-flex', overflow: 'hidden' }),
- c('.dshp-brandIdentity', { alignItems: 'center', gap: '8px', minWidth: 0, height: '24px', display: 'inline-flex' }),
- c('.dshp-brandMark', { flex: 'none', justifyContent: 'center', alignItems: 'center', display: 'inline-flex' }),
- c('.dshp-brandName', { letterSpacing: '.04em', alignItems: 'center', gap: '6px', minWidth: 0, height: '24px', fontSize: '18px', fontWeight: 600, lineHeight: '24px', display: 'inline-flex' }),
- c('.dshp-fallbackBrandName', { letterSpacing: 0, whiteSpace: 'nowrap', fontSize: '17px' }),
- c('.dshp-iconButton', { cursor: 'pointer', width: '28px', height: '28px', color: 'var(--dsw-alias-label-secondary)', background: 'transparent', border: 'none', borderRadius: '50%', flex: 'none', justifyContent: 'center', alignItems: 'center', padding: 0, display: 'inline-flex' }, [c('&:hover', { background: 'var(--dsw-alias-interactive-bg-hover)' })]),
- c('.dshp-collapsed .dshp-iconButton', { width: '36px', height: '36px', color: 'var(--dsw-alias-label-primary)' }),
- c('.dshp-railMark', { justifyContent: 'center', alignItems: 'center', display: 'inline-flex' }),
- c('.dshp-panelArea', { flex: 'none', flexDirection: 'column', alignItems: 'stretch', gap: '2px', margin: 0, display: 'flex', marginRight: 'var(--dsh-session-list-scrollbar-offset)', paddingLeft: '4px', paddingRight: 'calc(var(--dsh-session-list-edge-inset) - var(--dsh-session-list-scrollbar-width) - var(--dsh-session-list-scrollbar-offset))' }),
- c('.dshp-collapsed .dshp-panelArea', { alignItems: 'center', gap: '4px' }),
- c('.dshp-menuItem', {
- boxSizing: 'border-box',
- appearance: 'none',
- cursor: 'pointer',
- userSelect: 'none',
- width: '100%',
- minWidth: 0,
- height: '34px',
- flex: 'none',
- display: 'flex',
- alignItems: 'center',
- gap: '6px',
- padding: '0 8px',
- border: 0,
- borderRadius: '8px',
- overflow: 'hidden',
- background: 'transparent',
- color: 'var(--dsw-alias-label-primary)',
- fontFamily: 'inherit',
- fontSize: '14px',
- fontWeight: 400,
- lineHeight: '22px',
- textAlign: 'left',
- whiteSpace: 'nowrap',
- transition: 'background-color .12s var(--ds-ease-in-out), color .12s var(--ds-ease-in-out)',
- }, [c('&:hover', { background: 'var(--dsw-alias-interactive-bg-hover)' }), c('&:focus-visible', { outline: '2px solid var(--dsw-alias-border-focus)', outlineOffset: '-2px' })]),
- c('.dshp-menuItemSelected,.dshp-menuItemSelected:hover', { background: 'var(--dsw-alias-interactive-bg-hover)' }),
- c('.dshp-newSession', { width: '100%', height: '38px', margin: '0 0 4px', padding: '8px 16px', border: '1px solid var(--dsw-alias-border-l2)', borderRadius: '12px', background: 'var(--dsw-alias-button-elevated-fill)', justifyContent: 'center', alignItems: 'center', gap: '6px', fontWeight: 500 }, [c('&:hover', { background: 'var(--dsw-alias-button-floating-hover)' })]),
- c('.dshp-menuItemIcon', {
- boxSizing: 'border-box',
- flex: 'none',
- justifyContent: 'center',
- alignItems: 'center',
- display: 'inline-flex',
- fontSize: '16px',
- }),
- c('.dshp-menuItemLabel', { minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', margin: '0 6px 0 0' }),
- c('.dshp-collapsed .dshp-menuItem', { justifyContent: 'center', alignSelf: 'flex-start', width: '36px', minWidth: '36px', height: '36px', padding: 0, gap: 0, borderRadius: '12px' }),
- c('.dshp-collapsed .dshp-menuItemLabel', { display: 'none' }),
- c('.dshp-collapsed .dshp-panelArea', { marginBottom: '12px', paddingLeft: 0 }),
- c('.dshp-collapsed .dshp-menuItemIcon', {
- fontSize: '18px',
- color: 'var(--dsw-alias-label-primary)',
- }),
- c('.dshp-collapsed .dshp-newSession', { borderColor: 'transparent', justifyContent: 'center', width: '36px', height: '36px', margin: 0, padding: 0, gap: 0 }),
- c('.dshp-regionArea', { minHeight: 0, marginRight: 'calc(-1 * var(--dshp-padding))', flexDirection: 'column', flex: 1, padding: '0 4px', display: 'flex', overflow: 'hidden' }),
- c('.dshp-collapsed .dshp-regionArea', { marginLeft: 0, marginRight: 0, padding: 0 }),
- c('.dshp-footArea', { flexDirection: 'column', flex: 'none', display: 'flex' }),
- c('.dshp-settingsArea,.dshp-footerActions', { flex: 'none', width: '100%', minWidth: 0 }),
- c('.dshp-footerActions', { display: 'flex' }),
- c('.dshp-collapsed .dshp-footArea', { alignItems: 'center' }),
- c('.dshp-collapsed .dshp-settingsArea,.dshp-collapsed .dshp-footerActions', { justifyContent: 'center', width: 'auto', display: 'flex' }),
- c('.dshp-panelView', {
- 'height': '100%',
- 'boxSizing': 'border-box',
- 'minWidth': 0,
- 'overflowY': 'auto',
- 'scrollbarGutter': 'stable',
- 'position': 'relative',
- // 内容宽度派生(自给自足镜像 alpha):有拖拽偏好用偏好,否则自适应
- // clamp(680px, col*0.64, 920px);列宽与偏好由 width 控制器发布。
- '--dsh-chat-content-width': 'var(--dsh-chat-user-width, clamp(680px, calc(var(--dsh-conversation-column-width, 0px) * .64), 920px))',
- }),
- c('.dshp-panelViewColumn', { maxWidth: 'var(--dsh-chat-content-width,780px)', minHeight: '100%', width: '100%', margin: '0 auto', flexDirection: 'column', gap: '16px', display: 'flex' }),
- // 内容宽度拖拽手柄(镜像 alpha WidthHandle):绝对定位在内容列两侧 24px 外,
- // 宽度自适应(列宽 − 内容宽的一半再减两个 24px inset,最多 40px);
- // hover/拖动时发光条跟随指针 Y(--dsh-width-handle-pointer-y)。
- c('.dshp-widthHandle', {
- zIndex: 8,
- width: 'min(40px, calc((100% - var(--dsh-chat-content-width)) / 2 - 24px - 24px))',
- cursor: 'col-resize',
- position: 'absolute',
- top: 0,
- bottom: 0,
- }),
- c('.dshp-widthHandle[data-side="left"]', { right: 'calc(50% + var(--dsh-chat-content-width) / 2 + 24px)' }),
- c('.dshp-widthHandle[data-side="right"]', { left: 'calc(50% + var(--dsh-chat-content-width) / 2 + 24px)' }),
- c('.dshp-widthHandle:after', {
- content: '""',
- background: 'linear-gradient(to bottom, transparent calc(var(--dsh-width-handle-pointer-y, 50%) - 52px), var(--dsw-alias-scrollbar-hover-l1) calc(var(--dsh-width-handle-pointer-y, 50%) - 12px), var(--dsw-alias-scrollbar-hover-l1) calc(var(--dsh-width-handle-pointer-y, 50%) + 12px), transparent calc(var(--dsh-width-handle-pointer-y, 50%) + 52px))',
- opacity: 0,
- pointerEvents: 'none',
- borderRadius: '3px',
- width: '3px',
- position: 'absolute',
- top: 0,
- bottom: 0,
- }),
- c('.dshp-widthHandle[data-side="left"]:after', { right: '16px' }),
- c('.dshp-widthHandle[data-side="right"]:after', { left: '16px' }),
- c('.dshp-widthHandle:hover:after,.dshp-widthHandle[data-dragging]:after', { opacity: 1 }),
- // 面板激活期间,侧栏工作区单项撤销 hover 底色(仅非选中行;选中行保留
- // 自己的选中态,避免点按目标不可辨)。语义选择器按官方 aria 状态匹配,
- // 不依赖 css-module hash。
- c(`[${PANEL_DATA_ATTRIBUTES.active}] [role="treeitem"]:not([aria-selected="true"]):hover`, { background: 'transparent' }),
- c('@keyframes dshp-rail-in', [c('from', { opacity: 0, transform: 'translate(49px)' })]),
- c('@keyframes dshp-rail-fade-in', [c('from', { opacity: 0 })]),
- c('@media (prefers-reduced-motion: reduce)', [c('.dshp-fading>*', { transition: 'none' }), c('.dshp-railIn .dshp-iconButton,.dshp-railIn .dshp-menuItem,.dshp-railIn .dshp-footArea,.dshp-railIn .dshp-regionArea', { animation: 'none' })]),
-])
-
-export function mountPanelStyles(): () => void {
- if (typeof document === 'undefined')
- return () => {}
- if (cssr.find(PANEL_STYLE_ID) !== null)
- return () => {}
- panelStyle.mount({ id: PANEL_STYLE_ID, head: true })
- return () => panelStyle.unmount({ id: PANEL_STYLE_ID })
-}
diff --git a/packages/dsh-tauri-panel/src/client/styles/panel.cssr.ts b/packages/dsh-tauri-panel/src/client/styles/panel.cssr.ts
new file mode 100644
index 00000000..402f1e48
--- /dev/null
+++ b/packages/dsh-tauri-panel/src/client/styles/panel.cssr.ts
@@ -0,0 +1,311 @@
+import { cssr } from 'dsh-tauri-ui/client'
+
+const { c, bem: { b, e, m } } = cssr
+
+/** 侧栏整槽克隆(sidebar root):logo 行 + 面板区 + 官方子槽透传。 */
+export default b('panel', {
+ '--dshp-padding': '12px',
+ 'height': '100%',
+ 'padding': '6px var(--dshp-padding)',
+ 'boxSizing': 'border-box',
+ 'background': 'var(--dsw-specific-sidebar-fill)',
+ 'color': 'var(--dsw-alias-label-primary)',
+ '--dsh-scrollbar-thumb': 'var(--dsw-alias-scrollbar-bg-l2)',
+ '--dsh-scrollbar-thumb-hover': 'var(--dsw-alias-scrollbar-hover-l2)',
+ 'flexDirection': 'column',
+ 'fontSize': '14px',
+ 'display': 'flex',
+ '--dsh-sidebar-inline-padding': 'var(--dshp-padding)',
+}, [
+ e('section-header', {
+ boxSizing: 'border-box',
+ height: '36px',
+ color: 'var(--dsw-alias-label-tertiary)',
+ borderRadius: '12px',
+ flex: 'none',
+ alignItems: 'center',
+ gap: '4px',
+ marginBottom: '4px',
+ paddingLeft: '8px',
+ display: 'flex',
+ overflow: 'hidden',
+ }),
+ e('section-header-title', {
+ whiteSpace: 'nowrap',
+ opacity: 1,
+ visibility: 'visible',
+ minWidth: 0,
+ maxWidth: '45%',
+ transition: 'max-width .18s var(--ds-ease-in-out), margin-right .18s var(--ds-ease-in-out), opacity .12s var(--ds-ease-in-out), transform .18s var(--ds-ease-in-out), visibility 0s linear',
+ flex: 'none',
+ lineHeight: '20px',
+ overflow: 'hidden',
+ }),
+ e('logo-row', {
+ boxSizing: 'border-box',
+ flex: 'none',
+ justifyContent: 'flex-end',
+ alignItems: 'center',
+ gap: '8px',
+ height: '60px',
+ marginBottom: '4px',
+ padding: '4px 0 4px 4px',
+ display: 'flex',
+ overflow: 'hidden',
+ }),
+ e('brand', {
+ minWidth: 0,
+ color: 'inherit',
+ cursor: 'pointer',
+ background: 'transparent',
+ border: 'none',
+ flex: 1,
+ alignItems: 'center',
+ padding: 0,
+ display: 'inline-flex',
+ overflow: 'hidden',
+ }),
+ e('brand-identity', {
+ alignItems: 'center',
+ gap: '8px',
+ minWidth: 0,
+ height: '24px',
+ display: 'inline-flex',
+ }),
+ e('brand-mark', {
+ flex: 'none',
+ justifyContent: 'center',
+ alignItems: 'center',
+ display: 'inline-flex',
+ }),
+ e('brand-name', {
+ letterSpacing: '.04em',
+ alignItems: 'center',
+ gap: '6px',
+ minWidth: 0,
+ height: '24px',
+ fontSize: '18px',
+ fontWeight: 600,
+ lineHeight: '24px',
+ display: 'inline-flex',
+ }),
+ e('fallback-brand-name', {
+ letterSpacing: 0,
+ whiteSpace: 'nowrap',
+ fontSize: '17px',
+ }),
+ e('icon-button', {
+ cursor: 'pointer',
+ width: '28px',
+ height: '28px',
+ color: 'var(--dsw-alias-label-secondary)',
+ background: 'transparent',
+ border: 'none',
+ borderRadius: '50%',
+ flex: 'none',
+ justifyContent: 'center',
+ alignItems: 'center',
+ padding: 0,
+ display: 'inline-flex',
+ }, [
+ c('&:hover', { background: 'var(--dsw-alias-interactive-bg-hover)' }),
+ ]),
+ e('rail-mark', {
+ justifyContent: 'center',
+ alignItems: 'center',
+ display: 'inline-flex',
+ }),
+ e('panel-area', {
+ flex: 'none',
+ flexDirection: 'column',
+ alignItems: 'stretch',
+ gap: '2px',
+ margin: 0,
+ display: 'flex',
+ marginRight: 'var(--dsh-session-list-scrollbar-offset)',
+ paddingLeft: '4px',
+ paddingRight: 'calc(var(--dsh-session-list-edge-inset) - var(--dsh-session-list-scrollbar-width) - var(--dsh-session-list-scrollbar-offset))',
+ }),
+ e('menu-item', {
+ boxSizing: 'border-box',
+ appearance: 'none',
+ cursor: 'pointer',
+ userSelect: 'none',
+ width: '100%',
+ minWidth: 0,
+ height: '34px',
+ flex: 'none',
+ display: 'flex',
+ alignItems: 'center',
+ gap: '6px',
+ padding: '0 8px',
+ border: 0,
+ borderRadius: '8px',
+ overflow: 'hidden',
+ background: 'transparent',
+ color: 'var(--dsw-alias-label-primary)',
+ fontFamily: 'inherit',
+ fontSize: '14px',
+ fontWeight: 400,
+ lineHeight: '22px',
+ textAlign: 'left',
+ whiteSpace: 'nowrap',
+ transition: 'background-color .12s var(--ds-ease-in-out), color .12s var(--ds-ease-in-out)',
+ }, [
+ c('&:hover', { background: 'var(--dsw-alias-interactive-bg-hover)' }),
+ c('&:focus-visible', { outline: '2px solid var(--dsw-alias-border-focus)', outlineOffset: '-2px' }),
+ m('selected', { background: 'var(--dsw-alias-interactive-bg-hover)' }),
+ ]),
+ e('new-session', {
+ width: '100%',
+ height: '38px',
+ margin: '0 0 4px',
+ padding: '8px 16px',
+ border: '1px solid var(--dsw-alias-border-l2)',
+ borderRadius: '12px',
+ background: 'var(--dsw-alias-button-elevated-fill)',
+ justifyContent: 'center',
+ alignItems: 'center',
+ gap: '6px',
+ fontWeight: 500,
+ }, [
+ c('&:hover', { background: 'var(--dsw-alias-button-floating-hover)' }),
+ ]),
+ e('menu-item-icon', {
+ boxSizing: 'border-box',
+ flex: 'none',
+ justifyContent: 'center',
+ alignItems: 'center',
+ display: 'inline-flex',
+ fontSize: '16px',
+ }),
+ e('menu-item-label', {
+ minWidth: 0,
+ overflow: 'hidden',
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ margin: '0 6px 0 0',
+ }),
+ e('region-area', {
+ minHeight: 0,
+ marginRight: 'calc(-1 * var(--dshp-padding))',
+ flexDirection: 'column',
+ flex: 1,
+ padding: '0 4px',
+ display: 'flex',
+ overflow: 'hidden',
+ }),
+ e('foot-area', {
+ flexDirection: 'column',
+ flex: 'none',
+ display: 'flex',
+ }),
+ e('footer-actions', {
+ flex: 'none',
+ width: '100%',
+ minWidth: 0,
+ display: 'flex',
+ }),
+ e('settings-area', {
+ flex: 'none',
+ width: '100%',
+ minWidth: 0,
+ }),
+ e('panel-view', {
+ 'height': '100%',
+ 'boxSizing': 'border-box',
+ 'minWidth': 0,
+ 'overflowY': 'auto',
+ 'scrollbarGutter': 'stable',
+ 'position': 'relative',
+ // 内容宽度派生(自给自足镜像 alpha):有拖拽偏好用偏好,否则自适应
+ // clamp(680px, col*0.64, 920px);列宽与偏好由 width 控制器发布。
+ '--dsh-chat-content-width': 'var(--dsh-chat-user-width, clamp(680px, calc(var(--dsh-conversation-column-width, 0px) * .64), 920px))',
+ }),
+ e('panel-view-column', {
+ maxWidth: 'var(--dsh-chat-content-width,780px)',
+ minHeight: '100%',
+ width: '100%',
+ margin: '0 auto',
+ flexDirection: 'column',
+ gap: '16px',
+ display: 'flex',
+ }),
+ // 内容宽度拖拽手柄(镜像 alpha WidthHandle):绝对定位在内容列两侧 24px 外,
+ // 宽度自适应(列宽 − 内容宽的一半再减两个 24px inset,最多 40px);
+ // hover/拖动时发光条跟随指针 Y(--dsh-width-handle-pointer-y)。
+ e('width-handle', {
+ zIndex: 8,
+ width: 'min(40px, calc((100% - var(--dsh-chat-content-width)) / 2 - 24px - 24px))',
+ cursor: 'col-resize',
+ position: 'absolute',
+ top: 0,
+ bottom: 0,
+ }, [
+ c('&[data-side="left"]', { right: 'calc(50% + var(--dsh-chat-content-width) / 2 + 24px)' }),
+ c('&[data-side="right"]', { left: 'calc(50% + var(--dsh-chat-content-width) / 2 + 24px)' }),
+ c('&:after', {
+ content: '""',
+ background: 'linear-gradient(to bottom, transparent calc(var(--dsh-width-handle-pointer-y, 50%) - 52px), var(--dsw-alias-scrollbar-hover-l1) calc(var(--dsh-width-handle-pointer-y, 50%) - 12px), var(--dsw-alias-scrollbar-hover-l1) calc(var(--dsh-width-handle-pointer-y, 50%) + 12px), transparent calc(var(--dsh-width-handle-pointer-y, 50%) + 52px))',
+ opacity: 0,
+ pointerEvents: 'none',
+ borderRadius: '3px',
+ width: '3px',
+ position: 'absolute',
+ top: 0,
+ bottom: 0,
+ }),
+ c('&[data-side="left"]:after', { right: '16px' }),
+ c('&[data-side="right"]:after', { left: '16px' }),
+ c('&:hover:after, &[data-dragging]:after', { opacity: 1 }),
+ ]),
+ m('collapsed', [
+ c('&', { padding: '18px 10px 6px' }),
+ c('& .dshp-panel__section-header-title', { opacity: 0, visibility: 'hidden', maxWidth: 0 }),
+ c('& .dshp-panel__logo-row', { justifyContent: 'flex-start', height: '40px', marginBottom: '4px', padding: 0 }),
+ c('& .dshp-panel__icon-button', { width: '36px', height: '36px', color: 'var(--dsw-alias-label-primary)' }),
+ c('& .dshp-panel__panel-area', { alignItems: 'center', gap: '4px', marginBottom: '12px', paddingLeft: 0 }),
+ c('& .dshp-panel__menu-item', {
+ justifyContent: 'center',
+ alignSelf: 'flex-start',
+ width: '36px',
+ minWidth: '36px',
+ height: '36px',
+ padding: 0,
+ gap: 0,
+ borderRadius: '12px',
+ }),
+ c('& .dshp-panel__menu-item-label', { display: 'none' }),
+ c('& .dshp-panel__menu-item-icon', {
+ fontSize: '18px',
+ color: 'var(--dsw-alias-label-primary)',
+ }),
+ c('& .dshp-panel__new-session', {
+ borderColor: 'transparent',
+ justifyContent: 'center',
+ width: '36px',
+ height: '36px',
+ margin: 0,
+ padding: 0,
+ gap: 0,
+ }),
+ c('& .dshp-panel__region-area', { marginLeft: 0, marginRight: 0, padding: 0 }),
+ c('& .dshp-panel__foot-area', { alignItems: 'center' }),
+ c('& .dshp-panel__settings-area, & .dshp-panel__footer-actions', { justifyContent: 'center', width: 'auto', display: 'flex' }),
+ ]),
+ m('wide', [
+ c('&', { width: 'var(--dshp-width)' }),
+ ]),
+ m('quiet-bars', [
+ c('&', { '--dsh-scrollbar-thumb': 'transparent', '--dsh-scrollbar-thumb-hover': 'transparent' }),
+ ]),
+ m('fading', [
+ c('& > *', { opacity: 0, transition: 'opacity .15s var(--ds-ease-in-out)' }),
+ ]),
+ c('@keyframes dshp-rail-in', [c('from', { opacity: 0, transform: 'translate(49px)' })]),
+ c('@keyframes dshp-rail-fade-in', [c('from', { opacity: 0 })]),
+ c('@media (prefers-reduced-motion: reduce)', [
+ c('.dshp-panel--fading > *', { transition: 'none' }),
+ c('.dshp-panel--rail-in .dshp-panel__icon-button, .dshp-panel--rail-in .dshp-panel__menu-item, .dshp-panel--rail-in .dshp-panel__foot-area, .dshp-panel--rail-in .dshp-panel__region-area', { animation: 'none' }),
+ ]),
+])
diff --git a/packages/dsh-tauri-rightclick/package.json b/packages/dsh-tauri-rightclick/package.json
index 1a791b77..955db1d5 100644
--- a/packages/dsh-tauri-rightclick/package.json
+++ b/packages/dsh-tauri-rightclick/package.json
@@ -39,10 +39,12 @@
"inject": [
"@deepseek-ai/dsh-client-ui-layout",
"@deepseek-ai/dsh-client-ui-primitives",
- "dsh-tauri"
+ "dsh-tauri",
+ "dsh-tauri-ui"
],
"external": [
- "dsh-tauri/client"
+ "dsh-tauri/client",
+ "dsh-tauri-ui/client"
],
"platform": "web"
},
@@ -58,7 +60,8 @@
"typecheck": "tsc"
},
"dependencies": {
- "dsh-tauri": "workspace:*"
+ "dsh-tauri": "workspace:*",
+ "dsh-tauri-ui": "workspace:*"
},
"devDependencies": {
"dsh-tauri-tsdown": "workspace:*",
diff --git a/packages/dsh-tauri-rightclick/src/client/components/confirm-dialog.ts b/packages/dsh-tauri-rightclick/src/client/components/confirm-dialog.ts
index 52612b72..2b406ffa 100644
--- a/packages/dsh-tauri-rightclick/src/client/components/confirm-dialog.ts
+++ b/packages/dsh-tauri-rightclick/src/client/components/confirm-dialog.ts
@@ -3,7 +3,7 @@
*
* 内嵌 WebView2 里的 `window.confirm` 会以「127.0.0.1:3080 嵌入页提示」横幅出现,
* 不随客户端 UI 主题(#235)。这里用与官方一致的 primitives Modal 渲染,
- * Promise 化以便 await;仅依赖宿主提供的 react / primitives。
+ * Promise 化以便 await;仅依赖宿主提供的 react / primitives。
*/
import type { ReactElement } from 'react'
import { Button, Modal } from '@deepseek-ai/dsh-client-ui-primitives'
diff --git a/packages/dsh-tauri-rightclick/src/client/constants/index.ts b/packages/dsh-tauri-rightclick/src/client/constants/index.ts
index 923ce712..c6838159 100644
--- a/packages/dsh-tauri-rightclick/src/client/constants/index.ts
+++ b/packages/dsh-tauri-rightclick/src/client/constants/index.ts
@@ -11,19 +11,24 @@ export const OPEN_PATH_ROUTE = `${RIGHTCLICK_API_PREFIX}/open-path`
/** css-render style id。 */
export const RIGHTCLICK_STYLE_ID = 'dsh-tauri-rightclick-styles'
+export const RIGHTCLICK_MENU_STYLE_ID = 'dsh-tauri-rightclick-menu-styles'
+export const RIGHTCLICK_TOAST_STYLE_ID = 'dsh-tauri-rightclick-toast-styles'
/** Effects / lifecycle ids(诊断元数据)。 */
export const RIGHTCLICK_STYLES_EFFECT = `${RIGHTCLICK_CLIENT_PLUGIN}: styles`
export const RIGHTCLICK_MENU_EFFECT = `${RIGHTCLICK_CLIENT_PLUGIN}: context menu`
-/** css-render class prefix(跨插件协议暴露给扩展事件 detail 的 DOM 结构保持稳定)。 */
+/**
+ * css-render class 前缀(bem blockPrefix `.dshp-`,跨插件协议暴露给扩展事件
+ * detail 的 DOM 结构保持稳定——修改必须同步 styles/*.cssr.ts)。
+ */
export const RIGHTCLICK_CLASSES = {
- menu: 'dsh-tauri-rightclick',
- item: 'dsh-tauri-rightclick-item',
- itemDanger: 'dsh-tauri-rightclick-item--danger',
- shortcut: 'dsh-tauri-rightclick-shortcut',
- separator: 'dsh-tauri-rightclick-separator',
- toast: 'dsh-tauri-rightclick-toast',
+ menu: 'dshp-menu',
+ item: 'dshp-menu__item',
+ itemDanger: 'dshp-menu__item--danger',
+ shortcut: 'dshp-menu__shortcut',
+ separator: 'dshp-menu__separator',
+ toast: 'dshp-toast',
} as const
/** 扩展注册表协议(其他 Web 插件经 globalThis[Symbol.for(KEY)] 登记扩展项)。 */
diff --git a/packages/dsh-tauri-rightclick/src/client/index.ts b/packages/dsh-tauri-rightclick/src/client/index.ts
index 6344e1a5..e80ef0ec 100644
--- a/packages/dsh-tauri-rightclick/src/client/index.ts
+++ b/packages/dsh-tauri-rightclick/src/client/index.ts
@@ -13,15 +13,19 @@
* 与 node half(src/index.ts)经 /api/dsh-rightclick-menu/* 通信(open-url)。
*/
import type { ClientContext } from 'dsh-tauri/client'
+import { mountStyle } from 'dsh-tauri-ui/client'
import { compat } from 'dsh-tauri/client'
import {
RIGHTCLICK_CLIENT_PLUGIN,
RIGHTCLICK_MENU_EFFECT,
+ RIGHTCLICK_MENU_STYLE_ID,
RIGHTCLICK_STYLES_EFFECT,
+ RIGHTCLICK_TOAST_STYLE_ID,
} from './constants'
import { installLocale } from './locales'
import { installContextMenu } from './service/menu'
-import { mountRightClickStyles } from './styles'
+import rightClickMenuStyle from './styles/rightclick-menu.cssr'
+import rightClickToastStyle from './styles/rightclick-toast.cssr'
/** 插件显示名(诊断元数据)。 */
export const name = RIGHTCLICK_CLIENT_PLUGIN
@@ -37,7 +41,8 @@ export function apply(ctx: ClientContext): void {
const cx = compat(ctx)
installLocale(cx)
- ctx.effect(() => mountRightClickStyles(), RIGHTCLICK_STYLES_EFFECT)
+ ctx.effect(() => mountStyle(rightClickMenuStyle, RIGHTCLICK_MENU_STYLE_ID), RIGHTCLICK_STYLES_EFFECT)
+ ctx.effect(() => mountStyle(rightClickToastStyle, RIGHTCLICK_TOAST_STYLE_ID), RIGHTCLICK_STYLES_EFFECT)
ctx.effect(() => installContextMenu(cx), RIGHTCLICK_MENU_EFFECT)
}
diff --git a/packages/dsh-tauri-rightclick/src/client/styles/index.ts b/packages/dsh-tauri-rightclick/src/client/styles/index.ts
deleted file mode 100644
index 648dd586..00000000
--- a/packages/dsh-tauri-rightclick/src/client/styles/index.ts
+++ /dev/null
@@ -1,80 +0,0 @@
-/** Context menu and toast styles generated as css-render nodes. */
-import { CssRender } from 'dsh-tauri/client'
-import { RIGHTCLICK_CLASSES as K, RIGHTCLICK_STYLE_ID } from '../constants'
-
-const cssr = CssRender()
-const { c } = cssr
-
-const rightClickStyle = c([
- c(`.${K.menu}`, {
- position: 'fixed',
- zIndex: 2147483647,
- width: 'max-content',
- minWidth: '148px',
- maxWidth: '260px',
- padding: '4px',
- background: 'var(--dsw-alias-bg-layer-2, #fff)',
- color: 'var(--dsw-alias-label-primary, #161616)',
- border: '1px solid var(--dsw-alias-border-l2, #ddd)',
- borderRadius: '7px',
- boxShadow: '0 5px 16px #00000029',
- font: '13px/18px system-ui, sans-serif',
- }),
- c(`.${K.item}`, {
- boxSizing: 'border-box',
- width: '100%',
- height: '30px',
- padding: '0 8px',
- textAlign: 'left',
- whiteSpace: 'nowrap',
- color: 'inherit',
- background: 'transparent',
- border: '0',
- borderRadius: '5px',
- cursor: 'pointer',
- display: 'flex',
- gap: '16px',
- alignItems: 'center',
- justifyContent: 'space-between',
- }, [
- c('&:hover, &:focus-visible', {
- background: 'var(--dsw-alias-interactive-bg-hover, #0000000f)',
- outline: 'none',
- }),
- ]),
- c(`.${K.itemDanger}`, {
- color: 'var(--dsw-alias-state-error-primary, #d93025)',
- }),
- c(`.${K.shortcut}`, {
- color: 'var(--dsw-alias-label-tertiary, #777)',
- fontSize: '11px',
- }),
- c(`.${K.separator}`, {
- height: '1px',
- margin: '4px -4px',
- background: 'var(--dsw-alias-border-l2, #ddd)',
- }),
- c(`.${K.toast}`, {
- position: 'fixed',
- zIndex: 2147483647,
- left: '50%',
- bottom: '28px',
- transform: 'translateX(-50%)',
- padding: '7px 12px',
- borderRadius: '7px',
- background: '#222',
- color: '#fff',
- font: '13px/18px system-ui, sans-serif',
- boxShadow: '0 6px 20px #0003',
- }),
-])
-
-/** 挂载右键菜单样式;若已由其他生命周期挂载则不取得所有权。 */
-export function mountRightClickStyles(): () => void {
- if (typeof document === 'undefined')
- return () => {}
- if (cssr.find(RIGHTCLICK_STYLE_ID) !== null)
- return () => {}
- rightClickStyle.mount({ id: RIGHTCLICK_STYLE_ID, head: true })
- return () => rightClickStyle.unmount({ id: RIGHTCLICK_STYLE_ID })
-}
diff --git a/packages/dsh-tauri-rightclick/src/client/styles/rightclick-menu.cssr.ts b/packages/dsh-tauri-rightclick/src/client/styles/rightclick-menu.cssr.ts
new file mode 100644
index 00000000..3995e798
--- /dev/null
+++ b/packages/dsh-tauri-rightclick/src/client/styles/rightclick-menu.cssr.ts
@@ -0,0 +1,54 @@
+import { cssr } from 'dsh-tauri-ui/client'
+
+const { c, bem: { b, e, m } } = cssr
+
+/** 右键菜单:固定定位浮层 + 行项/快捷键/分隔线(DOM 结构见 dom/menu-item.ts)。 */
+export default b('menu', {
+ position: 'fixed',
+ zIndex: 2147483647,
+ width: 'max-content',
+ minWidth: '148px',
+ maxWidth: '260px',
+ padding: '4px',
+ background: 'var(--dsw-alias-bg-layer-2, #fff)',
+ color: 'var(--dsw-alias-label-primary, #161616)',
+ border: '1px solid var(--dsw-alias-border-l2, #ddd)',
+ borderRadius: '7px',
+ boxShadow: '0 5px 16px #00000029',
+ font: '13px/18px system-ui, sans-serif',
+}, [
+ e('item', {
+ boxSizing: 'border-box',
+ width: '100%',
+ height: '30px',
+ padding: '0 8px',
+ textAlign: 'left',
+ whiteSpace: 'nowrap',
+ color: 'inherit',
+ background: 'transparent',
+ border: '0',
+ borderRadius: '5px',
+ cursor: 'pointer',
+ display: 'flex',
+ gap: '16px',
+ alignItems: 'center',
+ justifyContent: 'space-between',
+ }, [
+ c('&:hover, &:focus-visible', {
+ background: 'var(--dsw-alias-interactive-bg-hover, #0000000f)',
+ outline: 'none',
+ }),
+ m('danger', {
+ color: 'var(--dsw-alias-state-error-primary, #d93025)',
+ }),
+ ]),
+ e('shortcut', {
+ color: 'var(--dsw-alias-label-tertiary, #777)',
+ fontSize: '11px',
+ }),
+ e('separator', {
+ height: '1px',
+ margin: '4px -4px',
+ background: 'var(--dsw-alias-border-l2, #ddd)',
+ }),
+])
diff --git a/packages/dsh-tauri-rightclick/src/client/styles/rightclick-toast.cssr.ts b/packages/dsh-tauri-rightclick/src/client/styles/rightclick-toast.cssr.ts
new file mode 100644
index 00000000..86bac4f9
--- /dev/null
+++ b/packages/dsh-tauri-rightclick/src/client/styles/rightclick-toast.cssr.ts
@@ -0,0 +1,18 @@
+import { cssr } from 'dsh-tauri-ui/client'
+
+const { bem: { b } } = cssr
+
+/** 右键动作反馈 toast(固定定位,底部居中)。 */
+export default b('toast', {
+ position: 'fixed',
+ zIndex: 2147483647,
+ left: '50%',
+ bottom: '28px',
+ transform: 'translateX(-50%)',
+ padding: '7px 12px',
+ borderRadius: '7px',
+ background: '#222',
+ color: '#fff',
+ font: '13px/18px system-ui, sans-serif',
+ boxShadow: '0 6px 20px #0003',
+})
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 4e633504..54fe5288 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -711,6 +711,9 @@ importers:
dsh-tauri:
specifier: workspace:*
version: link:../dsh-tauri
+ dsh-tauri-ui:
+ specifier: workspace:*
+ version: link:../dsh-tauri-ui
devDependencies:
dsh-tauri-tsdown:
specifier: workspace:*