DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.
refactor(ui): render download and update notices via HeroUI toast
hairyf2b181d1fce9f
diff --git a/src/components/download-toast.tsx b/src/components/download-toast.tsxindex e1529607..6437e5a3 100644--- a/src/components/download-toast.tsx+++ b/src/components/download-toast.tsx@@ -1,48 +1,49 @@+/* eslint-disable react/naming-convention-ref-name */+import { useWatch } from '@hairy/react-lib'import { invoke } from '@tauri-apps/api/core'+import { useRef } from 'react'import { useTranslation } from 'react-i18next'import { useStore } from 'valtio-define'+import { toast } from '@/utils'import { download } from '../store/modules/download'-import { button, toast } from './primitives'-/** 右下角"下载已保存/失败"提示条:状态与关闭操作直接来自 download store */export default function DownloadToast() {const { t } = useTranslation()const { notice } = useStore(download)+ const toastKey = useRef<string | null>(null)- if (!notice) {- return null- }-- const { success, path } = notice-- function revealInFolder(targetPath: string) {- void invoke('reveal_in_folder', { path: targetPath }).catch((err) => {- console.error('[Harness] reveal_in_folder failed:', err)+ useWatch([notice], () => {+ if (!notice)+ return null+ if (toastKey.current)+ toast.close(toastKey.current)+ const { success, path } = notice+ toastKey.current = toast(success ? t('download.saved') : t('download.failed'), {+ description: success && path+ ? (+ <div className="truncate max-w-[300px]">+ {`${t('download.saved_to')}: ${path}`}+ </div>+ )+ : undefined,+ placement: 'bottom end',+ actionProps: success && path+ ? {+ children: t('download.show_in_folder'),+ variant: 'tertiary',+ onPress: () => {+ const close = toast.close+ if (toastKey.current)+ close(toastKey.current)+ void invoke('reveal_in_folder', { path }).catch((err) => {+ console.error('[Harness] reveal_in_folder failed:', err)+ })+ },+ }+ : undefined,+ onClose: () => download.dismiss(),})- }+ })- return (- <div className={toast({ size: 'md', align: 'start' })}>- <div className="min-w-0 flex-1">- <p className="text-[13px] font-semibold text-ink">- {success ? t('download.saved') : t('download.failed')}- </p>- {success && path && (- <p className="mt-0.5 text-xs text-muted break-all truncate">- {t('download.saved_to')}- :- {path}- </p>- )}- </div>- {success && path && (- <button className={button({ tone: 'primary' })} onClick={() => revealInFolder(path)}>- {t('download.show_in_folder')}- </button>- )}- <button className={button({ tone: 'ghost' })} onClick={download.dismiss}>- {t('download.close')}- </button>- </div>- )+ return null}diff --git a/src/components/harness-updater.tsx b/src/components/harness-updater.tsxindex 8bf5c898..f2f9de12 100644--- a/src/components/harness-updater.tsx+++ b/src/components/harness-updater.tsx@@ -1,29 +1,27 @@+import { useWatch } from '@hairy/react-lib'import { useTranslation } from 'react-i18next'import { useStore } from 'valtio-define'+import { toast } from '@/utils'import { updater } from '../store/modules/updater'-import { button, toast } from './primitives'-/** 右下角"发现新版本"提示条:状态与操作直接来自 updater store */export default function HarnessUpdater() {const { t } = useTranslation()const { updateInfo, updating } = useStore(updater)- if (!updateInfo || updating) {- return null- }+ useWatch([updateInfo, updating], () => {+ if (!updateInfo || updating)+ return null+ toast(t('update.available', { tag: updateInfo.tag }), {+ actionProps: {+ children: 'Upgrade',+ onPress: () => toast.clear(),+ variant: 'tertiary',+ },+ placement: 'bottom end',+ description: updateInfo.commit.slice(0, 7),+ variant: 'default',+ })+ })- return (- <div className={toast()}>- <div className="min-w-0 flex-1">- <p className="text-[13px] font-semibold text-ink">{t('update.available', { tag: updateInfo.tag })}</p>- <p className="mt-0.5 text-xs text-muted">{updateInfo.commit.slice(0, 7)}</p>- </div>- <button className={button({ tone: 'primary' })} onClick={updater.handleUpdate}>- {t('update.now')}- </button>- <button className={button({ tone: 'ghost' })} onClick={updater.dismissUpdate}>- {t('update.later')}- </button>- </div>- )+ return null}diff --git a/src/i18n/locales/en-US.json b/src/i18n/locales/en-US.jsonindex 66e3515f..8fd64900 100644--- a/src/i18n/locales/en-US.json+++ b/src/i18n/locales/en-US.json@@ -32,7 +32,6 @@"download.saved_to": "Saved to","download.failed": "Session log download failed","download.show_in_folder": "Open",- "download.close": "Close","errors.service_start_timeout": "DeepSeek Harness startup timeout. Please check whether port {{port}} is occupied or the startup is too slow.","errors.install_verify_failed": "Package downloaded but installation verification failed.",diff --git a/src/i18n/locales/zh-CN.json b/src/i18n/locales/zh-CN.jsonindex 0947f573..99442d16 100644--- a/src/i18n/locales/zh-CN.json+++ b/src/i18n/locales/zh-CN.json@@ -32,7 +32,6 @@"download.saved_to": "已保存到","download.failed": "Session 日志下载失败","download.show_in_folder": "打开",- "download.close": "关闭","errors.service_start_timeout": "DeepSeek Harness 启动超时,请检查端口 {{port}} 是否被占用或启动过慢。","errors.install_verify_failed": "资源包已下载,但安装校验失败。",diff --git a/src/store/modules/updater/store.ts b/src/store/modules/updater/store.tsindex 0136a805..826e5e07 100644--- a/src/store/modules/updater/store.ts+++ b/src/store/modules/updater/store.ts@@ -1,9 +1,9 @@import type { UnlistenFn } from '@tauri-apps/api/event'import type { DshUpdateInfo } from './types'import { invoke } from '@tauri-apps/api/core'+import i18next from 'i18next'import { defineStore } from 'valtio-define'import { harness } from '../harness'-import { setting } from '../setting'/*** 版本更新模块:后台静默检查 + 手动更新安装。@@ -39,7 +39,7 @@ export const updater = defineStore({let unlistenInstall: UnlistenFn | null = nulltry {unlistenInstall = await harness.listenInstallProgress()- harness.prepareInstall(setting.t('status.updating'))+ harness.prepareInstall(i18next.t('status.updating'))await invoke('install_dependencies')await harness.launchAndWait()this.updateInfo = null