DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.
refactor(layout): extract shared components and tidy store modules
hairyf2e68a7ebb7e5
diff --git a/src/components/empty.tsx b/src/components/empty.tsxnew file mode 100644index 00000000..04d50d5d--- /dev/null+++ b/src/components/empty.tsx@@ -0,0 +1,20 @@+import type { ReactNode } from 'react'+import { cn } from 'tailwind-variants'++/**+ * 空态 / 内联提示:带边框的浅底小字提示条。+ * 统一为 config-core「本地核心缺失提示」的样式(p-3、左对齐),+ * 供各配置面板的空列表与补充提示共用。+ */+export interface EmptyProps {+ children?: ReactNode+ className?: string+}++export function Empty({ children, className }: EmptyProps) {+ return (+ <p className={cn('rounded-md border border-line bg-panel2/40 p-3 text-xs text-muted', className)}>+ {children}+ </p>+ )+}diff --git a/src/components/info-row.tsx b/src/components/info-row.tsxnew file mode 100644index 00000000..50832adb--- /dev/null+++ b/src/components/info-row.tsx@@ -0,0 +1,24 @@+import type { ReactNode } from 'react'+import { cn } from 'tailwind-variants'++/**+ * 信息键值行(term|value):两侧对齐的「项目名 + 值」行。+ * 供 config-debug 的运行时信息与「关于 / 检查更新」对话框共用,+ * 值默认用等宽字体(版本号/路径等类代码内容)。+ */+export interface InfoRowProps {+ /** 左侧项名 */+ term: string+ /** 右侧值(可为节点;无则显示 '-' 由调用方决定) */+ children?: ReactNode+ className?: string+}++export function InfoRow({ term, children, className }: InfoRowProps) {+ return (+ <div className={cn('flex items-center justify-between gap-2 text-xs py-0.5', className)}>+ <span className="shrink-0 text-muted font-medium">{term}</span>+ <span className="min-w-0 break-all text-right font-mono text-ink">{children}</span>+ </div>+ )+}diff --git a/src/components/item.tsx b/src/components/item.tsxnew file mode 100644index 00000000..bd394e9b--- /dev/null+++ b/src/components/item.tsx@@ -0,0 +1,38 @@+import type { MouseEventHandler, ReactNode } from 'react'+import { Card } from '@heroui/react'+import { cn } from 'tailwind-variants'++/**+ * 通用列表项:统一 HeroUI「卡片行」骨架(Card + Card.Content 两栏布局),+ * 供各配置面板(plugin / core / profile)与预装插件列表共用,+ * 避免到处重复写 `<Card className="rounded-md bg-panel2 py-3"><Card.Content />`。+ *+ * - left:行左侧主内容(min-w-0,允许截断)+ * - right:行右侧操作区(shrink-0,勾选框 / 按钮 / 状态 chip 等)+ * - footer:主行之后的附加内容(如 config-core 的「本地核心更新」入口)+ * - onClick:传入则整行可点击并显示手型光标+ */+export interface ItemProps {+ left?: ReactNode+ right?: ReactNode+ footer?: ReactNode+ onClick?: MouseEventHandler<HTMLDivElement>+ className?: string+}++export function Item({ left, right, footer, onClick, className }: ItemProps) {+ return (+ <Card+ className={cn('rounded-md bg-panel2 py-3', onClick && 'cursor-pointer', className)}+ onClick={onClick}+ >+ <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">{left}</div>+ <div className="flex shrink-0 items-center gap-1.5">{right}</div>+ </div>+ {footer}+ </Card.Content>+ </Card>+ )+}diff --git a/src/components/logs.tsx b/src/components/logs.tsxnew file mode 100644index 00000000..bed24546--- /dev/null+++ b/src/components/logs.tsx@@ -0,0 +1,49 @@+import type { ReactNode } from 'react'+import { useTranslation } from 'react-i18next'+import { If } from 'react-if-lite'+import { cn } from 'tailwind-variants'++/**+ * 日志面板:带边框的「› + 行」日志容器 + 空日志占位。+ * 供 panel-progress 与 preinstall-setup 的日志控制台共用;+ * 顶部可选 header(如复制按钮)。+ */+export interface LogsProps {+ logs: readonly string[]+ /** 最多展示的行数(默认 100) */+ limit?: number+ /** 顶部自定义头(如复制按钮),渲染在边框内 */+ header?: ReactNode+ /** 外层容器样式类(边框/圆角/布局等) */+ className?: string+ /** 滚动区域样式类(高度等,如 max-h-[184px]) */+ bodyClassName?: string+}++export function Logs({ logs, limit = 100, header, className, bodyClassName }: LogsProps) {+ const { t } = useTranslation()+ return (+ <div className={cn('overflow-hidden rounded-lg border border-line bg-log-bg', className)}>+ {header && (+ <div className="flex items-center justify-end border-b border-line/40 bg-panel2/60 px-2 py-1">+ {header}+ </div>+ )}+ <div+ className={cn('min-h-[112px] overflow-y-auto px-3.5 py-2.5 text-left font-mono text-xs leading-[1.7]', bodyClassName)}+ aria-label={t('ui.install_log')}+ >+ <If cond={logs.length > 0} else={<p className="m-0 text-muted">{t('ui.waiting_logs')}</p>}>+ {logs.slice(-limit).map((line, index) => (+ // 日志行内容可能重复,需以 index 区分 key+ // eslint-disable-next-line react/no-array-index-key+ <p key={`${line}-${index}`} className="m-0 flex gap-2 overflow-hidden text-ellipsis whitespace-nowrap text-log-ink">+ <span className="shrink-0 text-accent select-none">›</span>+ <span className="min-w-0 overflow-hidden text-ellipsis">{line}</span>+ </p>+ ))}+ </If>+ </div>+ </div>+ )+}diff --git a/src/components/panel-header.tsx b/src/components/panel-header.tsxnew file mode 100644index 00000000..ff8e2172--- /dev/null+++ b/src/components/panel-header.tsx@@ -0,0 +1,22 @@+import { Typography } from '@heroui/react'+import { cn } from 'tailwind-variants'++/**+ * 配置面板头部:标题 + 说明。+ * 与 config-plugin / core / profile 的「面板头」一致,+ * className 用于叠加 sticky / 背景等定位类(如 config-plugin 的 sticky 头部)。+ */+export interface PanelHeaderProps {+ title: string+ description: string+ className?: string+}++export function PanelHeader({ title, description, className }: PanelHeaderProps) {+ return (+ <div className={cn('space-y-2', className)}>+ <Typography type="h4">{title}</Typography>+ <Typography color="muted" type="body-sm">{description}</Typography>+ </div>+ )+}diff --git a/src/components/progress-panel.tsx b/src/components/panel-progress.tsxsimilarity index 57%rename from src/components/progress-panel.tsxrename to src/components/panel-progress.tsxindex 20ff1b81..ae9b054f 100644--- a/src/components/progress-panel.tsx+++ b/src/components/panel-progress.tsx@@ -1,4 +1,4 @@-import { useTranslation } from 'react-i18next'+import { Logs } from './logs'const LOG_LIMIT = 5@@ -8,15 +8,14 @@ const LOG_LIMIT = 5* 从 Loadable 中拆出,供首次安装(setup)与核心版本下载对话框共用:* 两处都要展示 `install-progress` 事件驱动的百分比与日志流。*/-export interface ProgressPanelProps {+export interface PanelProgressProps {/** 进度百分比(0-100);不传则不渲染进度条 */percentage?: number/** 日志行;不传则不渲染日志面板(空数组渲染"等待日志"占位) */logs?: readonly string[]}-export function ProgressPanel({ percentage, logs }: ProgressPanelProps) {- const { t } = useTranslation()+export function PanelProgress({ percentage, logs }: PanelProgressProps) {const hasLogs = logs != nullconst showPanel = hasLogs || percentage != null@@ -38,16 +37,7 @@ export function ProgressPanel({ percentage, logs }: ProgressPanelProps) {</div>)}{hasLogs && (- <div className="min-h-[112px] max-h-[184px] overflow-y-auto rounded-lg border border-line bg-log-bg px-3.5 py-2.5 text-left font-mono text-xs leading-[1.7]" aria-label={t('ui.install_log')}>- {(logs!.length ? logs! : [t('ui.waiting_logs')]).slice(-LOG_LIMIT).map((line, index) => (- // 日志行内容可能重复,需以 index 区分 key- // eslint-disable-next-line react/no-array-index-key- <p key={`${line}-${index}`} className="m-0 flex gap-2 overflow-hidden text-ellipsis whitespace-nowrap text-log-ink">- <span className="shrink-0 text-accent select-none">›</span>- <span className="min-w-0 overflow-hidden text-ellipsis">{line}</span>- </p>- ))}- </div>+ <Logs logs={logs!} limit={LOG_LIMIT} bodyClassName="max-h-[184px]" />)}</div>)diff --git a/src/components/panel-state.tsx b/src/components/panel-state.tsxnew file mode 100644index 00000000..6d77ff66--- /dev/null+++ b/src/components/panel-state.tsx@@ -0,0 +1,43 @@+import type { ReactNode } from 'react'+import { Spinner } from '@heroui/react'+import { useTranslation } from 'react-i18next'+import { If } from 'react-if-lite'++/**+ * 列表三态(加载中 / 加载失败 / 正常内容)。+ * 对齐各配置面板(plugin / core / profile)的展示:加载中带 spinner,+ * 失败态复用 plugins.error 文案;error 为空且非 loading 时渲染 children。+ */+export interface PanelStateProps {+ loading: boolean+ error: string+ children?: ReactNode+}++export function PanelState({ loading, error, children }: PanelStateProps) {+ const { t } = useTranslation()+ return (+ <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>+ )}+ >+ {children}+ </If>+ )+}diff --git a/src/components/desktop-updater.tsx b/src/layout/components/desktop-updater.tsxsimilarity index 81%rename from src/components/desktop-updater.tsxrename to src/layout/components/desktop-updater.tsxindex acc06c5a..7b2ee31a 100644--- a/src/components/desktop-updater.tsx+++ b/src/layout/components/desktop-updater.tsx@@ -3,9 +3,9 @@ import { useOverlay } from '@overlastic/react'import { useEffect } from 'react'import { useTranslation } from 'react-i18next'import { useStore } from 'valtio-define'+import { DesktopUpdateDialog } from '@/components/desktop-update-dialog'+import { store } from '@/store'import { toast } from '@/utils'-import { desktopUpdate } from '../store/modules/desktop-update'-import DesktopUpdateDialog from './desktop-update-dialog'/** 桌面端自更新轮询间隔:Rust 侧不再缓存,改为低频轮询以免触发 GitHub 未认证限流(60 次/小时/IP) */const POLL_INTERVAL = 10 * 60_000@@ -15,16 +15,16 @@ const POLL_INTERVAL = 10 * 60_000* 每次实时查询),发现新版本时在右下角弹 toast。* 用户关闭后记住该版本,本次会话不再弹出;新版本出现仍会再次提示。*/-export default function DesktopUpdater() {+export function DesktopUpdater() {const { t } = useTranslation()- const { updateInfo, dismissedTag, downloading } = useStore(desktopUpdate)+ const { updateInfo, dismissedTag, downloading } = useStore(store.desktopUpdater)const openUpdateDialog = useOverlay(DesktopUpdateDialog)// 低频静默检查新版本(实时查询,无本地缓存);后台失败静默,不打扰用户useEffect(() => {- void desktopUpdate.check().catch(() => {})+ void store.desktopUpdater.check().catch(() => {})const timer = setInterval(() => {- void desktopUpdate.check().catch(() => {})+ void store.desktopUpdater.check().catch(() => {})}, POLL_INTERVAL)return () => clearInterval(timer)}, [])@@ -45,7 +45,7 @@ export default function DesktopUpdater() {toast.clear()// 打开更新对话框并开始下载,对话框内展示下载进度(下载完成自动关闭)openUpdateDialog()- void desktopUpdate.downloadAndOpen()+ void store.desktopUpdater.downloadAndOpen()},variant: 'tertiary',},@@ -53,7 +53,7 @@ export default function DesktopUpdater() {placement: 'bottom end',description: t('update.desktop_new'),variant: 'default',- onClose: () => desktopUpdate.dismissToast(),+ onClose: () => store.desktopUpdater.dismissToast(),})}, { immediate: true })diff --git a/src/components/download-toast.tsx b/src/layout/components/download-toast-trigger.tsxsimilarity index 83%rename from src/components/download-toast.tsxrename to src/layout/components/download-toast-trigger.tsxindex 6437e5a3..52247e87 100644--- a/src/components/download-toast.tsx+++ b/src/layout/components/download-toast-trigger.tsx@@ -4,12 +4,12 @@ import { invoke } from '@tauri-apps/api/core'import { useRef } from 'react'import { useTranslation } from 'react-i18next'import { useStore } from 'valtio-define'+import { store } from '@/store'import { toast } from '@/utils'-import { download } from '../store/modules/download'-export default function DownloadToast() {+export function DownloadToast() {const { t } = useTranslation()- const { notice } = useStore(download)+ const { notice } = useStore(store.download)const toastKey = useRef<string | null>(null)useWatch([notice], () => {@@ -32,16 +32,15 @@ export default function DownloadToast() {children: t('download.show_in_folder'),variant: 'tertiary',onPress: () => {- const close = toast.closeif (toastKey.current)- close(toastKey.current)+ toast.close(toastKey.current)void invoke('reveal_in_folder', { path }).catch((err) => {console.error('[Harness] reveal_in_folder failed:', err)})},}: undefined,- onClose: () => download.dismiss(),+ onClose: () => store.download.dismiss(),})})diff --git a/src/components/harness-updater.tsx b/src/layout/components/harness-updater.tsxsimilarity index 64%rename from src/components/harness-updater.tsxrename to src/layout/components/harness-updater.tsxindex 4c0bfb1d..9c53f413 100644--- a/src/components/harness-updater.tsx+++ b/src/layout/components/harness-updater.tsx@@ -1,14 +1,15 @@import { useWatch } from '@hairy/react-lib'import { useStore } from 'valtio-define'-import { updater } from '../store/modules/updater'+import { store } from '@/store'+/** 右下角"发现新版本"提示条:状态与操作直接来自 updater store */-export default function HarnessUpdater() {- const { updateInfo, updating } = useStore(updater)+export function HarnessUpdater() {+ const { updateInfo, updating } = useStore(store.harnessUpdater)useWatch([updateInfo, updating], () => {if (!updateInfo || updating)return null- updater.showToast()+ store.harnessUpdater.showToast()}, { immediate: true })return nulldiff --git a/src/layout/components/loadable.tsx b/src/layout/components/loadable.tsxindex 46cb8b77..75c535c5 100644--- a/src/layout/components/loadable.tsx+++ b/src/layout/components/loadable.tsx@@ -1,7 +1,7 @@import type { ComponentType, ReactNode, SVGProps } from 'react'import { useTranslation } from 'react-i18next'+import { PanelProgress } from '@/components/panel-progress'import { button } from '@/components/primitives'-import { ProgressPanel } from '@/components/progress-panel'/** 图标组件类型(@gravity-ui/icons 均为 SVG 组件) */export type IconComponent = ComponentType<SVGProps<SVGSVGElement>>@@ -37,7 +37,7 @@ export interface LoadableProps {children?: ReactNode}-export default function Loadable({+export function Loadable({icon: Icon,title,subtitle,@@ -85,7 +85,7 @@ export default function Loadable({{showPanel && (<div className="flex w-full flex-col gap-4">- <ProgressPanel percentage={percentage} logs={hasLogs ? logs! : undefined} />+ <PanelProgress percentage={percentage} logs={hasLogs ? logs! : undefined} /></div>)}diff --git a/src/layout/components/navbar.tsx b/src/layout/components/navbar.tsxindex c018caa0..dff4fabb 100644--- a/src/layout/components/navbar.tsx+++ b/src/layout/components/navbar.tsx@@ -15,13 +15,13 @@ import { getCurrentWindow } from '@tauri-apps/api/window'import { useTranslation } from 'react-i18next'import { If } from 'react-if-lite'import { useStore } from 'valtio-define'-import { toast } from '@/utils'+import { ConfigDialog } from '@/components/config-dialog'+import { DesktopAboutDialog } from '@/components/desktop-about-dialog'+import { DesktopUpdateDialog } from '@/components/desktop-update-dialog'import { useDshPlugins } from '@/hooks/use-dsh-plugins'import { useIframeTauri } from '@/hooks/use-iframe-tauri'-import { desktopUpdate } from '@/store/modules/desktop-update'-import { ConfigDialog } from '@/components/config-dialog'-import DesktopAboutDialog from '@/components/desktop-about-dialog'-import DesktopUpdateDialog from '@/components/desktop-update-dialog'+import { store } from '@/store'+import { toast } from '@/utils'/*** 壳层窗口顶部导航栏(44px,常驻):@@ -49,16 +49,16 @@ import DesktopUpdateDialog from '@/components/desktop-update-dialog'*/const TAURI_PLUGIN_ID = 'dsh-tauri'-interface NavbarProps {+export interface NavbarProps {/** 就绪态 iframe;传入时启用左侧导航控制 */iframeRef?: RefObject<HTMLIFrameElement | null>}-export default function Navbar({ iframeRef }: NavbarProps) {+export function Navbar({ iframeRef }: NavbarProps) {const { t } = useTranslation()const { plugins } = useDshPlugins()const { sidebarCollapsed, canGoBack, canGoForward, sendNav } = useIframeTauri(iframeRef)- const { updateInfo } = useStore(desktopUpdate)+ const { updateInfo } = useStore(store.desktopUpdater)const openConfigDialog = useOverlay(ConfigDialog)const openAboutDialog = useOverlay(DesktopAboutDialog)@@ -85,7 +85,7 @@ export default function Navbar({ iframeRef }: NavbarProps) {if (key === 'check-update')void handleCheckUpdate()else if (key === 'about')- openAboutDialog()+ void openAboutDialog().catch(() => {})else if (key === 'copy-run-logs')void copyRunLogs()}@@ -93,9 +93,9 @@ export default function Navbar({ iframeRef }: NavbarProps) {/** 「检查更新」:先检查,有更新才弹框;检查失败提示错误而非「已是最新」 */async function handleCheckUpdate() {try {- const info = await desktopUpdate.check()+ const info = await store.desktopUpdater.check()if (info)- openUpdateDialog()+ void openUpdateDialog().catch(() => {})elsetoast(t('update.up_to_date'), {})}@@ -163,7 +163,7 @@ export default function Navbar({ iframeRef }: NavbarProps) {className="rounded-lg h-6 text-xs px-1.5"size="sm"variant="ghost"- onPress={() => openConfigDialog()}+ onPress={() => void openConfigDialog().catch(() => {})}>{t('app.config')}</Button>diff --git a/src/layout/components/preinstall-setup.tsx b/src/layout/components/preinstall-setup.tsxindex 31f17a33..6cf97f8c 100644--- a/src/layout/components/preinstall-setup.tsx+++ b/src/layout/components/preinstall-setup.tsx@@ -1,13 +1,16 @@import type { PreinstallPlugin } from '@/store/modules/harness'import { CircleInfo, Copy, Xmark } from '@gravity-ui/icons'-import { Button, Card, Checkbox, Chip } from '@heroui/react'+import { Button, Checkbox, Chip, Label, Spinner, Typography } from '@heroui/react'import { invoke } from '@tauri-apps/api/core'import { useEffect, useState } from 'react'import { useTranslation } from 'react-i18next'import { If } from 'react-if-lite'import { useStore } from 'valtio-define'-import { harness } from '@/store/modules/harness'-import { toast } from '@/utils/toast'+import { Empty } from '@/components/empty'+import { Item } from '@/components/item'+import { Logs } from '@/components/logs'+import { store } from '@/store'+import { toast } from '@/utils'/*** 预装插件引导页:首次安装(或老版本升级)后展示推荐插件列表,@@ -15,7 +18,7 @@ import { toast } from '@/utils/toast'* 或跳过;两者都会标记完成并继续启动服务。*/-/** 插件列表的一行:勾选框 + 名称 + 推荐/已安装标签 + 仓库跳转按钮 */+/** 插件列表的一行:名称 + 推荐/已安装标签在左,勾选框 + 仓库跳转按钮在右 */function PluginRow({ plugin, checked, disabled, onToggle, onOpenRepo }: {plugin: PreinstallPluginchecked: boolean@@ -26,50 +29,57 @@ function PluginRow({ plugin, checked, disabled, onToggle, onOpenRepo }: {const { t } = useTranslation()return (- <div className="flex items-center justify-between gap-3 border-b border-line/40 px-4 py-3 last:border-b-0">- <Checkbox- isSelected={checked || plugin.installed}- isDisabled={disabled || plugin.installed}- onChange={isSelected => onToggle(plugin.id, isSelected)}- className="min-w-0 flex-1"- >- <Checkbox.Content className="min-w-0">- <Checkbox.Control className="bg-panel2 rounded-md">- <Checkbox.Indicator className="rounded-md" />- </Checkbox.Control>- <span className="min-w-0">- <span className={`flex min-w-0 items-center gap-2 text-sm font-medium ${plugin.installed ? 'text-muted line-through' : 'text-ink'}`}>- <span className="truncate">{plugin.name}</span>- <If cond={plugin.recommended && !plugin.installed}>- <Chip size="sm" variant="soft" color="success" className="font-medium">- {t('preinstall.recommend')}- </Chip>- </If>- <If cond={plugin.fix && !plugin.installed}>- <Chip size="sm" variant="soft" color="warning" className="font-medium">- {t('preinstall.fix')}- </Chip>- </If>- <If cond={plugin.installed}>- <Chip size="sm" variant="soft" color="success" className="font-medium">- {t('preinstall.installed')}- </Chip>- </If>- </span>- </span>- </Checkbox.Content>- </Checkbox>- <Button- isIconOnly- size="sm"- variant="ghost"- className="shrink-0 rounded-md"- aria-label={t('preinstall.open_repo', { name: plugin.name })}- onPress={() => onOpenRepo(plugin.id)}- >- <CircleInfo className="size-4" />- </Button>- </div>+ <Item+ left={(+ <>+ <Label className={`min-w-0 truncate text-sm font-medium ${plugin.installed ? 'text-muted line-through' : 'text-ink'}`}>+ {plugin.name}+ </Label>+ <If cond={plugin.recommended && !plugin.installed}>+ <Chip size="sm" variant="soft" color="success" className="shrink-0 font-medium">+ {t('preinstall.recommend')}+ </Chip>+ </If>+ <If cond={plugin.fix && !plugin.installed}>+ <Chip size="sm" variant="soft" color="warning" className="shrink-0 font-medium">+ {t('preinstall.fix')}+ </Chip>+ </If>+ <If cond={plugin.installed}>+ <Chip size="sm" variant="soft" color="success" className="shrink-0 font-medium">+ {t('preinstall.installed')}+ </Chip>+ </If>+ </>+ )}+ right={(+ <>+ <Checkbox+ isSelected={checked || plugin.installed}+ isDisabled={disabled || plugin.installed}+ onChange={isSelected => onToggle(plugin.id, isSelected)}+ className="shrink-0"+ aria-label={plugin.name}+ >+ <Checkbox.Content>+ <Checkbox.Control>+ <Checkbox.Indicator />+ </Checkbox.Control>+ </Checkbox.Content>+ </Checkbox>+ <Button+ isIconOnly+ size="sm"+ variant="ghost"+ className="size-6 shrink-0 rounded-md"+ aria-label={t('preinstall.open_repo', { name: plugin.name })}+ onPress={() => onOpenRepo(plugin.id)}+ >+ <CircleInfo className="size-4" />+ </Button>+ </>+ )}+ />)}@@ -89,49 +99,36 @@ function LogPanel({ logs }: { logs: readonly string[] }) {}return (- <div className="overflow-hidden rounded-lg border border-line bg-log-bg">- {/* 面板头:复制日志(右上角) */}- <div className="flex items-center justify-end border-b border-line/40 bg-panel2/60 px-2 py-1">+ <Logs+ logs={logs}+ limit={100}+ bodyClassName="max-h-[240px]"+ header={(<Buttonsize="sm"variant="ghost"isIconOnly- className="size-6 min-w-6 rounded-md"+ className="size-6 shrink-0 rounded-md"aria-label={t('buttons.copy')}onPress={copyLogs}><Copy className="size-3.5" /></Button>- </div>- <div- className="max-h-[240px] min-h-[112px] overflow-y-auto px-3.5 py-2.5 text-left font-mono text-xs leading-[1.7]"- aria-label={t('ui.install_log')}- >- <If cond={logs.length > 0} else={<p className="m-0 text-load-muted">{t('ui.waiting_logs')}</p>}>- {logs.slice(-100).map((line, index) => (- // 日志行内容可能重复,以 index 区分 key- // eslint-disable-next-line react/no-array-index-key- <p key={`${line}-${index}`} className="m-0 flex gap-2 overflow-hidden text-ellipsis whitespace-nowrap text-log-ink">- <span className="shrink-0 text-accent select-none">›</span>- <span className="min-w-0 overflow-hidden text-ellipsis">{line}</span>- </p>- ))}- </If>- </div>- </div>+ )}+ />)}-export default function PreinstallSetup() {+export function PreinstallSetup() {const { t } = useTranslation()- const { preinstall } = useStore(harness)+ const { preinstall } = useStore(store.harness)// 用户手动调整后的选择(一旦交互即接管默认勾选)const [selected, setSelected] = useState<Set<string>>(() => new Set())const [touched, setTouched] = useState(false)// 进入引导页时拉取插件列表useEffect(() => {- void harness.loadPreinstallPlugins()+ void store.harness.loadPreinstallPlugins()}, [])// 默认勾选:未安装的推荐插件 +「修复」类项 + 无 chip 但标记默认勾选的项(如 dsh-notification)。@@ -162,11 +159,11 @@ export default function PreinstallSetup() {}function handleConfirm() {- void harness.confirmPreinstall([...effectiveSelected])+ void store.harness.confirmPreinstall([...effectiveSelected])}function handleSkip() {- void harness.skipPreinstall()+ void store.harness.skipPreinstall()}// 可选中的插件(未安装项)勾选数,用于禁用"确定"@@ -178,8 +175,8 @@ export default function PreinstallSetup() {<div className="flex h-full w-full items-center justify-center bg-canvas"><div className="flex w-[min(560px,88vw)] flex-col gap-5"><header className="flex flex-col items-center gap-1.5 text-center">- <h1 className="text-base font-semibold tracking-[0.08em] text-load-ink">{t('preinstall.title')}</h1>- <p className="max-w-[440px] text-xs leading-5 text-load-muted">{t('preinstall.subtitle')}</p>+ <Typography type="h4">{t('preinstall.title')}</Typography>+ <Typography color="muted" type="body-sm" className="max-w-[440px]">{t('preinstall.subtitle')}</Typography></header><If@@ -191,11 +188,11 @@ export default function PreinstallSetup() {else={(<>{/* 插件列表 */}- <Card className="p-0 rounded-md">+ <div className="space-y-3 flex-wrap gap-2"><Ifcond={preinstall.plugins.length > 0}else={(- <p className="text-center text-xs text-load-muted">{t('preinstall.empty')}</p>+ <Empty>{t('preinstall.empty')}</Empty>)}>{preinstall.plugins.map(plugin => (@@ -209,15 +206,15 @@ export default function PreinstallSetup() {/>))}</If>- </Card>+ </div>{/* 操作区:跳过 / 确定 */}<div className="flex items-center justify-end gap-2">- <Button className="rounded-md" size="sm" variant="tertiary" onPress={handleSkip} isDisabled={installing}>+ <Button className="h-8 rounded-md" size="sm" variant="tertiary" onPress={handleSkip} isDisabled={installing}>{t('preinstall.skip')}</Button><Button- className="rounded-md"+ className="h-8 rounded-md"size="sm"variant="primary"onPress={handleConfirm}@@ -231,19 +228,19 @@ export default function PreinstallSetup() {>{/* 安装失败:错误信息 + 日志 + 操作 */}<div className="flex flex-col gap-2.5">- <div className="flex flex-col gap-2 rounded-lg border border-danger/30 bg-danger/5 px-3.5 py-3">+ <div className="flex flex-col gap-2 rounded-md border border-danger/30 bg-danger/5 p-3"><p className="text-xs font-medium text-danger">{t('preinstall.failed')}</p>- <p className="max-h-[120px] overflow-y-auto break-all font-mono text-[11px] leading-relaxed text-load-muted">+ <p className="max-h-[120px] overflow-y-auto break-all font-mono text-[11px] leading-relaxed text-muted">{preinstall.error}</p></div><LogPanel logs={preinstall.logs} /><div className="flex items-center justify-end gap-2">- <Button className="rounded-md" size="sm" variant="tertiary" onPress={handleSkip} isDisabled={installing}>+ <Button className="h-8 rounded-md" size="sm" variant="tertiary" onPress={handleSkip} isDisabled={installing}>{t('preinstall.skip')}</Button><Button- className="rounded-md"+ className="h-8 rounded-md"size="sm"variant="primary"onPress={handleConfirm}@@ -256,20 +253,20 @@ export default function PreinstallSetup() {</If>)}>- {/* 安装中:与 Loadable 加载页一致的指示样式(spinner 在上、文案在下,图标旁不加文字) */}+ {/* 安装中:spinner 在上、文案在下,图标旁不加文字 */}<div className="flex flex-col gap-2.5"><div className="flex flex-col items-center gap-3">- <span className="h-5 w-5 animate-load-spin rounded-full border-2 border-load-ring border-t-load-ink" />- <p className="text-xs leading-[18px] text-load-muted">{t('preinstall.installing')}</p>+ <Spinner size="md" color="current" />+ <p className="text-xs text-muted">{t('preinstall.installing')}</p></div><LogPanel logs={preinstall.logs} />{/* 取消安装:网络抖动/限流(429)时可能长时间卡在重试,给用户退出入口 */}<div className="flex items-center justify-center"><Button- className="rounded-md"+ className="h-8 rounded-md"size="sm"variant="tertiary"- onPress={harness.cancelPreinstall}+ onPress={store.harness.cancelPreinstall}isDisabled={preinstall.cancelling}><Xmark className="size-3.5" />diff --git a/src/layout/components/setup.tsx b/src/layout/components/setup.tsxindex 04cda54a..63e0e7a9 100644--- a/src/layout/components/setup.tsx+++ b/src/layout/components/setup.tsx@@ -1,10 +1,10 @@-import type { SetupStatus } from '@/store/modules/harness'import type { IconComponent } from './loadable'+import type { SetupStatus } from '@/store/modules/harness'import { ArrowDownToLine, CircleCheck, CircleExclamation, CircleInfo, Magnifier, Rocket } from '@gravity-ui/icons'import { useTranslation } from 'react-i18next'import { useStore } from 'valtio-define'-import { harness } from '@/store/modules/harness'-import Loadable from './loadable'+import { store } from '@/store'+import { Loadable } from './loadable'// 各阶段对应不同图标,保持与 logo 一致的黑白中性色调const STATUS_ICONS: Record<SetupStatus, IconComponent> = {@@ -21,9 +21,9 @@ const STATUS_ICONS: Record<SetupStatus, IconComponent> = {* 视觉与官方 web shell 的 boot 加载页(AppRoot)一致。* 状态与重试动作直接从 harness store 读取,不再接收 props。*/-export default function Setup() {+export function Setup() {const { t } = useTranslation()- const { status, installer, errorMsg, errorLogs, pluginConflictHint } = useStore(harness)+ const { status, installer, errorMsg, errorLogs, pluginConflictHint } = useStore(store.harness)const error = status === 'error'const installing = status === 'installing'const heading = error ? t('status.error') : installer.title || t('status.installing')@@ -42,7 +42,7 @@ export default function Setup() {percentage={installing ? installer.percentage : undefined}logs={logs}errorMsg={error ? errorMsg : undefined}- onRetry={error ? harness.boot : undefined}+ onRetry={error ? store.harness.boot : undefined}>{error && pluginConflictHint && (<p className="m-0 text-xs leading-[18px] break-all text-load-muted">{pluginConflictHint}</p>diff --git a/src/layout/components/sidebar-toggle.tsx b/src/layout/components/sidebar-toggle.tsxdeleted file mode 100644index e6f5d3b0..00000000--- a/src/layout/components/sidebar-toggle.tsx+++ /dev/null@@ -1,34 +0,0 @@-import { Wrench } from '@gravity-ui/icons'-import { Button } from '@heroui/react'-import { useTranslation } from 'react-i18next'-import { useStore } from 'valtio-define'-import { setting } from '@/store/modules/setting'-import { updater } from '@/store/modules/updater'--/**- * 右下角侧边栏展开按钮:显隐与位置都从 store 读取。- * 用 HeroUI 图标按钮实现,lifted 时上移避免与提示条重叠。- */-export default function SidebarToggle() {- const { t } = useTranslation()- const { sidebarOpen } = useStore(setting)- const { updateInfo, updating } = useStore(updater)-- // 侧边栏已展开时隐藏,避免与抽屉重叠- if (sidebarOpen) {- return null- }-- const lifted = updateInfo !== null && !updating-- return (- <Button- isIconOnly- aria-label={t('app.expand_sidebar')}- onPress={setting.toggleSidebar}- className={`fixed right-4 z-20 flex size-9 rounded-full border border-line bg-panel/80 text-ink shadow-lg backdrop-blur-md hover:bg-panel-hover ${lifted ? 'bottom-[84px]' : 'bottom-4'}`}- >- <Wrench className="size-4" />- </Button>- )-}diff --git a/src/layout/components/harness-webview.tsx b/src/layout/components/webview.tsxsimilarity index 87%rename from src/layout/components/harness-webview.tsxrename to src/layout/components/webview.tsxindex be48967a..b45b267e 100644--- a/src/layout/components/harness-webview.tsx+++ b/src/layout/components/webview.tsx@@ -4,11 +4,11 @@ import { useRef } from 'react'import { useTranslation } from 'react-i18next'import { useStore } from 'valtio-define'import { useIframeShim } from '@/hooks/use-iframe-shim'-import { harness } from '@/store/modules/harness'-import Loadable from './loadable'-import Navbar from './navbar'-import PreinstallSetup from './preinstall-setup'-import Setup from './setup'+import { store } from '@/store'+import { Loadable } from './loadable'+import { Navbar } from './navbar'+import { PreinstallSetup } from './preinstall-setup'+import { Setup } from './setup'/*** 主区域视图:壳层导航栏(Navbar)常驻顶部,@@ -16,7 +16,7 @@ import Setup from './setup'* (挂载后加载职责交给 dsh 应用内官方 boot 页,避免两套 loading 叠加)。* 状态与方法全部来自 harness store,不再接收 props。*/-export default function HarnessWebview() {+export function Webview() {const { t } = useTranslation()const {status,@@ -25,7 +25,7 @@ export default function HarnessWebview() {iframeKey,iframeSrc,serviceUrl,- } = useStore(harness)+ } = useStore(store.harness)const iframeRef = useRef<HTMLIFrameElement>(null)@@ -80,8 +80,8 @@ export default function HarnessWebview() {src={iframeSrc}allow="clipboard-read; clipboard-write; fullscreen"sandbox="allow-same-origin allow-scripts allow-popups allow-forms allow-modals allow-downloads allow-storage-access-by-user-activation"- onLoad={harness.markIframeLoaded}- onError={harness.markIframeError}+ onLoad={store.harness.markIframeLoaded}+ onError={store.harness.markIframeError}title={t('app.open_editor')}/>)@@ -95,7 +95,7 @@ export default function HarnessWebview() {icon={CircleExclamation}title={t('ui.iframe_error')}errorMsg={t('ui.ensure_running', { url: serviceUrl })}- onRetry={harness.refreshIframe}+ onRetry={store.harness.refreshIframe}/></div>)}diff --git a/src/layout/index.tsx b/src/layout/index.tsxindex 042c8db5..dda3f4e4 100644--- a/src/layout/index.tsx+++ b/src/layout/index.tsx@@ -1,11 +1,11 @@import { useEffect } from 'react'import { useStore } from 'valtio-define'-import DesktopUpdater from '../components/desktop-updater'-import DownloadToast from '../components/download-toast'-import HarnessUpdater from '../components/harness-updater'-import HarnessWebview from './components/harness-webview'import { useDshTheme } from '../hooks/use-dsh-theme'import { store } from '../store'+import { DesktopUpdater } from './components/desktop-updater'+import { DownloadToast } from './components/download-toast-trigger'+import { HarnessUpdater } from './components/harness-updater'+import { Webview } from './components/webview'import '../i18n'/*** 应用根布局:只负责首次启动与整体壳层结构。@@ -14,7 +14,7 @@ import '../i18n'* 弹出层(关于 / 检查更新 / 应用配置)统一由 overlastic 命令式打开,* 仅在需要时挂载,不常驻渲染。*/-export default function App() {+export function App() {useDshTheme()const { status } = useStore(store.harness)// 首次挂载自动启动 harness(store 内部对 StrictMode 重复挂载去重)@@ -24,7 +24,7 @@ export default function App() {return (<div className="flex h-screen w-screen">- <HarnessWebview />+ <Webview />{status === 'ready' && <HarnessUpdater />}{status === 'ready' && <DownloadToast />}<DesktopUpdater />diff --git a/src/main.tsx b/src/main.tsxindex f3f1afca..19838d9a 100644--- a/src/main.tsx+++ b/src/main.tsx@@ -2,9 +2,9 @@ import { OverlaysProvider } from '@overlastic/react'import { QueryClientProvider } from '@tanstack/react-query'import React from 'react'import ReactDOM from 'react-dom/client'-import App from './layout'import { ToastProvider } from './components/toast-provider'import { queryClient } from './config/client'+import { App } from './layout'import '@/utils/logger'import './style/main.css'diff --git a/src/store/index.ts b/src/store/index.tsindex 6e94eaa2..9139e4a8 100644--- a/src/store/index.ts+++ b/src/store/index.ts@@ -1,35 +1,14 @@-import { desktopUpdate } from './modules/desktop-update'+import { desktopUpdater } from './modules/desktop-updater'import { download } from './modules/download'import { harness } from './modules/harness'+import { harnessUpdater } from './modules/harness-updater'import { setting } from './modules/setting'-import { updater } from './modules/updater'/** 全局 store 聚合(参考 damn-reports 的组织方式:模块各自独立,聚合统一出口) */export const store = {harness,- updater,+ harnessUpdater,download,setting,- desktopUpdate,+ desktopUpdater,}--export { desktopUpdate } from './modules/desktop-update'-export type {- DesktopAboutInfo,- DesktopDownloadProgress,- DesktopUpdateInfo,-} from './modules/desktop-update'-export { download } from './modules/download'-export type { DownloadFinishedPayload } from './modules/download'-export { harness } from './modules/harness'-export type {- InstallerState,- InstallProgress,- PreinstallLogPayload,- PreinstallPlugin,- SetupStatus,- SidebarBusyAction,-} from './modules/harness'-export { setting } from './modules/setting'-export { updater } from './modules/updater'-export type { DshUpdateInfo } from './modules/updater'diff --git a/src/store/modules/desktop-update/index.ts b/src/store/modules/desktop-updater/index.tssimilarity index 70%rename from src/store/modules/desktop-update/index.tsrename to src/store/modules/desktop-updater/index.tsindex 7771cf93..98c33722 100644--- a/src/store/modules/desktop-update/index.ts+++ b/src/store/modules/desktop-updater/index.ts@@ -1,4 +1,4 @@-export { desktopUpdate } from './store'+export { desktopUpdater } from './store'export type {DesktopAboutInfo,DesktopDownloadProgress,diff --git a/src/store/modules/desktop-update/store.ts b/src/store/modules/desktop-updater/store.tssimilarity index 92%rename from src/store/modules/desktop-update/store.tsrename to src/store/modules/desktop-updater/store.tsindex 21ff95c2..3441fa51 100644--- a/src/store/modules/desktop-update/store.ts+++ b/src/store/modules/desktop-updater/store.ts@@ -27,7 +27,7 @@ function readDismissedTag(): string {}}-export const desktopUpdate = defineStore({+export const desktopUpdater = defineStore({state: () => ({/** 发现的新版本信息(null 表示暂无) */updateInfo: null as DesktopUpdateInfo | null,@@ -91,7 +91,7 @@ export const desktopUpdate = defineStore({this.about = await invoke<DesktopAboutInfo>('get_desktop_about')}catch (err) {- console.warn('[DesktopUpdate] failed to load about info:', err)+ console.warn('[DesktopUpdater] failed to load about info:', err)}}return this.about@@ -123,7 +123,7 @@ export const desktopUpdate = defineStore({await this.openInstaller(updated.path)}catch (err) {- console.error('[DesktopUpdate] download failed:', err)+ console.error('[DesktopUpdater] download failed:', err)toast(i18next.t('update.desktop_download_failed'), {variant: 'danger',placement: 'bottom end',@@ -145,7 +145,7 @@ export const desktopUpdate = defineStore({})}catch (err) {- console.error('[DesktopUpdate] failed to open installer:', err)+ console.error('[DesktopUpdater] failed to open installer:', err)toast(i18next.t('update.desktop_open_failed'), {variant: 'danger',placement: 'bottom end',@@ -157,7 +157,7 @@ export const desktopUpdate = defineStore({// 模块级监听下载进度(应用生命周期内常驻)listen<DesktopDownloadProgress>('desktop-update-progress', (e) => {- desktopUpdate.downloadProgress = e.payload.percentage+ desktopUpdater.downloadProgress = e.payload.percentage// 后端附加提示(如主源失败已切换镜像源重试)→ toast 告知用户if (e.payload.message) {toast(e.payload.message, {@@ -166,5 +166,5 @@ listen<DesktopDownloadProgress>('desktop-update-progress', (e) => {})}}).catch((err) => {- console.error('[DesktopUpdate] failed to listen desktop-update-progress:', err)+ console.error('[DesktopUpdater] failed to listen desktop-update-progress:', err)})diff --git a/src/store/modules/desktop-update/types.ts b/src/store/modules/desktop-updater/types.tssimilarity index 100%rename from src/store/modules/desktop-update/types.tsrename to src/store/modules/desktop-updater/types.tsdiff --git a/src/store/modules/updater/index.ts b/src/store/modules/harness-updater/index.tssimilarity index 52%rename from src/store/modules/updater/index.tsrename to src/store/modules/harness-updater/index.tsindex 22de3ee8..7e87e42c 100644--- a/src/store/modules/updater/index.ts+++ b/src/store/modules/harness-updater/index.ts@@ -1,2 +1,2 @@-export { updater } from './store'+export { harnessUpdater } from './store'export type { DshUpdateInfo } from './types'diff --git a/src/store/modules/updater/store.ts b/src/store/modules/harness-updater/store.tssimilarity index 97%rename from src/store/modules/updater/store.tsrename to src/store/modules/harness-updater/store.tsindex 6646fcb7..c6f830f2 100644--- a/src/store/modules/updater/store.ts+++ b/src/store/modules/harness-updater/store.ts@@ -10,7 +10,7 @@ import { harness } from '../harness'* 版本更新模块:后台静默检查 + 手动更新安装。* 安装进度与启动等待复用 harness 模块的能力,本模块只负责"有没有新版本"的决策。*/-export const updater = defineStore({+export const harnessUpdater = defineStore({state: () => ({/** 发现的新版本信息(null 表示暂无/已被忽略) */updateInfo: null as DshUpdateInfo | null,@@ -87,7 +87,7 @@ export const updater = defineStore({children: t('update.now'),onPress: () => {toast.clear()- void updater.handleUpdate()+ void this.handleUpdate()},variant: 'tertiary',},diff --git a/src/store/modules/updater/types.ts b/src/store/modules/harness-updater/types.tssimilarity index 100%rename from src/store/modules/updater/types.tsrename to src/store/modules/harness-updater/types.tsdiff --git a/src/store/modules/harness/store.ts b/src/store/modules/harness/store.tsindex bd9f2e8f..bc42b0f7 100644--- a/src/store/modules/harness/store.ts+++ b/src/store/modules/harness/store.ts@@ -8,12 +8,13 @@ import type {SetupStatus,SidebarBusyAction,} from './types'+import { emitter } from '@hairy/react-lib'import { invoke } from '@tauri-apps/api/core'import { listen } from '@tauri-apps/api/event'import i18next from 'i18next'import { defineStore } from 'valtio-define'import { queryClient } from '@/config/client'-import { updater } from '../updater'+import { harnessUpdater } from '../harness-updater'const MAX_RETRIES = 8const IFRAME_LOAD_TIMEOUT = 20000@@ -320,7 +321,7 @@ export const harness = defineStore({return// 已安装时后台静默检查新版,发现后提示用户if (config.installed) {- void updater.checkForUpdate()+ void harnessUpdater.checkForUpdate()}}catch (err) {@@ -356,6 +357,7 @@ export const harness = defineStore({returnthis.busyAction = 'restart'try {+ emitter.emit('config:dialog:hidden')await invoke('shutdown_harness')}catch (err) {@@ -376,6 +378,8 @@ export const harness = defineStore({if (this.busyAction)returnthis.busyAction = 'shutdown'+ // 停止服务后应用回到「已停止」态,配置弹窗已无意义,与 restart 一致地关闭它+ emitter.emit('config:dialog:hidden')try {await invoke('shutdown_harness')}@@ -512,7 +516,7 @@ export const harness = defineStore({/** 预装引导结束后的收尾:拉起服务等待就绪,并静默检查更新 */async continueAfterPreinstall() {await this.launchAndWait()- void updater.checkForUpdate()+ void harnessUpdater.checkForUpdate()},/**@@ -522,6 +526,7 @@ export const harness = defineStore({async openPreinstall() {if (this.preinstall.installing)return+ emitter.emit('config:dialog:hidden')this.preinstall.error = ''this.preinstall.logs = []this.status = 'preinstall'