DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.
refactor(config): reuse shared components in configuration panels
hairyf0b223a8a5818
diff --git a/src/components/config-core.tsx b/src/components/config-core.tsxindex f74d1331..7cba8ae6 100644--- a/src/components/config-core.tsx+++ b/src/components/config-core.tsx@@ -1,6 +1,6 @@import type { HarnessCore } from '../hooks/use-dsh-cores'import { ArrowRotateRight, CircleArrowDown as DownloadIcon, FolderOpen } from '@gravity-ui/icons'-import { Button, Card, Checkbox, Chip, Description, Label, Spinner, Typography } from '@heroui/react'+import { Button, Checkbox, Chip, Description, Label, Spinner } from '@heroui/react'import { useOverlay } from '@overlastic/react'import { invoke } from '@tauri-apps/api/core'import { useState } from 'react'@@ -9,8 +9,12 @@ import { If } from 'react-if-lite'import { store } from '@/store'import { toast } from '@/utils'import { useDshCores } from '../hooks/use-dsh-cores'-import { CoreDownloadDialog } from './core-download-dialog'-import { Dialog } from './dialog'+import { DownloadCoreDialog } from './download-core-dialog'+import { Empty } from './empty'+import { Item } from './item'+import { Modal } from './modal'+import { PanelHeader } from './panel-header'+import { PanelState } from './panel-state'/*** 「核心」面板:管理 Harness 引擎来源与多版本。@@ -27,8 +31,8 @@ import { Dialog } from './dialog'* - 每行展示核心入口(cli path,超长省略号 + 限制宽度)。*/export function ConfigCore() {- const [dialogHolder, openDialog] = useOverlay(Dialog, { type: 'holder' })- const [downloadDialogHolder, openDownloadDialog] = useOverlay(CoreDownloadDialog, { type: 'holder' })+ const [dialogHolder, openDialog] = useOverlay(Modal, { type: 'holder' })+ const [downloadDialogHolder, openDownloadDialog] = useOverlay(DownloadCoreDialog, { type: 'holder' })const { t } = useTranslation()const { cores, loading, error, setActiveCore, updateLocalCore, downloadCore, removeCore, busy } = useDshCores()@@ -56,24 +60,32 @@ export function ConfigCore() {async function onActivate(core: HarnessCore) {if (core.active || busy || !core.present)return- await openDialog({- status: 'warning',- title: t('core.switch_confirm_title'),- description: (- <p>- {t('core.switch_confirm_desc', { version: displayVersion(core) })}- </p>- ),- })+ try {+ await openDialog({+ status: 'warning',+ title: t('core.switch_confirm_title'),+ description: (+ <p>+ {t('core.switch_confirm_desc', { version: displayVersion(core) })}+ </p>+ ),+ })+ }+ catch {+ return+ }try {await runBusy(core.id, () => setActiveCore(core.id))- toast(t('core.activate_toast', { version: displayVersion(core) }), {+ const key = toast(t('core.activate_toast', { version: displayVersion(core) }), {variant: 'accent',description: t('core.switch_restart_hint'),timeout: 10_000,})- // 需求 5:切换核心后自动重启服务+ // 需求 5:切换核心后自动重启服务;重启结束后收起提示 toast。+ // 重启失败已由应用错误态呈现,这里静默吞掉以免重复弹错。void store.harness.restart()+ .then(() => toast.close(key))+ .catch(() => {})}catch (err) {console.error('[ConfigCore] switch failed:', err)@@ -116,16 +128,21 @@ export function ConfigCore() {async function onRemove(core: HarnessCore) {if (busy)return- await openDialog({- status: 'danger',- title: t('core.remove_confirm_title'),- description: (- <p>- {t('core.remove_confirm_desc', { version: displayVersion(core) })}- </p>- ),- confirmText: t('core.uninstall'),- })+ try {+ await openDialog({+ status: 'danger',+ title: t('core.remove_confirm_title'),+ description: (+ <p>+ {t('core.remove_confirm_desc', { version: displayVersion(core) })}+ </p>+ ),+ confirmText: t('core.uninstall'),+ })+ }+ catch {+ return+ }try {await runBusy(core.id, () => removeCore(core.id))toast(t('core.uninstalled_toast', { version: displayVersion(core) }), {})@@ -155,134 +172,106 @@ export function ConfigCore() {return (<div className="space-y-3">- {/* 面板头:标题 + 说明 */}- <div className="space-y-2">- <Typography type="h4">- {t('core.title')}- </Typography>- <Typography color="muted" type="body-sm">- {t('core.tooltip')}- </Typography>- </div>+ <PanelHeader title={t('core.title')} description={t('core.tooltip')} />{/* 加载 / 失败 / 列表 */}- <If- cond={!loading && error === ''}- else={(- <If- cond={loading}- else={(- <p className="rounded-md border border-danger/30 bg-danger/5 p-3 text-xs text-danger">- {t('plugins.error')}- :- {error}- </p>- )}- >- <div className="flex items-center justify-center gap-2 p-4 text-xs text-muted">- <Spinner size="sm" color="current" />- {t('plugins.loading')}- </div>- </If>- )}- >+ <PanelState loading={loading} error={error}><div className="space-y-3 flex-wrap gap-2">{rows.map(core => (- <Card+ <Itemkey={core.id}- className={`rounded-md bg-panel2 py-3${core.present && !core.active ? ' cursor-pointer' : ''}`}- onClick={() => onActivate(core)}- >- <Card.Content className="flex flex-col gap-1.5">- <div className="flex flex-row items-center justify-between">- <div className="flex min-w-0 items-center gap-1">- <Label className="min-w-0 truncate font-mono text-sm font-medium text-ink">- {displayVersion(core)}- </Label>- <If cond={core.source === 'local'}>- <Chip size="sm" variant="soft" color="accent" className="shrink-0 font-medium">- {t('core.local')}- </Chip>- </If>- <If cond={core.source === 'app'}>- <Chip size="sm" variant="soft" color="default" className="shrink-0 font-medium">- {t('core.app')}- </Chip>- </If>- {/* 已下载:Chip 右侧的文件夹图标,点击打开所在目录 */}- <If cond={core.present}>- <Button- size="sm"- variant="tertiary"- className="h-6 w-6 shrink-0 rounded-md p-0"- isDisabled={busy}- aria-label={t('core.open_dir')}- onClick={(event) => {- event.stopPropagation()- openCoreDir(core)- }}- >- <FolderOpen className="size-3.5" />- </Button>- </If>- <If cond={!core.present}>- <Description className="min-w-0 text-xs text-muted">- {t('core.not_downloaded')}- </Description>- </If>- </div>-- <div className="flex shrink-0 items-center gap-2">- {/* 已下载:切换(选中当前使用版本) */}- <If cond={core.present}>- <Checkbox- isSelected={core.active}- isDisabled={busy}- aria-label={core.version || core.id}- className="shrink-0"- >- <Checkbox.Content>- <Checkbox.Control>- <Checkbox.Indicator />- </Checkbox.Control>- </Checkbox.Content>- </Checkbox>- </If>- {/* 未下载(app 版本):下载入口(进度与日志在下载对话框内展示) */}- <If cond={!core.present && core.source === 'app'}>- <Button- size="sm"- variant="tertiary"- className="h-7 rounded-md text-xs"- isDisabled={busy}- onClick={(event) => {- event.stopPropagation()- onDownload(core)- }}- >- <DownloadIcon className="size-3.5" />- {t('core.download')}- </Button>- </If>- {/* 已下载且非激活(app 版本):卸载入口 */}- <If cond={core.present && !core.active && core.source === 'app'}>- <Button- size="sm"- variant="tertiary"- className="h-7 rounded-md text-xs"- isDisabled={busy}- onClick={(event) => {- event.stopPropagation()- onRemove(core)- }}- >- <If cond={busyId === core.id} then={<Spinner size="sm" color="current" />} />- {t('core.uninstall')}- </Button>- </If>- </div>- </div>- {/* 本地核心更新入口 */}+ onClick={core.present && !core.active ? () => onActivate(core) : undefined}+ left={(+ <>+ <Label className="min-w-0 truncate font-mono text-sm font-medium text-ink">+ {displayVersion(core)}+ </Label>+ <If cond={core.source === 'local'}>+ <Chip size="sm" variant="soft" color="accent" className="shrink-0 font-medium">+ {t('core.local')}+ </Chip>+ </If>+ <If cond={core.source === 'app'}>+ <Chip size="sm" variant="soft" color="default" className="shrink-0 font-medium">+ {t('core.app')}+ </Chip>+ </If>+ {/* 已下载:Chip 右侧的文件夹图标,点击打开所在目录 */}+ <If cond={core.present}>+ <Button+ size="sm"+ variant="tertiary"+ className="h-6 w-6 shrink-0 rounded-md p-0"+ isDisabled={busy}+ aria-label={t('core.open_dir')}+ onClick={(event) => {+ event.stopPropagation()+ openCoreDir(core)+ }}+ >+ <FolderOpen className="size-3.5" />+ </Button>+ </If>+ <If cond={!core.present}>+ <Description className="min-w-0 text-xs text-muted">+ {t('core.not_downloaded')}+ </Description>+ </If>+ </>+ )}+ right={(+ <>+ {/* 已下载:切换(选中当前使用版本) */}+ <If cond={core.present}>+ <Checkbox+ isSelected={core.active}+ isDisabled={busy}+ aria-label={core.version || core.id}+ className="shrink-0"+ >+ <Checkbox.Content>+ <Checkbox.Control>+ <Checkbox.Indicator />+ </Checkbox.Control>+ </Checkbox.Content>+ </Checkbox>+ </If>+ {/* 未下载(app 版本):下载入口(进度与日志在下载对话框内展示) */}+ <If cond={!core.present && core.source === 'app'}>+ <Button+ size="sm"+ variant="tertiary"+ className="h-7 rounded-md text-xs"+ isDisabled={busy}+ onClick={(event) => {+ event.stopPropagation()+ onDownload(core)+ }}+ >+ <DownloadIcon className="size-3.5" />+ {t('core.download')}+ </Button>+ </If>+ {/* 已下载且非激活(app 版本):卸载入口 */}+ <If cond={core.present && !core.active && core.source === 'app'}>+ <Button+ size="sm"+ variant="tertiary"+ className="h-7 rounded-md text-xs"+ isDisabled={busy}+ onClick={(event) => {+ event.stopPropagation()+ onRemove(core)+ }}+ >+ <If cond={busyId === core.id} then={<Spinner size="sm" color="current" />} />+ {t('core.uninstall')}+ </Button>+ </If>+ </>+ )}+ footer={(+ // 本地核心更新入口(放在主行之后,避免与勾选/卸载操作混排)<If cond={core.source === 'local' && core.present}><div className="flex justify-end"><Button@@ -300,17 +289,15 @@ export function ConfigCore() {</Button></div></If>- </Card.Content>- </Card>+ )}+ />))}{/* 本地核心提示:未检测到时说明如何安装 */}<If cond={!localCore?.present}>- <p className="rounded-md border border-line bg-panel2/40 p-3 text-xs text-muted">- {t('core.local_missing_hint')}- </p>+ <Empty>{t('core.local_missing_hint')}</Empty></If></div>- </If>+ </PanelState>{dialogHolder}{downloadDialogHolder}diff --git a/src/components/config-debug.tsx b/src/components/config-debug.tsxindex 1777e95e..01e1c78c 100644--- a/src/components/config-debug.tsx+++ b/src/components/config-debug.tsx@@ -1,4 +1,3 @@-import type { ReactNode } from 'react'import { ArrowRotateRight, ArrowUpRightFromSquare, ChevronRight, CircleInfo, Copy, Folder, Power, TrashBin } from '@gravity-ui/icons'import { Button, Chip, Description, Input, Link, ListBox, Select, Spinner, Surface, Switch, Tooltip } from '@heroui/react'import { useMutation, useQuery } from '@tanstack/react-query'@@ -9,6 +8,7 @@ import { If } from 'react-if-lite'import { useStore } from 'valtio-define'import { store } from '@/store'import { toast } from '@/utils'+import { InfoRow } from './info-row'export interface RuntimeInfo {app_version: string@@ -38,7 +38,7 @@ export interface AppConfig {export function ConfigDebug() {const { t, i18n } = useTranslation()const { serviceRunning, busyAction, preinstall } = useStore(store.harness)- const { updateInfo } = useStore(store.updater)+ const { updateInfo } = useStore(store.harnessUpdater)const [port, setPort] = useState<number>(3080)@@ -60,17 +60,18 @@ export function ConfigDebug() {queryKey: ['cli_status'],queryFn: () => invoke<CliLinkStatus>('get_cli_link_status'),})+const { data: logs, refetch: refreshLogs } = useQuery({queryKey: ['logs'],queryFn: () => invoke<string>('read_service_logs'),- refetchInterval: 5000,+ refetchInterval: 2000,})const { mutate: onClearLogs } = useMutation({mutationFn: async () => {await invoke('clear_service_logs')await refreshLogs()- toast(t('messages.logs_cleared'), {})+ toast(t('messages.logs_cleared'))},})@@ -84,7 +85,7 @@ export function ConfigDebug() {const { mutate: onCopyServiceUrl } = useMutation({mutationFn: async () => {await invoke('copy_service_url')- toast(t('messages.copy_success'), {})+ toast(t('messages.copy_success'))},})@@ -92,13 +93,16 @@ export function ConfigDebug() {mutationFn: async (port: number) => {await invoke<AppConfig>('update_app_config', { port })await refreshConfig()- toast(t('messages.port_changed'), {+ const key = toast(t('messages.port_changed'), {variant: 'accent',description: t('messages.port_restart_hint'),timeout: 10_000,actionProps: {children: t('app.restart'),- onPress: () => store.harness.restart(),+ onPress: () => {+ store.harness.restart()+ toast.close(key)+ },},})},@@ -107,6 +111,7 @@ export function ConfigDebug() {const { mutate: onRevealDataDir } = useMutation({mutationFn: () => invoke('reveal_data_dir'),})+return (<div className="space-y-3"><div className="space-y-1.5">@@ -183,12 +188,12 @@ export function ConfigDebug() {</div><div className="border-t border-line/30" /><div>- <dl className="space-y-1">+ <div className="space-y-1"><InfoRow term={t('ui.current_version')}>{info?.app_version ?? '-'}</InfoRow><InfoRow term={t('ui.dsh_version')}><span>{info?.dsh_version ?? '-'}</span><If cond={updateInfo}>- <Link className="ml-2 text-[10px] text-accent" onClick={store.updater.showToast}>+ <Link className="ml-2 text-[10px] text-accent" onClick={store.harnessUpdater.showToast}>{t('menu.new_version')}<ChevronRight className="scale-75" /></Link>@@ -200,8 +205,8 @@ export function ConfigDebug() {{info ? `${info.platform} / ${info.arch}` : '-'}</InfoRow><div className="flex items-center justify-between gap-2 text-xs">- <dt className="shrink-0 min-w-[30%] text-muted font-medium">{t('ui.data_dir')}</dt>- <dd className="min-w-0 flex items-center gap-1">+ <span className="shrink-0 min-w-[30%] text-muted font-medium">{t('ui.data_dir')}</span>+ <span className="min-w-0 flex items-center gap-1"><span className="truncate font-mono text-[11px] text-muted/80" title={info?.data_dir ?? '-'}>{info?.data_dir ?? '-'}</span>@@ -215,9 +220,9 @@ export function ConfigDebug() {><Folder className="size-3.5" /></Button>- </dd>+ </span></div>- </dl>+ </div></div><div className="border-t border-line/30" /><div className="space-y-1.5">@@ -227,6 +232,7 @@ export function ConfigDebug() {<SwitchisSelected={cliStatus?.enabled ?? false}onChange={onToggleCliLink}+ aria-label={t('ui.cli_link_enabled')}><Switch.Content><Switch.Control>@@ -310,6 +316,7 @@ export function ConfigDebug() {selectedKey={i18n.language}onSelectionChange={key => i18n.changeLanguage(String(key))}className="w-[80px]"+ aria-label={t('ui.language')}><Select.Trigger className="rounded-md min-h-8! h-8 py-0 items-center"><Select.Value />@@ -338,20 +345,11 @@ export function ConfigDebug() {variant="ghost"onPress={async () => {await navigator.clipboard.writeText(logs || '')- toast(t('messages.logs_copied'), {})+ toast(t('messages.logs_copied'))}}><Copy className="scale-80" /></Button>- <Button- isIconOnly- size="sm"- className="rounded-md size-6"- variant="ghost"- onPress={() => refreshLogs()}- >- <ArrowRotateRight className="scale-80" />- </Button><ButtonisIconOnlysize="sm"@@ -370,12 +368,3 @@ export function ConfigDebug() {</div>)}--function InfoRow({ term, children }: { term: string, children: ReactNode }) {- return (- <div className="flex items-center justify-between gap-2 text-xs py-0.5">- <dt className="shrink-0 text-muted font-medium">{term}</dt>- <dd className="min-w-0 break-all text-ink text-right font-mono">{children}</dd>- </div>- )-}diff --git a/src/components/config-dialog.tsx b/src/components/config-dialog.tsxindex 079bae88..6460081c 100644--- a/src/components/config-dialog.tsx+++ b/src/components/config-dialog.tsx@@ -1,5 +1,6 @@import type { PropsWithOverlays } from '@overlastic/react'import { Cpu, PersonPencil, Puzzle, Wrench } from '@gravity-ui/icons'+import { useEventBus } from '@hairy/react-lib'import { cn, Modal } from '@heroui/react'import { useDisclosure } from '@overlastic/react'import { useState } from 'react'@@ -15,6 +16,7 @@ export interface ConfigDialogProps extends PropsWithOverlays {}export function ConfigDialog(props: ConfigDialogProps) {const disclosure = useDisclosure({ props })const { t } = useTranslation()+const navs = [{ label: t('config.debug'), value: 'debug', icon: Wrench },{ label: t('config.profiles'), value: 'profiles', icon: PersonPencil },@@ -23,6 +25,9 @@ export function ConfigDialog(props: ConfigDialogProps) {]const [activeTab, setActiveTab] = useState('debug')++ useEventBus('config:dialog:hidden').on(disclosure.cancel)+return (<Modal isOpen={disclosure.visible} onOpenChange={disclosure.cancel}><Modal.Backdrop>diff --git a/src/components/config-plugin.tsx b/src/components/config-plugin.tsxindex 9f096eaa..84edb745 100644--- a/src/components/config-plugin.tsx+++ b/src/components/config-plugin.tsx@@ -1,15 +1,20 @@import { CircleExclamation } from '@gravity-ui/icons'-import { Button, Card, Chip, Label, Spinner, Tooltip, Typography } from '@heroui/react'+import { Button, Chip, Label, Spinner, Tooltip } from '@heroui/react'import { useOverlay } from '@overlastic/react'import { useMutation, useQueryClient } from '@tanstack/react-query'import { invoke } from '@tauri-apps/api/core'import { useState } from 'react'import { useTranslation } from 'react-i18next'import { If } from 'react-if-lite'+import { store } from '@/store'import { toast } from '@/utils'import { useDshPlugins } from '../hooks/use-dsh-plugins'-import { Dialog } from './dialog'import { Ellipsis as TextEllipsis } from './ellipsis'+import { Empty } from './empty'+import { Item } from './item'+import { Modal } from './modal'+import { PanelHeader } from './panel-header'+import { PanelState } from './panel-state'/*** 「插件」面板:展示已安装插件,作为「插件出问题时」的卸载/升级入口。@@ -27,7 +32,7 @@ export function ConfigPlugin() {const queryClient = useQueryClient()const { plugins, loading, error } = useDshPlugins()- const [dialogHolder, openDialog] = useOverlay(Dialog, { type: 'holder' })+ const [dialogHolder, openDialog] = useOverlay(Modal, { type: 'holder' })/** 行内操作进行中状态:id + 操作类型(update/remove),保证单例运行 */const [busy, setBusy] = useState<{ id: string, action: 'update' | 'remove' } | null>(null)@@ -74,22 +79,30 @@ export function ConfigPlugin() {}finally {setBusy(null)+ // 插件操作会停掉运行中的服务(即使失败也已被后端停止),这里统一拉起服务并+ // 同步前端运行状态,避免留下「服务已死但界面仍显示运行中」的过期状态。+ void store.harness.restart()}}async function onRemove(id: string, name: string) {if (busy)return- await openDialog({- status: 'danger',- title: t('plugins.remove_confirm_title'),- description: (- <p>- {t('plugins.remove_confirm_desc', { name })}- </p>- ),- confirmText: t('plugins.uninstall'),- })+ try {+ await openDialog({+ status: 'danger',+ title: t('plugins.remove_confirm_title'),+ description: (+ <p>+ {t('plugins.remove_confirm_desc', { name })}+ </p>+ ),+ confirmText: t('plugins.uninstall'),+ })+ }+ catch {+ return+ }setBusy({ id, action: 'remove' })try {await remove.mutateAsync(id)@@ -99,54 +112,28 @@ export function ConfigPlugin() {}finally {setBusy(null)+ // 同上:卸载后统一拉起服务,避免服务被后端停止后前端状态过期。+ void store.harness.restart()}}return (<div>- {/* 面板头:标题 + 说明 */}- <div className="space-y-2 sticky top-0 bg-canvas z-10 pb-3">- <Typography type="h4">- {t('plugins.title')}- </Typography>- <Typography color="muted" type="body-sm">- {t('plugins.panel_tooltip')}- </Typography>- </div>+ <PanelHeader className="sticky top-0 bg-canvas z-10 pb-3" title={t('plugins.title')} description={t('plugins.panel_tooltip')} />{/* 加载 / 失败 / 空态 */}- <If- cond={!loading && error === ''}- else={(- <If- cond={loading}- else={(- <p className="rounded-md border border-danger/30 bg-danger/5 p-3 text-xs text-danger">- {t('plugins.error')}- :- {error}- </p>- )}- >- <div className="flex items-center justify-center gap-2 p-4 text-xs text-muted">- <Spinner size="sm" color="current" />- {t('plugins.loading')}- </div>- </If>- )}- >+ <PanelState loading={loading} error={error}><Ifcond={plugins.length > 0}else={(- <p className="rounded-md border border-line bg-panel2/40 p-4 text-center text-xs text-muted">- {t('plugins.empty')}- </p>+ <Empty>{t('plugins.empty')}</Empty>)}><div className="space-y-3 flex-wrap gap-2">{plugins.map(plugin => (- <Card key={plugin.id} className="rounded-md bg-panel2 py-3">- <Card.Content className="flex flex-row items-center justify-between">+ <Item+ key={plugin.id}+ left={(<div className="min-w-0"><div className="flex min-w-0 items-center gap-1"><If cond={plugin.error != null}>@@ -187,8 +174,9 @@ export function ConfigPlugin() {</TextEllipsis></If></div>-- <div className="flex shrink-0 items-center gap-1.5">+ )}+ right={(+ <>{/* 更新入口仅在插件异常时显示(需求 2:异常插件的修复入口) */}<If cond={plugin.error != null}><Chip@@ -216,13 +204,13 @@ export function ConfigPlugin() {{t('plugins.uninstall')}</span></Chip>- </div>- </Card.Content>- </Card>+ </>+ )}+ />))}</div></If>- </If>+ </PanelState>{dialogHolder}</div>diff --git a/src/components/config-profile.tsx b/src/components/config-profile.tsxindex 0cdff14a..2f94f643 100644--- a/src/components/config-profile.tsx+++ b/src/components/config-profile.tsx@@ -1,5 +1,5 @@import { Plus } from '@gravity-ui/icons'-import { Button, Card, Checkbox, Chip, Description, Input, Label, Typography } from '@heroui/react'+import { Button, Checkbox, Chip, Description, Input, Label } from '@heroui/react'import { useOverlay } from '@overlastic/react'import { useState } from 'react'@@ -8,8 +8,11 @@ import { If } from 'react-if-lite'import { store } from '@/store'import { toast } from '@/utils'import { useDshProfiles } from '../hooks/use-dsh-profiles'-import { Dialog } from './dialog'import { Ellipsis } from './ellipsis'+import { Item } from './item'+import { Modal } from './modal'+import { PanelHeader } from './panel-header'+import { PanelState } from './panel-state'export function ConfigProfile() {/**@@ -22,7 +25,7 @@ export function ConfigProfile() {*/const { profiles, loading, error, createProfile, activateProfile, removeProfile, busy } = useDshProfiles()- const [dialogHolder, openDialog] = useOverlay(Dialog, { type: 'holder' })+ const [dialogHolder, openDialog] = useOverlay(Modal, { type: 'holder' })const { t } = useTranslation()const [creating, setCreating] = useState(false)@@ -32,24 +35,32 @@ export function ConfigProfile() {const target = profiles.find(p => p.id === id)if (!target || target.active || busy)return- await openDialog({- status: 'warning',- title: t('profiles.activate_confirm_title'),- description: (- <p>- {t('profiles.activate_confirm_desc', { name: target.name })}- </p>- ),- })+ try {+ await openDialog({+ status: 'warning',+ title: t('profiles.activate_confirm_title'),+ description: (+ <p>+ {t('profiles.activate_confirm_desc', { name: target.name })}+ </p>+ ),+ })+ }+ catch {+ return+ }try {await activateProfile(id)- toast(t('profiles.activate_toast', { name: target.name }), {+ const key = toast(t('profiles.activate_toast', { name: target.name }), {variant: 'accent',description: t('profiles.activate_restart_hint'),timeout: 10_000,actionProps: {children: t('app.restart'),- onPress: () => store.harness.restart(),+ onPress: () => {+ store.harness.restart()+ toast.close(key)+ },},})}@@ -89,16 +100,21 @@ export function ConfigProfile() {const target = profiles.find(p => p.id === id)if (!target || busy)return- await openDialog({- title: t('profiles.remove_confirm_title'),- status: 'danger',- description: (- <p>- {t('profiles.remove_confirm_desc', { name: target.name })}- </p>- ),- confirmText: t('profiles.remove_confirm'),- })+ try {+ await openDialog({+ title: t('profiles.remove_confirm_title'),+ status: 'danger',+ description: (+ <p>+ {t('profiles.remove_confirm_desc', { name: target.name })}+ </p>+ ),+ confirmText: t('profiles.remove_confirm'),+ })+ }+ catch {+ return+ }try {// 删除成功后列表已移除该档案,UI 本身就有变化,不再弹成功 toastawait removeProfile(id)@@ -111,41 +127,17 @@ export function ConfigProfile() {return (<div className="space-y-3">- {/* 面板头:标题 + 说明 [i] */}- <div className="space-y-2">- <Typography type="h4">- {t('profiles.title')}- </Typography>- <Typography color="muted" type="body-sm">- {t('profiles.tooltip')}- </Typography>- </div>+ <PanelHeader title={t('profiles.title')} description={t('profiles.tooltip')} />{/* 加载 / 失败 / 列表 */}- <If- cond={!loading && error === ''}- else={(- <If- cond={loading}- else={(- <p className="rounded-md border border-danger/30 bg-danger/5 p-3 text-xs text-danger">- {t('plugins.error')}- :- {error}- </p>- )}- >- <div className="flex items-center justify-center gap-2 p-4 text-xs text-muted">- {t('plugins.loading')}- </div>- </If>- )}- >+ <PanelState loading={loading} error={error}><div className="space-y-3 flex-wrap gap-2">{profiles.map(profile => (- <Card key={profile.id} className="bg-panel2 rounded-md py-3 cursor-pointer" onClick={() => activate(profile.id)}>- <Card.Content className="flex flex-row justify-between">- <div className="flex items-center gap-1">+ <Item+ key={profile.id}+ onClick={() => activate(profile.id)}+ left={(+ <><Label className="min-w-0 truncate text-sm font-medium text-ink">{profile.name}</Label>@@ -154,8 +146,10 @@ export function ConfigProfile() {<Ellipsis>{t('profiles.default_desc')}</Ellipsis></Description></If>- </div>- <div className="flex items-center gap-2">+ </>+ )}+ right={(+ <><CheckboxisSelected={profile.active}isDisabled={busy}@@ -182,9 +176,9 @@ export function ConfigProfile() {{t('profiles.remove')}</Chip></If>- </div>- </Card.Content>- </Card>+ </>+ )}+ />))}{/* 新建档案:内联输入 or 触发入口 */}<If@@ -229,7 +223,7 @@ export function ConfigProfile() {</Button></If></div>- </If>+ </PanelState>{dialogHolder}</div>)diff --git a/src/components/desktop-about-dialog.tsx b/src/components/desktop-about-dialog.tsxindex 57d79965..59134793 100644--- a/src/components/desktop-about-dialog.tsx+++ b/src/components/desktop-about-dialog.tsx@@ -6,7 +6,8 @@ import { invoke } from '@tauri-apps/api/core'import { useEffect } from 'react'import { useTranslation } from 'react-i18next'import { useStore } from 'valtio-define'-import { desktopUpdate } from '../store/modules/desktop-update'+import { store } from '@/store'+import { InfoRow } from './info-row'export interface DesktopAboutDialogProps extends PropsWithOverlays {}@@ -16,14 +17,14 @@ export interface DesktopAboutDialogProps extends PropsWithOverlays {}* 使用 overlastic 命令式打开(`useOverlay(DesktopAboutDialog)`),* 打开时通过 store 的 `loadAbout` 拉取信息,关闭由 `disclosure.cancel` 完成。*/-export default function DesktopAboutDialog(props: DesktopAboutDialogProps) {+export function DesktopAboutDialog(props: DesktopAboutDialogProps) {const disclosure = useDisclosure({ props })const { t } = useTranslation()- const { about } = useStore(desktopUpdate)+ const { about } = useStore(store.desktopUpdater)useEffect(() => {if (disclosure.visible)- void desktopUpdate.loadAbout()+ void store.desktopUpdater.loadAbout()}, [disclosure.visible])return (@@ -44,16 +45,8 @@ export default function DesktopAboutDialog(props: DesktopAboutDialogProps) {</Description></div><div className="space-y-1.5 border-t border-line/40 pt-3">- <div className="flex items-center justify-between text-sm">- <span className="text-muted">{t('ui.current_version')}</span>- <span className="text-ink font-medium">{about?.version ?? '-'}</span>- </div>- <div className="flex items-center justify-between text-sm">- <span className="text-muted">{t('about.release_date')}</span>- <span className="text-ink">- {about?.published_at ? formatDate(about.published_at) : '-'}- </span>- </div>+ <InfoRow term={t('ui.current_version')}>{about?.version ?? '-'}</InfoRow>+ <InfoRow term={t('about.release_date')}>{about?.published_at ? formatDate(about.published_at) : '-'}</InfoRow><div className="flex items-center justify-between text-sm border-t border-line/40 pt-2 "><span className="text-muted">{t('about.source_code')}</span><Buttondiff --git a/src/components/desktop-update-dialog.tsx b/src/components/desktop-update-dialog.tsxindex b4c02f68..6a178c9c 100644--- a/src/components/desktop-update-dialog.tsx+++ b/src/components/desktop-update-dialog.tsx@@ -6,7 +6,8 @@ import { useRef } from 'react'import { useTranslation } from 'react-i18next'import { If } from 'react-if-lite'import { useStore } from 'valtio-define'-import { desktopUpdate } from '../store/modules/desktop-update'+import { store } from '@/store'+import { InfoRow } from './info-row'export interface DesktopUpdateDialogProps extends PropsWithOverlays {}@@ -18,10 +19,10 @@ export interface DesktopUpdateDialogProps extends PropsWithOverlays {}* 下载由 store 驱动:对话框内「立即更新」触发 `downloadAndOpen`;* 外部触发(右下角 toast)下载完成并打开安装包后,对话框依据 downloading 回落自动关闭。*/-export default function DesktopUpdateDialog(props: DesktopUpdateDialogProps) {+export function DesktopUpdateDialog(props: DesktopUpdateDialogProps) {const disclosure = useDisclosure({ props })const { t } = useTranslation()- const { updateInfo, downloading, downloadProgress } = useStore(desktopUpdate)+ const { updateInfo, downloading, downloadProgress } = useStore(store.desktopUpdater)const prevDownloadingRef = useRef(false)// 外部触发下载(如右下角 toast「立即更新」)完成并打开安装包后,自动关闭对话框;@@ -33,15 +34,15 @@ export default function DesktopUpdateDialog(props: DesktopUpdateDialogProps) {}, { immediate: true })async function handlePrimary() {- const info = desktopUpdate.updateInfo+ const info = store.desktopUpdater.updateInfoif (!info)returnif (info.downloaded) {- await desktopUpdate.openInstaller(info.path)+ await store.desktopUpdater.openInstaller(info.path)disclosure.cancel()}else {- await desktopUpdate.downloadAndOpen()+ await store.desktopUpdater.downloadAndOpen()}}@@ -57,14 +58,8 @@ export default function DesktopUpdateDialog(props: DesktopUpdateDialogProps) {<Modal.Body className="space-y-3"><If cond={updateInfo != null}><div className="space-y-1.5">- <div className="flex items-center justify-between text-sm">- <span className="text-muted">{t('ui.current_version')}</span>- <span className="text-ink font-medium">{updateInfo?.currentVersion}</span>- </div>- <div className="flex items-center justify-between text-sm">- <span className="text-muted">{t('update.new_version_label')}</span>- <span className="text-ink font-medium">{updateInfo?.version}</span>- </div>+ <InfoRow term={t('ui.current_version')}>{updateInfo?.currentVersion}</InfoRow>+ <InfoRow term={t('update.new_version_label')}>{updateInfo?.version}</InfoRow><If cond={updateInfo?.downloaded}><Description className="text-xs">{t('update.desktop_downloaded')}diff --git a/src/components/core-download-dialog.tsx b/src/components/download-core-dialog.tsxsimilarity index 92%rename from src/components/core-download-dialog.tsxrename to src/components/download-core-dialog.tsxindex 400071fb..7f0750a8 100644--- a/src/components/core-download-dialog.tsx+++ b/src/components/download-core-dialog.tsx@@ -7,7 +7,7 @@ import { listen } from '@tauri-apps/api/event'import { useEffect, useState } from 'react'import { useTranslation } from 'react-i18next'import { If } from 'react-if-lite'-import { ProgressPanel } from './progress-panel'+import { PanelProgress } from './panel-progress'/*** 核心版本下载对话框:复用首次安装(setup)的 `install-progress` 事件流,@@ -15,13 +15,13 @@ import { ProgressPanel } from './progress-panel'** 用法(overlastic holder):* ```tsx- * const [dialog, openDownload] = useOverlay(CoreDownloadDialog, { type: 'holder' })+ * const [dialog, openDownload] = useOverlay(DownloadCoreDialog, { type: 'holder' })* await openDownload({ tag, version, runDownload: (tag) => downloadCore(tag) })* ```* `runDownload` 由调用方注入(通常是 useDshCores 的 downloadCore),对话框负责* 监听进度事件并在结束后 resolve/reject。*/-export interface CoreDownloadDialogProps extends PropsWithOverlays {+export interface DownloadCoreDialogProps extends PropsWithOverlays {/** 要下载的 release tag(如 `dsh-0.1.0-rc.8-32331963388`) */tag: string/** 展示用版本号 */@@ -30,7 +30,7 @@ export interface CoreDownloadDialogProps extends PropsWithOverlays {runDownload: (tag: string) => Promise<HarnessCore>}-export function CoreDownloadDialog(props: CoreDownloadDialogProps) {+export function DownloadCoreDialog(props: DownloadCoreDialogProps) {const disclosure = useDisclosure({ props, delay: 300 })const { t } = useTranslation()@@ -104,7 +104,7 @@ export function CoreDownloadDialog(props: CoreDownloadDialogProps) {else={(<div className="flex flex-col gap-3"><p className="break-all font-mono text-xs leading-[1.7] text-danger">{errorMsg}</p>- <ProgressPanel logs={logs} />+ <PanelProgress logs={logs} /></div>)}>@@ -113,7 +113,7 @@ export function CoreDownloadDialog(props: CoreDownloadDialogProps) {<Spinner size="sm" color="current" /><span className="text-xs text-muted">{t('core.downloading_hint', { version: props.version })}</span></div>- <ProgressPanel percentage={percentage} logs={logs} />+ <PanelProgress percentage={percentage} logs={logs} /></div></If></AlertDialog.Body>diff --git a/src/components/dialog.tsx b/src/components/modal.tsxsimilarity index 94%rename from src/components/dialog.tsxrename to src/components/modal.tsxindex 5d0e8354..3b2e9bea 100644--- a/src/components/dialog.tsx+++ b/src/components/modal.tsx@@ -5,7 +5,7 @@ import { AlertDialog, Button } from '@heroui/react'import { useDisclosure } from '@overlastic/react'import { useTranslation } from 'react-i18next'-export interface DialogProps extends PropsWithOverlays {+export interface ModalProps extends PropsWithOverlays {status: AlertDialogStatustitle?: stringdescription?: ReactNode@@ -14,7 +14,7 @@ export interface DialogProps extends PropsWithOverlays {confirmText?: string}-export function Dialog(props: DialogProps) {+export function Modal(props: ModalProps) {const disclosure = useDisclosure({ props })const { t } = useTranslation()diff --git a/src/i18n/locales/en-US.json b/src/i18n/locales/en-US.jsonindex cbc81fe6..02765ac2 100644--- a/src/i18n/locales/en-US.json+++ b/src/i18n/locales/en-US.json@@ -200,7 +200,7 @@"core.remove_failed": "Failed to uninstall the core version","core.local_missing_hint": "No local core detected. Install @deepseek-ai/dsh globally via npm/pnpm and the desktop will prefer it automatically.","app.dev_env": "Development",- "app.config": "Configuration",+ "app.config": "Application","config.debug": "Debug","config.profiles": "Profiles","config.plugins": "Plugins",diff --git a/src/i18n/locales/zh-CN.json b/src/i18n/locales/zh-CN.jsonindex 53a16e3e..c4ca2901 100644--- a/src/i18n/locales/zh-CN.json+++ b/src/i18n/locales/zh-CN.json@@ -200,7 +200,7 @@"core.remove_failed": "卸载核心版本失败","core.local_missing_hint": "未检测到本地核心。通过 npm/pnpm 全局安装 @deepseek-ai/dsh 后,桌面端将自动优先使用它。","app.dev_env": "开发环境",- "app.config": "应用配置",+ "app.config": "应用","config.debug": "调试","config.profiles": "档案","config.plugins": "插件",diff --git a/src/utils/toast.ts b/src/utils/toast.tsindex d4375674..ba23eab6 100644--- a/src/utils/toast.ts+++ b/src/utils/toast.ts@@ -20,10 +20,10 @@ const placementsKeys = new Map<string, Placement>()export function toast(message: string,- options: HeroUIToastOptions & { placement?: Placement },+ options?: HeroUIToastOptions & { placement?: Placement },) {// 默认右下角;个别调用方需要其他位置时显式传 placement- const { placement = 'bottom end', ...rest } = options+ const { placement = 'bottom end', ...rest } = options || {}const key = queues[placement].add({ title: message, ...rest })placementsKeys.set(key, placement)return key