DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.
refactor(panel): split styles into per-component cssr + shared index
hairyf51c01955cce9
diff --git a/packages/dsh-tauri-panel/src/client/components/action-item.cssr.ts b/packages/dsh-tauri-panel/src/client/components/action-item.cssr.tsnew file mode 100644index 00000000..53ead126--- /dev/null+++ b/packages/dsh-tauri-panel/src/client/components/action-item.cssr.ts@@ -0,0 +1,52 @@+import { cssr } from 'dsh-tauri-ui/client'++const { c, bem: { b, e, m } } = cssr++/** 面板区条目(action-item.tsx):菜单行 + 选中态。 */+export default b('panel', [+ 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('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',+ }),+])diff --git a/packages/dsh-tauri-panel/src/client/components/action-item.tsx b/packages/dsh-tauri-panel/src/client/components/action-item.tsxindex d56ff97d..c476cb78 100644--- a/packages/dsh-tauri-panel/src/client/components/action-item.tsx+++ b/packages/dsh-tauri-panel/src/client/components/action-item.tsx@@ -7,15 +7,18 @@import type { ReactElement } from 'react'import type { PanelActionItemProps } from '../types'-import { PANEL_DATA_ATTRIBUTES } from '../constants'+import { useMountStyle } from 'dsh-tauri-ui/client'+import { ACTION_ITEM_STYLE_ID, PANEL_DATA_ATTRIBUTES } from '../constants'import { usePanelViewId } from '../hooks/panel'+import actionItemStyle from './action-item.cssr'export function PanelActionItem({ id, icon, onClick, children }: PanelActionItemProps): ReactElement {const active = usePanelViewId()?.id === id+ useMountStyle(actionItemStyle, ACTION_ITEM_STYLE_ID)return (<buttontype="button"- className={active ? `${'dshp-panel__menu-item'} ${'dshp-panel__menu-item--selected'}` : 'dshp-panel__menu-item'}+ className={active ? 'dshp-panel__menu-item dshp-panel__menu-item--selected' : 'dshp-panel__menu-item'}{...{ [PANEL_DATA_ATTRIBUTES.action]: '' }}onClick={onClick}>diff --git a/packages/dsh-tauri-panel/src/client/components/conversation-seat.cssr.ts b/packages/dsh-tauri-panel/src/client/components/conversation-seat.cssr.tsnew file mode 100644index 00000000..cc3458d0--- /dev/null+++ b/packages/dsh-tauri-panel/src/client/components/conversation-seat.cssr.ts@@ -0,0 +1,27 @@+import { cssr } from 'dsh-tauri-ui/client'++const { bem: { b, e } } = cssr++/** 会话区替换视图(conversation-seat.tsx):内容列居中。 */+export default b('panel', [+ 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',+ }),+])diff --git a/packages/dsh-tauri-panel/src/client/components/conversation-seat.tsx b/packages/dsh-tauri-panel/src/client/components/conversation-seat.tsxindex 1d154dff..2945b6ff 100644--- a/packages/dsh-tauri-panel/src/client/components/conversation-seat.tsx+++ b/packages/dsh-tauri-panel/src/client/components/conversation-seat.tsx@@ -15,8 +15,10 @@import type { ReactElement } from 'react'import type { PanelWidthController } from '../service/width'import type { PanelContentSpec } from '../types'+import { useMountStyle } from 'dsh-tauri-ui/client'import { useEffect, useRef } from 'react'-import { PANEL_DATA_ATTRIBUTES } from '../constants'+import { CONVERSATION_SEAT_STYLE_ID, PANEL_DATA_ATTRIBUTES } from '../constants'+import conversationSeatStyle from './conversation-seat.cssr'import { WidthHandle } from './width-handle'export function ConversationSeat({@@ -29,6 +31,7 @@ export function ConversationSeat({width: PanelWidthController}): ReactElement | null {const rootRef = useRef<HTMLDivElement | null>(null)+ useMountStyle(conversationSeatStyle, CONVERSATION_SEAT_STYLE_ID)// 挂载根元素到宽度控制器:RO 发布列宽 + 偏好;卸载时 detach(disconnect)。useEffect(() => {diff --git a/packages/dsh-tauri-panel/src/client/styles/panel.cssr.ts b/packages/dsh-tauri-panel/src/client/components/sidebar.cssr.tssimilarity index 56%rename from packages/dsh-tauri-panel/src/client/styles/panel.cssr.tsrename to packages/dsh-tauri-panel/src/client/components/sidebar.cssr.tsindex 402f1e48..6af32a40 100644--- a/packages/dsh-tauri-panel/src/client/styles/panel.cssr.ts+++ b/packages/dsh-tauri-panel/src/client/components/sidebar.cssr.ts@@ -2,7 +2,7 @@ import { cssr } from 'dsh-tauri-ui/client'const { c, bem: { b, e, m } } = cssr-/** 侧栏整槽克隆(sidebar root):logo 行 + 面板区 + 官方子槽透传。 */+/** 侧栏整槽克隆(sidebar.tsx):root + logo 行 + 面板区 + 官方子槽透传 + 折叠态。 */export default b('panel', {'--dshp-padding': '12px','height': '100%',@@ -17,30 +17,6 @@ export default b('panel', {'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',@@ -126,36 +102,6 @@ export default b('panel', {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',@@ -171,21 +117,6 @@ export default b('panel', {}, [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))',@@ -211,57 +142,8 @@ export default b('panel', {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 }),diff --git a/packages/dsh-tauri-panel/src/client/components/sidebar.tsx b/packages/dsh-tauri-panel/src/client/components/sidebar.tsxindex 484c1480..4e399347 100644--- a/packages/dsh-tauri-panel/src/client/components/sidebar.tsx+++ b/packages/dsh-tauri-panel/src/client/components/sidebar.tsx@@ -1,9 +1,10 @@import type { CSSProperties, ReactElement } from 'react'import type { SidebarRootProps } from '../types'import { SlotOutlet } from '@deepseek-ai/dsh-client-ui-renderer'-import { CommentPlus, FishMark, Icon } from 'dsh-tauri-ui/client'+import { CommentPlus, FishMark, Icon, useMountStyle } from 'dsh-tauri-ui/client'import { useEffect, useRef, useState } from 'react'-import { COLLAPSE_SETTLE_MS, PANEL_DATA_ATTRIBUTES, SCROLLBAR_LINGER_MS } from '../constants'+import { COLLAPSE_SETTLE_MS, PANEL_DATA_ATTRIBUTES, SCROLLBAR_LINGER_MS, SIDEBAR_STYLE_ID } from '../constants'+import sidebarStyle from './sidebar.cssr'/*** components/sidebar.tsx — sidebar 槽整槽替换的克隆组件(priority -1 shadow 官方@@ -33,6 +34,7 @@ function cx(...parts: Array<string | false | undefined>): string {/** 克隆的 SidebarRoot:紧凑 logoRow + 面板区 + 官方子槽透传。 */export function SidebarRootClone({ collapsed, width, startSession, toggleSidebar, t }: SidebarRootProps): ReactElement {const [settled, setSettled] = useState(false)+ useMountStyle(sidebarStyle, SIDEBAR_STYLE_ID)useEffect(() => {setSettled(false)const timer = window.setTimeout(() => {diff --git a/packages/dsh-tauri-panel/src/client/components/width-handle.cssr.ts b/packages/dsh-tauri-panel/src/client/components/width-handle.cssr.tsnew file mode 100644index 00000000..917eaacd--- /dev/null+++ b/packages/dsh-tauri-panel/src/client/components/width-handle.cssr.ts@@ -0,0 +1,36 @@+import { cssr } from 'dsh-tauri-ui/client'++const { c, bem: { b, e } } = cssr++/**+ * 内容宽度拖拽手柄(width-handle.tsx):绝对定位在内容列两侧 24px 外,+ * 宽度自适应(列宽 − 内容宽的一半再减两个 24px inset,最多 40px);+ * hover/拖动时发光条跟随指针 Y(--dsh-width-handle-pointer-y)。+ */+export default b('panel', [+ 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 }),+ ]),+])diff --git a/packages/dsh-tauri-panel/src/client/components/width-handle.tsx b/packages/dsh-tauri-panel/src/client/components/width-handle.tsxindex 907c4bfc..65ebe9ba 100644--- a/packages/dsh-tauri-panel/src/client/components/width-handle.tsx+++ b/packages/dsh-tauri-panel/src/client/components/width-handle.tsx@@ -9,8 +9,10 @@import type { ReactElement } from 'react'import type { PanelWidthHandleCallbacks } from '../service/width'+import { useMountStyle } from 'dsh-tauri-ui/client'import { useCallback, useRef, useState } from 'react'-import { PANEL_DATA_ATTRIBUTES, PANEL_WIDTH_VARS } from '../constants'+import { PANEL_DATA_ATTRIBUTES, PANEL_WIDTH_VARS, WIDTH_HANDLE_STYLE_ID } from '../constants'+import widthHandleStyle from './width-handle.cssr'export interface WidthHandleProps {/** 手柄所在侧(决定外向拖拽方向)。 */@@ -22,6 +24,7 @@ export interface WidthHandleProps {/** 自绘宽度手柄:pointer capture + rAF 节流的对称拖拽。 */export function WidthHandle({ side, handle }: WidthHandleProps): ReactElement {const [dragging, setDragging] = useState(false)+ useMountStyle(widthHandleStyle, WIDTH_HANDLE_STYLE_ID)const baseRef = useRef(0)const originRef = useRef(0)const latestRef = useRef(0)diff --git a/packages/dsh-tauri-panel/src/client/constants/index.ts b/packages/dsh-tauri-panel/src/client/constants/index.tsindex d1334d99..27a6e4ce 100644--- a/packages/dsh-tauri-panel/src/client/constants/index.ts+++ b/packages/dsh-tauri-panel/src/client/constants/index.ts@@ -5,6 +5,10 @@ export const PANEL_PROTOCOL_SERVICE = 'panel.protocol'export const PANEL_VIEW_SLOT = 'conversation'export const PANEL_VIEW_COMPONENT_ID = 'dsh-tauri-panel-conversation-seat'export const PANEL_STYLE_ID = 'dsh-tauri-panel-styles'+export const SIDEBAR_STYLE_ID = 'dsh-tauri-panel-sidebar-styles'+export const ACTION_ITEM_STYLE_ID = 'dsh-tauri-panel-action-item-styles'+export const CONVERSATION_SEAT_STYLE_ID = 'dsh-tauri-panel-conversation-seat-styles'+export const WIDTH_HANDLE_STYLE_ID = 'dsh-tauri-panel-width-handle-styles'export const COLLAPSE_SETTLE_MS = 150export const SCROLLBAR_LINGER_MS = 2000export const SIDEBAR_INTERACTIVE_SELECTOR = 'button,a[href],input,select,textarea,summary,[role="button"],[role="link"],[role="menuitem"],[role="option"],[role="tab"],[role="treeitem"][aria-selected]'diff --git a/packages/dsh-tauri-panel/src/client/index.ts b/packages/dsh-tauri-panel/src/client/index.tsindex 88c30e4f..d2596cbf 100644--- a/packages/dsh-tauri-panel/src/client/index.ts+++ b/packages/dsh-tauri-panel/src/client/index.ts@@ -22,7 +22,7 @@ import { PANEL_STYLE_ID } from './constants'import { installPanelLocale } from './locales'import { installPanelService } from './register/panel-service'import { installSidebarRoot } from './register/sidebar'-import panelStyle from './styles/panel.cssr'+import panelIndexStyle from './styles/index.cssr'export { PANEL_PROTOCOL_SERVICE } from './constants'export type { PanelActionItemProps, PanelContentSpec, SidebarRootProps } from './types'@@ -46,7 +46,7 @@ export const inject = ['slots', 'layout', 'locale']*/export function apply(ctx: ClientContext): void {ctx.effect(- () => mountStyle(panelStyle, PANEL_STYLE_ID),+ () => mountStyle(panelIndexStyle, PANEL_STYLE_ID),'dsh-tauri-panel: styles',)installPanelLocale(ctx)diff --git a/packages/dsh-tauri-panel/src/client/styles/index.cssr.ts b/packages/dsh-tauri-panel/src/client/styles/index.cssr.tsnew file mode 100644index 00000000..8d06e1d1--- /dev/null+++ b/packages/dsh-tauri-panel/src/client/styles/index.cssr.ts@@ -0,0 +1,32 @@+import { cssr } from 'dsh-tauri-ui/client'++const { c, bem: { b, e } } = cssr++/** 跨组件通用的「分区标题行」(侧栏 ActionItem 区域标题,折叠时隐藏)。 */+export default b('panel', [+ 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',+ }),+ c('.dshp-panel--collapsed .dshp-panel__section-header-title', { opacity: 0, visibility: 'hidden', maxWidth: 0 }),+])