Skip to content

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

feat(ui): 组件层新增 GoalBar,并按官方 PermissionSelect 校正 composerTrigger

hairyf11cca57caf13
diff --git a/packages/dsh-tauri-ui/src/client/components/button.cssr.ts b/packages/dsh-tauri-ui/src/client/components/button.cssr.ts
index edcfe77b..b80aacce 100644
--- a/packages/dsh-tauri-ui/src/client/components/button.cssr.ts
+++ b/packages/dsh-tauri-ui/src/client/components/button.cssr.ts
@@ -2,7 +2,22 @@ import { styles as sharedStyles } from '../constants/theme'
import { cssr } from '../utils/cssr'
const { c, bem: { b, m } } = cssr
-const { borderL3, error, primary, primaryFill, primaryFg, primaryHover } = sharedStyles
+const { borderL3, error, primary, primaryFill, primaryFg, primaryHover, hover, active } = sharedStyles
+
+const addCapsule = {
+ display: 'inline-flex',
+ alignItems: 'center',
+ justifyContent: 'center',
+ gap: '4px',
+ boxSizing: 'border-box',
+ height: '32px',
+ padding: '0 12px',
+ border: 'none',
+ borderRadius: '16px',
+ fontSize: '13px',
+ lineHeight: '20px',
+ cursor: 'pointer',
+} as const
export default b('button', {}, [
m('elevated', {
@@ -32,28 +47,21 @@ export default b('button', {}, [
opacity: '0.5',
}),
]),
- m('add', {
- display: 'inline-flex',
- alignItems: 'center',
- justifyContent: 'center',
- gap: '4px',
- boxSizing: 'border-box',
- height: '32px',
- padding: '0 12px',
- border: 'none',
- borderRadius: '16px',
- background: primaryFill,
- color: primaryFg,
- fontSize: '13px',
- lineHeight: '20px',
- cursor: 'pointer',
- }, [
+ m('add', { ...addCapsule, background: primaryFill, color: primaryFg }, [
c('&:hover:not(:disabled)', { background: primaryHover }),
c('&:disabled', {
cursor: 'not-allowed',
opacity: '0.4',
}),
]),
+ m('addGhost', { ...addCapsule, background: 'transparent', color: primary }, [
+ c('&:hover:not(:disabled)', { background: hover }),
+ c('&:active:not(:disabled)', { background: active }),
+ c('&:disabled', {
+ cursor: 'not-allowed',
+ opacity: '0.4',
+ }),
+ ]),
// 上游 `.danger` 是 token 重绑:本地覆盖 --dsw-alias-interactive-bg-hover,让 hover 洗色变红。
m('danger', {
'display': 'inline-flex',
diff --git a/packages/dsh-tauri-ui/src/client/components/button.tsx b/packages/dsh-tauri-ui/src/client/components/button.tsx
index 6631d67a..05cbecd6 100644
--- a/packages/dsh-tauri-ui/src/client/components/button.tsx
+++ b/packages/dsh-tauri-ui/src/client/components/button.tsx
@@ -7,11 +7,11 @@ import buttonStyle from './button.cssr'
const BUTTON_STYLE_ID = 'dsh-tauri-ui-button-styles'
-function isLocalVariant(variant: ButtonProps['variant']): variant is 'elevated' | 'add' | 'danger' {
- return variant === 'elevated' || variant === 'add' || variant === 'danger'
+function isLocalVariant(variant: ButtonProps['variant']): variant is 'elevated' | 'add' | 'addGhost' | 'danger' {
+ return variant === 'elevated' || variant === 'add' || variant === 'addGhost' || variant === 'danger'
}
-// elevated / add 是上游固定几何,size 对其无效;danger 沿用官方 outline 的 md / sm 两档。
+// elevated / add / addGhost 是上游固定几何,size 对其无效;danger 沿用官方 outline 的 md / sm 两档。
function LocalButton({
variant,
size,
@@ -19,7 +19,7 @@ function LocalButton({
className,
children,
...rest
-}: ButtonProps & { variant: 'elevated' | 'add' | 'danger', size: ButtonSize }): ReactElement {
+}: ButtonProps & { variant: 'elevated' | 'add' | 'addGhost' | 'danger', size: ButtonSize }): ReactElement {
useMountStyle(buttonStyle, BUTTON_STYLE_ID)
return (
<button
diff --git a/packages/dsh-tauri-ui/src/client/components/button.types.ts b/packages/dsh-tauri-ui/src/client/components/button.types.ts
index 079e540d..2617ad19 100644
--- a/packages/dsh-tauri-ui/src/client/components/button.types.ts
+++ b/packages/dsh-tauri-ui/src/client/components/button.types.ts
@@ -7,6 +7,7 @@ export type ButtonVariant
| 'toolbar'
| 'elevated'
| 'add'
+ | 'addGhost'
| 'danger'
export type ButtonSize = 'sm' | 'md'
diff --git a/packages/dsh-tauri-ui/src/client/components/chip.cssr.ts b/packages/dsh-tauri-ui/src/client/components/chip.cssr.ts
index ed88a6b1..072beb53 100644
--- a/packages/dsh-tauri-ui/src/client/components/chip.cssr.ts
+++ b/packages/dsh-tauri-ui/src/client/components/chip.cssr.ts
@@ -35,7 +35,7 @@ export default b('chip', {}, [
}),
]),
m('composerTrigger', {
- display: 'flex',
+ display: 'inline-flex',
alignItems: 'center',
gap: '4px',
minWidth: '0',
diff --git a/packages/dsh-tauri-ui/src/client/components/goal-bar.cssr.ts b/packages/dsh-tauri-ui/src/client/components/goal-bar.cssr.ts
new file mode 100644
index 00000000..930525de
--- /dev/null
+++ b/packages/dsh-tauri-ui/src/client/components/goal-bar.cssr.ts
@@ -0,0 +1,98 @@
+import { styles as sharedStyles } from '../constants/theme'
+import { cssr } from '../utils/cssr'
+
+const { c, bem: { b, e, m } } = cssr
+const { dimmed, error, focusRing, hover, primary, secondary, tertiary } = sharedStyles
+
+export default b('goal-bar', {
+ 'position': 'relative',
+ 'isolation': 'isolate',
+ 'boxSizing': 'border-box',
+ 'display': 'flex',
+ 'alignItems': 'center',
+ 'gap': '10px',
+ 'width': '100%',
+ 'maxWidth': 'calc(var(--dsh-composer-card-max-width) - 4 * var(--dsh-composer-dock-inset))',
+ 'height': '36px',
+ 'margin': '0 auto',
+ 'padding': '4px 5px 4px 12px',
+ 'border': '0',
+ '--dsw-elevation-stroke-color': 'var(--dsw-alias-border-l1)',
+ 'borderRadius': '12px',
+ 'boxShadow': 'var(--dsw-elevation-panel)',
+}, [
+ c('&::before', {
+ content: '""',
+ position: 'absolute',
+ inset: '0',
+ zIndex: '-1',
+ borderRadius: 'inherit',
+ background: 'var(--dsw-specific-menu)',
+ backdropFilter: 'var(--dsw-menu-backdrop-filter)',
+ pointerEvents: 'none',
+ }),
+ e('glyph', {
+ display: 'inline-flex',
+ flex: 'none',
+ color: tertiary,
+ }),
+ e('label', {
+ flex: 'none',
+ fontSize: '13px',
+ lineHeight: '24px',
+ fontWeight: '500',
+ color: primary,
+ }),
+ e('objective', {
+ flex: '1',
+ minWidth: '0',
+ overflow: 'hidden',
+ fontSize: '13px',
+ lineHeight: '20px',
+ color: dimmed,
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ }),
+ e('error', {
+ flex: '1',
+ minWidth: '0',
+ overflow: 'hidden',
+ color: error,
+ fontSize: '12px',
+ lineHeight: '20px',
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ }),
+ e('actions', {
+ display: 'flex',
+ alignItems: 'center',
+ gap: '10px',
+ flex: 'none',
+ }),
+ e('action', {
+ display: 'inline-flex',
+ alignItems: 'center',
+ justifyContent: 'center',
+ gap: '4px',
+ padding: '0',
+ border: '0',
+ background: 'transparent',
+ color: tertiary,
+ font: 'inherit',
+ fontSize: '13px',
+ lineHeight: '20px',
+ borderRadius: '6px',
+ cursor: 'pointer',
+ }, [
+ c('&:hover:not(:disabled)', { color: secondary, background: hover }),
+ c('&:focus-visible', { ...focusRing }),
+ c('&:disabled', {
+ color: dimmed,
+ cursor: 'default',
+ opacity: '0.4',
+ }),
+ ]),
+ m('danger', { color: error }, [
+ c('&:hover:not(:disabled)', { color: `color-mix(in srgb, ${error} 78%, ${primary})` }),
+ ]),
+])
diff --git a/packages/dsh-tauri-ui/src/client/components/goal-bar.tsx b/packages/dsh-tauri-ui/src/client/components/goal-bar.tsx
new file mode 100644
index 00000000..22ed480f
--- /dev/null
+++ b/packages/dsh-tauri-ui/src/client/components/goal-bar.tsx
@@ -0,0 +1,48 @@
+import type { ReactElement } from 'react'
+import type { GoalBarActionProps, GoalBarProps } from './goal-bar.types'
+import { compact } from 'dsh-tauri/client'
+import { useMountStyle } from '../hooks/use-mount-style'
+import goalBarStyle from './goal-bar.cssr'
+
+const GOAL_BAR_STYLE_ID = 'dsh-tauri-ui-goal-bar-styles'
+
+export function GoalBar({
+ glyph,
+ label,
+ objective,
+ error,
+ actions,
+ className,
+ children,
+ ...rest
+}: GoalBarProps): ReactElement {
+ useMountStyle(goalBarStyle, GOAL_BAR_STYLE_ID)
+ return (
+ <div className={compact(['dshp-goal-bar', className]).join(' ')} {...rest}>
+ {glyph === undefined ? null : <span className="dshp-goal-bar__glyph">{glyph}</span>}
+ {label === undefined ? null : <span className="dshp-goal-bar__label">{label}</span>}
+ {objective === undefined ? null : <span className="dshp-goal-bar__objective">{objective}</span>}
+ {error === undefined ? null : <span className="dshp-goal-bar__error" role="alert">{error}</span>}
+ {children}
+ {actions === undefined ? null : <div className="dshp-goal-bar__actions">{actions}</div>}
+ </div>
+ )
+}
+
+export function GoalBarAction({
+ variant = 'default',
+ className,
+ children,
+ ...rest
+}: GoalBarActionProps): ReactElement {
+ useMountStyle(goalBarStyle, GOAL_BAR_STYLE_ID)
+ return (
+ <button
+ type="button"
+ className={compact(['dshp-goal-bar__action', variant === 'default' ? undefined : `dshp-goal-bar--${variant}`, className]).join(' ')}
+ {...rest}
+ >
+ {children}
+ </button>
+ )
+}
diff --git a/packages/dsh-tauri-ui/src/client/components/goal-bar.types.ts b/packages/dsh-tauri-ui/src/client/components/goal-bar.types.ts
new file mode 100644
index 00000000..176101e4
--- /dev/null
+++ b/packages/dsh-tauri-ui/src/client/components/goal-bar.types.ts
@@ -0,0 +1,17 @@
+import type { ButtonHTMLAttributes, HTMLAttributes, ReactNode } from 'react'
+
+export type GoalBarActionVariant = 'default' | 'danger'
+
+export interface GoalBarProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
+ glyph?: ReactNode
+ label?: ReactNode
+ objective?: ReactNode
+ error?: ReactNode
+ actions?: ReactNode
+ children?: ReactNode
+}
+
+export interface GoalBarActionProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'children'> {
+ variant?: GoalBarActionVariant
+ children?: ReactNode
+}
diff --git a/packages/dsh-tauri-ui/src/client/components/index.ts b/packages/dsh-tauri-ui/src/client/components/index.ts
index 11d05348..6c4dae32 100644
--- a/packages/dsh-tauri-ui/src/client/components/index.ts
+++ b/packages/dsh-tauri-ui/src/client/components/index.ts
@@ -4,6 +4,8 @@ export * from './checkbox'
export type * from './checkbox.types'
export * from './chip'
export type * from './chip.types'
+export * from './goal-bar'
+export type * from './goal-bar.types'
export * from './icon'
export * from './icon-button'
export type * from './icon.types'
diff --git a/packages/dsh-tauri-ui/src/client/components/registry.ts b/packages/dsh-tauri-ui/src/client/components/registry.ts
index 9eff54b6..a6363cb5 100644
--- a/packages/dsh-tauri-ui/src/client/components/registry.ts
+++ b/packages/dsh-tauri-ui/src/client/components/registry.ts
@@ -84,6 +84,12 @@ export const UI_COMPONENT_REGISTRY: readonly UiComponentEntry[] = [
upstreamPath: 'packages/client/ui-plugin-manager/src/client/PluginManagerPage.module.css',
mappedClass: 'addButton',
}),
+ reforkVariant('Button', 'addGhost', {
+ package: '@deepseek-ai/dsh-client-ui-plugin-manager',
+ availableAt: AVAILABLE_LATEST,
+ upstreamPath: 'packages/client/ui-plugin-manager/src/client/PluginManagerPage.module.css',
+ mappedClass: 'addButton',
+ }),
reforkVariant('Button', 'danger', {
package: '@deepseek-ai/dsh-client-ui-plugin-manager',
availableAt: AVAILABLE_LATEST,
@@ -150,6 +156,18 @@ export const UI_COMPONENT_REGISTRY: readonly UiComponentEntry[] = [
upstreamPath: 'packages/client/ui-permission-presets/src/client/PermissionRow.module.css',
mappedClass: 'selector',
}),
+ reforkVariant('GoalBar', 'bar', {
+ package: '@deepseek-ai/dsh-client-ui-goal',
+ availableAt: AVAILABLE_BOTH,
+ upstreamPath: 'packages/client/ui-goal/src/client/GoalBar.module.css',
+ mappedClass: 'bar',
+ }),
+ reforkVariant('GoalBar', 'action', {
+ package: '@deepseek-ai/dsh-client-ui-goal',
+ availableAt: AVAILABLE_BOTH,
+ upstreamPath: 'packages/client/ui-goal/src/client/GoalBar.module.css',
+ mappedClass: 'iconBtn',
+ }),
reforkVariant('Tag', 'version', {
package: '@deepseek-ai/dsh-client-ui-plugin-manager',
availableAt: AVAILABLE_LATEST,
diff --git a/packages/dsh-tauri-ui/src/client/constants/index.ts b/packages/dsh-tauri-ui/src/client/constants/index.ts
index 4e79172c..0d2af4c5 100644
--- a/packages/dsh-tauri-ui/src/client/constants/index.ts
+++ b/packages/dsh-tauri-ui/src/client/constants/index.ts
@@ -13,15 +13,6 @@ export const SETTINGS_ONBOARDING_SLOT = 'settings.onboarding'
export const SETTINGS_SIDEBAR_ID = 'dsh-tauri-ui-settings'
export const SETTINGS_SIDEBAR_CLASS = 'dshp-settings-sidebar'
-/**
- * 仅 dev 构建挂载的「UI 组件」调试面板。
- *
- * 面板入口排在 IM(40)之后;是否挂载由宿主命令 `is_dev_build` 决定——插件侧没有
- * 可用的构建期开关(`dsh-tauri-tsdown` 无条件把 `process.env.NODE_ENV` 定成
- * `'production'`,也不替换 `import.meta.env`)。
- */
-export const UI_COMPONENTS_PANEL_ID = 'dsh-tauri-ui-components'
-export const UI_COMPONENTS_PANEL_ORDER = 50
/** 接管后的英雄区工作区选择控件(官方 chip 由样式隐藏,见 `ui/hero-workspace.cssr.ts`)。 */
export const HERO_WORKSPACE_CHIP_CLASS = 'dshp-hero-workspace'
@@ -61,7 +52,6 @@ export const SECTIONS_EFFECT = `${PLUGIN_ID}: settings sections projection`
export const SETTINGS_EFFECT = `${PLUGIN_ID}: settings panel`
export const OBSTRUCTIONS_EFFECT = `${PLUGIN_ID}: settings obstructions`
export const IM_PANEL_EFFECT = `${PLUGIN_ID}: im panel`
-export const UI_COMPONENTS_EFFECT = `${PLUGIN_ID}: ui components panel`
export const HERO_WORKSPACE_EFFECT = `${PLUGIN_ID}: hero workspace picker`
export const NEW_SESSION_EFFECT = `${PLUGIN_ID}: sidebar new session`
export const UNGROUPED_NEW_SESSION_EFFECT = `${PLUGIN_ID}: sidebar ungrouped new session`
diff --git a/packages/dsh-tauri-ui/src/client/constants/theme.ts b/packages/dsh-tauri-ui/src/client/constants/theme.ts
index dce58ffd..22e9d208 100644
--- a/packages/dsh-tauri-ui/src/client/constants/theme.ts
+++ b/packages/dsh-tauri-ui/src/client/constants/theme.ts
@@ -13,6 +13,7 @@ export const styles = {
modulePlatform: 'var(--dsw-alias-bg-module-platform)',
font: 'var(--dsw-font-family)',
hover: 'var(--dsw-alias-interactive-bg-hover)',
+ active: 'var(--dsw-alias-interactive-bg-active)',
hoverSolid: 'var(--dsw-alias-interactive-bg-hover-solid)',
hoverDanger: 'var(--dsw-alias-interactive-bg-hover-danger)',
error: 'var(--dsw-alias-state-error-primary)',
diff --git a/packages/dsh-tauri-ui/src/client/index.ts b/packages/dsh-tauri-ui/src/client/index.ts
index 864a8390..c83bdf50 100644
--- a/packages/dsh-tauri-ui/src/client/index.ts
+++ b/packages/dsh-tauri-ui/src/client/index.ts
@@ -1,9 +1,8 @@
import type {} from '@deepseek-ai/dsh-client-ui-layout/client'
import type { ClientContext } from 'dsh-tauri/client'
import { PLUGIN_ID } from '../shared/constants'
-import { HERO_WORKSPACE_EFFECT, IM_PANEL_EFFECT, LOCALE_EFFECT, NEW_SESSION_EFFECT, OBSTRUCTIONS_EFFECT, SEAT_EFFECT, SECTIONS_EFFECT, SETTINGS_EFFECT, STYLES_EFFECT, UI_COMPONENTS_EFFECT, UNGROUPED_NEW_SESSION_EFFECT } from './constants'
+import { HERO_WORKSPACE_EFFECT, IM_PANEL_EFFECT, LOCALE_EFFECT, NEW_SESSION_EFFECT, OBSTRUCTIONS_EFFECT, SEAT_EFFECT, SECTIONS_EFFECT, SETTINGS_EFFECT, STYLES_EFFECT, UNGROUPED_NEW_SESSION_EFFECT } from './constants'
import { locale } from './locales'
-import { registerUiComponentsPanel } from './register/components-playground'
import { composerResumeFeature } from './register/composer-resume'
import { heroWorkspaceFeature } from './register/hero-workspace'
import { registerImPanel } from './register/im-panel'
@@ -55,5 +54,4 @@ export function apply(ctx: ClientContext): void {
ctx.effect(ungroupedNewSessionFeature, UNGROUPED_NEW_SESSION_EFFECT)
ctx.effect(composerResumeFeature, COMPOSER_RESUME_EFFECT)
ctx.effect(registerImPanel, IM_PANEL_EFFECT)
- ctx.effect(registerUiComponentsPanel, UI_COMPONENTS_EFFECT)
}
diff --git a/packages/dsh-tauri-ui/src/client/locales/index.ts b/packages/dsh-tauri-ui/src/client/locales/index.ts
index 7f5534f6..39b85e81 100644
--- a/packages/dsh-tauri-ui/src/client/locales/index.ts
+++ b/packages/dsh-tauri-ui/src/client/locales/index.ts
@@ -9,8 +9,6 @@ export const locale = defineLocale(PLUGIN_ID, {
noResults: '没有匹配的设置项',
resumeTask: '继续任务',
im: 'IM',
- uiComponents: 'UI 组件',
- uiComponentsHint: '官方组件与 refork 组件的样式对照,仅 dev 构建可见。',
chooseWorkspace: '选择工作区',
ungrouped: '未分组',
addWorkspace: '添加工作区…',
@@ -59,8 +57,6 @@ export const locale = defineLocale(PLUGIN_ID, {
noResults: 'No matching settings',
resumeTask: 'Resume task',
im: 'IM',
- uiComponents: 'UI components',
- uiComponentsHint: 'Style comparison of official and reforked components. Dev builds only.',
chooseWorkspace: 'Choose workspace',
ungrouped: 'Ungrouped',
addWorkspace: 'Add workspace…',
diff --git a/packages/dsh-tauri-ui/src/client/register/components-playground.tsx b/packages/dsh-tauri-ui/src/client/register/components-playground.tsx
deleted file mode 100644
index ab845161..00000000
--- a/packages/dsh-tauri-ui/src/client/register/components-playground.tsx
+++ /dev/null
@@ -1,38 +0,0 @@
-import type { ClientContext } from 'dsh-tauri/client'
-import { definePanel, defineRegister, invoke } from 'dsh-tauri/client'
-import { Icon } from '../components/icon'
-import { Puzzle } from '../components/icons'
-import { PanelPage } from '../ui/panel-page'
-import { UI_COMPONENTS_PANEL_ID, UI_COMPONENTS_PANEL_ORDER } from '../constants'
-import { locale } from '../locales'
-import { UiComponentsPanel } from '../ui/components-playground/ui-components'
-
-/**
- * 仅 dev 构建挂载的「UI 组件」面板。
- *
- * 插件侧没有可用的构建期开关(`dsh-tauri-tsdown` 无条件把 `process.env.NODE_ENV`
- * 定成 `'production'`,也不替换 `import.meta.env`),因此向宿主问 `is_dev_build`;
- * 命令不可用(旧宿主或非桌面宿主)时按 release 处理,宁可不显示也不误发调试入口。
- */
-export const registerUiComponentsPanel = defineRegister<ClientContext>((controller, ctx) => {
- // 同一 profile 也服务普通浏览器标签:只有桌面 iframe 有宿主命令可问。
- if (typeof window === 'undefined' || window.parent === window)
- return
-
- invoke<boolean>('is_dev_build')
- .then((dev) => {
- if (!dev)
- return
- const panel = definePanel(ctx, {
- id: UI_COMPONENTS_PANEL_ID,
- order: UI_COMPONENTS_PANEL_ORDER,
- label: () => locale.text('uiComponents'),
- icon: props => <Icon as={Puzzle} size={props.size} />,
- render: () => <PanelPage><UiComponentsPanel /></PanelPage>,
- })
- controller.add(panel.dispose)
- })
- .catch((error: unknown) => {
- console.warn('[dsh-tauri-ui] is_dev_build unavailable; UI components panel stays hidden', error)
- })
-})
diff --git a/packages/dsh-tauri-ui/src/client/ui/components-playground/ui-components.cssr.ts b/packages/dsh-tauri-ui/src/client/ui/components-playground/ui-components.cssr.ts
deleted file mode 100644
index dab3dbb1..00000000
--- a/packages/dsh-tauri-ui/src/client/ui/components-playground/ui-components.cssr.ts
+++ /dev/null
@@ -1,106 +0,0 @@
-import { styles as sharedStyles } from '../../constants/theme'
-import { cssr } from '../../utils/cssr'
-
-const { c, bem: { b, e } } = cssr
-const { borderL2, layer1, layer3, primary, secondary, tertiary } = sharedStyles
-
-export default b('ui-components', {
- display: 'flex',
- flexDirection: 'column',
- gap: '22px',
- width: '100%',
- minWidth: 0,
- color: primary,
-}, [
- e('section', {
- display: 'flex',
- flexDirection: 'column',
- gap: '10px',
- minWidth: 0,
- }),
- e('title', {
- fontSize: '13px',
- fontWeight: '600',
- lineHeight: '20px',
- color: primary,
- }),
- e('hint', {
- fontSize: '12px',
- lineHeight: '1.5',
- color: tertiary,
- }),
- e('row', {
- display: 'flex',
- flexWrap: 'wrap',
- alignItems: 'center',
- gap: '10px',
- }),
- e('grid', {
- display: 'grid',
- gridTemplateColumns: 'repeat(auto-fill, minmax(260px, 1fr))',
- gap: '10px',
- }),
- e('card', {
- display: 'flex',
- flexDirection: 'column',
- gap: '8px',
- minWidth: 0,
- padding: '12px',
- border: `0.5px solid ${borderL2}`,
- borderRadius: '10px',
- background: layer1,
- }),
- e('cardHead', {
- display: 'flex',
- alignItems: 'center',
- justifyContent: 'space-between',
- gap: '8px',
- }),
- e('name', {
- fontSize: '12px',
- fontWeight: '600',
- lineHeight: '18px',
- color: primary,
- }),
- e('badge', {
- flex: 'none',
- padding: '0 6px',
- fontSize: '10px',
- lineHeight: '16px',
- color: secondary,
- background: layer3,
- borderRadius: '999px',
- }),
- e('meta', {
- display: 'flex',
- flexDirection: 'column',
- gap: '2px',
- fontSize: '11px',
- lineHeight: '16px',
- color: tertiary,
- }),
- e('code', {
- fontFamily: 'monospace',
- fontSize: '11px',
- lineHeight: '16px',
- color: secondary,
- wordBreak: 'break-all',
- }),
- e('sample', {
- display: 'flex',
- flexWrap: 'wrap',
- alignItems: 'center',
- gap: '8px',
- minHeight: '48px',
- padding: '10px',
- background: layer3,
- borderRadius: '8px',
- }),
- e('stack', {
- display: 'flex',
- flexDirection: 'column',
- alignItems: 'flex-start',
- gap: '8px',
- }),
- c('.dshp-ui-components__sample > *', { flex: 'none' }),
-])
diff --git a/packages/dsh-tauri-ui/src/client/ui/components-playground/ui-components.tsx b/packages/dsh-tauri-ui/src/client/ui/components-playground/ui-components.tsx
deleted file mode 100644
index e5b0a292..00000000
--- a/packages/dsh-tauri-ui/src/client/ui/components-playground/ui-components.tsx
+++ /dev/null
@@ -1,198 +0,0 @@
-import type { ReactElement, ReactNode } from 'react'
-import type { ChipVariant } from '../../components/chip.types'
-import type { UiComponentEntry } from '../../components/registry.types'
-import { useState } from 'react'
-import { Button } from '../../components/button'
-import { Chip } from '../../components/chip'
-import { Icon } from '../../components/icon'
-import { IconButton } from '../../components/icon-button'
-import { ChevronDown, Comments, Gear, Magnifier, Person, Plus, Puzzle, TrashBin } from '../../components/icons'
-import { Input, Menu, Pill, Switch } from '../../components/official'
-import { UI_COMPONENT_REGISTRY } from '../../components/registry'
-import { Tag } from '../../components/tag'
-import { useMountStyle } from '../../hooks/use-mount-style'
-import uiComponentsStyle from './ui-components.cssr'
-
-const UI_COMPONENTS_STYLE_ID = 'dsh-tauri-ui-components-styles'
-const BUTTON_VARIANTS = ['primary', 'outline', 'ghost', 'toolbar'] as const
-const BUTTON_SIZES = ['md', 'sm'] as const
-const TAG_TONES = ['outline', 'solid', 'neutral', 'quiet', 'success', 'info', 'warning', 'danger'] as const
-
-interface SampleOption { id: string, label: string }
-
-const SEAT_OPTIONS: readonly SampleOption[] = [
- { id: 'default', label: '默认' },
- { id: 'plan', label: '计划模式' },
- { id: 'review', label: '评审模式' },
-]
-const PERMISSION_OPTIONS: readonly SampleOption[] = [
- { id: 'default', label: '默认权限' },
- { id: 'acceptEdits', label: '接受编辑' },
- { id: 'bypass', label: '跳过确认' },
-]
-const THEME_OPTIONS: readonly SampleOption[] = [
- { id: 'system', label: '跟随系统' },
- { id: 'light', label: '浅色' },
- { id: 'dark', label: '深色' },
-]
-
-/**
- * `seat` / `composerTrigger` / `selector` 三个 chip 在应用里本身就是 select 的触发
- * 按钮:单独渲染只是个死的按钮,面板要调试它们的选中态、chevron 旋转与弹层位置,
- * 就必须接上官方 `Menu`。
- */
-function SelectSample({ variant, icon, options }: {
- variant: ChipVariant
- icon?: ReactNode
- options: readonly SampleOption[]
-}): ReactElement {
- const [open, setOpen] = useState(false)
- const [value, setValue] = useState(options[0]?.id ?? '')
- return (
- <Menu
- open={open}
- onClose={() => setOpen(false)}
- onSelect={(id) => {
- setOpen(false)
- setValue(id)
- }}
- items={options.map(option => ({ id: option.id, label: option.label }))}
- selectedId={value}
- portal
- align="end"
- anchor={(
- <Chip
- aria-expanded={open}
- aria-haspopup="menu"
- chevron={<Icon as={ChevronDown} size={12} />}
- icon={icon}
- open={open}
- variant={variant}
- onClick={() => setOpen(openState => !openState)}
- >
- {options.find(option => option.id === value)?.label ?? value}
- </Chip>
- )}
- />
- )
-}
-
-function SourceCard({ entry }: { entry: UiComponentEntry }): ReactElement {
- const { source } = entry
- return (
- <div className="dshp-ui-components__card">
- <div className="dshp-ui-components__cardHead">
- <span className="dshp-ui-components__name">{entry.title}</span>
- <span className="dshp-ui-components__badge">{source.kind}</span>
- </div>
- <div className="dshp-ui-components__meta">
- <span>
- {source.variant === undefined
- ? `映射组件:${source.component}`
- : `映射组件:${source.component} · ${source.variant}`}
- </span>
- <span className="dshp-ui-components__code">{source.package}</span>
- <span>{`版本:${source.availableAt.join(' / ')}`}</span>
- {source.mappedClass === undefined
- ? null
- : <span>{`官方类名:.${source.mappedClass}`}</span>}
- <span className="dshp-ui-components__code">{source.upstreamPath}</span>
- </div>
- </div>
- )
-}
-
-export function UiComponentsPanel(): ReactElement {
- useMountStyle(uiComponentsStyle, UI_COMPONENTS_STYLE_ID)
- const [checked, setChecked] = useState(true)
- const [activePill, setActivePill] = useState('alpha')
- const [query, setQuery] = useState('')
-
- return (
- <div className="dshp-ui-components">
- <section className="dshp-ui-components__section">
- <span className="dshp-ui-components__title">官方转发(reexport)</span>
- <span className="dshp-ui-components__hint">
- 两代内核都导出,直接转发官方实现,样式由官方 CSS Modules 提供。
- </span>
- <div className="dshp-ui-components__sample">
- {BUTTON_SIZES.map(size => BUTTON_VARIANTS.map(variant => (
- <Button key={`${size}-${variant}`} size={size} variant={variant}>
- {`${variant} / ${size}`}
- </Button>
- )))}
- </div>
- <div className="dshp-ui-components__sample">
- <Button icon={<Plus />} variant="primary">带图标</Button>
- <Button icon={<TrashBin />} variant="ghost">带图标</Button>
- {TAG_TONES.map(tone => <Tag key={tone} tone={tone}>{tone}</Tag>)}
- <Pill active={activePill === 'alpha'} onClick={() => setActivePill('alpha')}>alpha</Pill>
- <Pill active={activePill === 'beta'} onClick={() => setActivePill('beta')}>beta</Pill>
- <Switch checked={checked} label="开关" onChange={setChecked} />
- <Input
- icon={<Magnifier />}
- placeholder="搜索"
- value={query}
- onChange={event => setQuery(event.target.value)}
- />
- </div>
- </section>
-
- <section className="dshp-ui-components__section">
- <span className="dshp-ui-components__title">refork 组件</span>
- <span className="dshp-ui-components__hint">
- 官方只在 0.1.7 有实现或未导出,按官方 CSS 在本地重写;映射见下方表格。
- </span>
- <div className="dshp-ui-components__sample">
- <div className="dshp-ui-components__stack">
- <Button icon={<Plus width={16} height={16} />} variant="elevated">新建会话</Button>
- <Button disabled icon={<Plus width={16} height={16} />} variant="elevated">禁用态</Button>
- <Button icon={<Plus width={16} height={16} />} variant="add">添加模型</Button>
- <Button icon={<TrashBin width={16} height={16} />} variant="danger">删除</Button>
- <Button icon={<TrashBin width={16} height={16} />} size="sm" variant="danger">删除 / sm</Button>
- </div>
- <IconButton aria-label="搜索" icon={<Magnifier width={16} height={16} />} variant="search" />
- <IconButton aria-label="工具栏" icon={<Gear width={16} height={16} />} variant="toolbar" />
- <IconButton aria-label="模型" icon={<Puzzle width={16} height={16} />} variant="model" />
- <IconButton aria-label="圆形" icon={<Plus width={16} height={16} />} variant="round" />
- <IconButton aria-label="行内" icon={<TrashBin width={16} height={16} />} variant="row" />
- <IconButton aria-expanded aria-label="帮助" icon={<Person width={16} height={16} />} variant="help" />
- <IconButton aria-label="消息动作" icon={<Comments width={16} height={16} />} variant="action" />
- </div>
- <div className="dshp-ui-components__sample">
- <SelectSample icon={<Icon as={Person} size={14} />} options={SEAT_OPTIONS} variant="seat" />
- <SelectSample icon={<Icon as={Gear} size={14} />} options={PERMISSION_OPTIONS} variant="composerTrigger" />
- <SelectSample options={THEME_OPTIONS} variant="selector" />
- <Tag variant="version">1.0.0</Tag>
- <Tag tone="neutral" variant="version">1.0.0</Tag>
- <Tag tone="outline" variant="status">outline</Tag>
- <Tag tone="info" variant="status">info</Tag>
- <Tag tone="danger" variant="status">danger</Tag>
- </div>
- </section>
-
- <section className="dshp-ui-components__section">
- <span className="dshp-ui-components__title">{`映射表(${UI_COMPONENT_REGISTRY.length})`}</span>
- <span className="dshp-ui-components__hint">
- kind = reexport 表示直接转发官方;refork 表示按官方 CSS 在本地重写。
- </span>
- <div className="dshp-ui-components__grid">
- {UI_COMPONENT_REGISTRY.map(entry => <SourceCard key={entry.id} entry={entry} />)}
- </div>
- </section>
-
- <section className="dshp-ui-components__section">
- <span className="dshp-ui-components__title">图标</span>
- <span className="dshp-ui-components__hint">
- 官方 icons 桶两代导出名不同,统一走 @gravity-ui/icons,经 dsh-tauri-ui/client 转发。
- </span>
- <div className="dshp-ui-components__sample">
- <Icon as={Plus} size={20} />
- <Icon as={TrashBin} size={20} />
- <Icon as={Magnifier} size={20} />
- <Icon as={Gear} size={20} />
- </div>
- </section>
- </div>
- )
-}