Skip to content

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

feat(config): add config dialog for core/plugin/profile settings

hairyf391dbe5ff28a
diff --git a/src/components/config-core.tsx b/src/components/config-core.tsx
index 95bc8925..be1f90e4 100644
--- a/src/components/config-core.tsx
+++ b/src/components/config-core.tsx
@@ -1,4 +1,164 @@
+import { Card, Checkbox, Chip, Description, Label, Typography } from '@heroui/react'
+import { useOverlay } from '@overlastic/react'
+import { useState } from 'react'
+import { useTranslation } from 'react-i18next'
+
+import { If } from 'react-if-lite'
+import { toast } from '@/utils'
+import { Dialog } from './dialog'
+
+/** 版本来源:local = 本机用 CLI 安装;app = 由桌面端管理 */
+export type HarnessSource = 'local' | 'app'
+
+/** Harness Core 版本行 */
+export interface HarnessVersion {
+ id: string
+ version: string
+ source: HarnessSource
+ /** 本地是否已下载/存在(可卸载)。未下载过的版本没有卸载入口。 */
+ present: boolean
+ /** 当前正在使用的版本 */
+ active: boolean
+ /** 额外说明的 i18n key(可选) */
+ hint?: string
+}
+
+/**
+ * 「Harness Core」面板:管理各版本引擎副本,切换使用 / 卸载不再需要的版本。
+ *
+ * 与「档案」面板保持一致:`Card` 行布局 + `Typography` 标题、右侧 `Checkbox`
+ * 表示当前使用版本,切换/卸载用 `Dialog`(`useOverlay` holder)二次确认。
+ *
+ * 注意:后端尚无 get_harness_versions / set_harness_version / uninstall_harness_version
+ * 命令,按需求约定「仅前端 + 内置示范数据」在此用本地状态驱动 UI;
+ * 后端命令落地后用真实查询与接口替换本地更新逻辑。
+ */
+const DEMO_VERSIONS: HarnessVersion[] = [
+ { id: 'local-rc7', version: 'v0.1.0-rc.7', source: 'local', present: true, active: false, hint: 'core.local_hint' },
+ { id: 'app-rc8', version: 'v0.1.0-rc.8', source: 'app', present: true, active: true },
+ { id: 'app-rc7', version: 'v0.1.0-rc.7', source: 'app', present: false, active: false },
+ { id: 'app-rc6', version: 'v0.1.0-rc.6', source: 'app', present: false, active: false },
+]
+
export function ConfigCore() {
- // TODO
- return null
+ const [dialogHolder, openDialog] = useOverlay(Dialog, { type: 'holder' })
+
+ const { t } = useTranslation()
+ const [versions, setVersions] = useState<HarnessVersion[]>(DEMO_VERSIONS)
+
+ /** 当前可卸载(已下载)的版本数:仅剩一个时隐藏卸载入口 */
+ const presentCount = versions.filter(v => v.present).length
+
+ async function activate(version: HarnessVersion) {
+ if (version.active)
+ return
+ await openDialog({
+ status: 'warning',
+ title: t('core.switch_confirm_title'),
+ description: (
+ <p>
+ {t('core.switch_confirm_desc', { version: version.version })}
+ </p>
+ ),
+ })
+ setVersions(prev => prev.map(v => ({ ...v, active: v.id === version.id })))
+ toast(t('core.activate_toast', { version: version.version }), {})
+ }
+
+ async function remove(version: HarnessVersion) {
+ await openDialog({
+ status: 'danger',
+ title: t('core.remove_confirm_title'),
+ description: (
+ <p>
+ {t('core.remove_confirm_desc', { version: version.version })}
+ </p>
+ ),
+ confirmText: t('core.uninstall'),
+ })
+ // 卸载后整行移除,保证「本地条目删除后即消失」
+ setVersions(prev => prev.filter(v => v.id !== version.id))
+ toast(t('core.uninstalled_toast', { version: version.version }), {})
+ }
+
+ 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>
+
+ <div className="space-y-3 flex-wrap gap-2">
+ {versions.map(version => (
+ <Card
+ key={version.id}
+ className="cursor-pointer rounded-md bg-[#f5f5f5] py-3"
+ onClick={() => activate(version)}
+ >
+ <Card.Content 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">
+ {version.version}
+ </Label>
+ <If cond={version.source === 'local'}>
+ <Chip size="sm" variant="soft" color="accent" className="shrink-0 font-medium">
+ {t('core.local')}
+ </Chip>
+ </If>
+ <If cond={version.hint != null}>
+ <Description className="min-w-0 text-xs text-muted">
+ {t(version.hint as string)}
+ </Description>
+ </If>
+ <If cond={!version.present && version.hint == null}>
+ <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">
+ <Checkbox
+ isSelected={version.active}
+ aria-label={version.version}
+ className="shrink-0"
+ >
+ <Checkbox.Content>
+ <Checkbox.Control>
+ <Checkbox.Indicator />
+ </Checkbox.Control>
+ </Checkbox.Content>
+ </Checkbox>
+ <If cond={version.present && presentCount > 1}>
+ <Chip
+ className="rounded-md"
+ variant="primary"
+ color="danger"
+ size="sm"
+ onClick={(event) => {
+ event.stopPropagation()
+ void remove(version)
+ }}
+ >
+ {t('core.uninstall')}
+ </Chip>
+ </If>
+ </div>
+ </Card.Content>
+ </Card>
+ ))}
+ {/* 未下载、无卸载入口的兜底提示 */}
+ <If cond={versions.length === 0}>
+ <p className="p-4 text-center text-xs text-muted">{t('plugins.empty')}</p>
+ </If>
+ </div>
+
+ {dialogHolder}
+ </div>
+ )
}
diff --git a/src/components/config-dialog.tsx b/src/components/config-dialog.tsx
index 8b743349..909e3eae 100644
--- a/src/components/config-dialog.tsx
+++ b/src/components/config-dialog.tsx
@@ -42,14 +42,14 @@ export function ConfigDialog() {
<Modal isOpen={disclosure.visible} onOpenChange={disclosure.confirm}>
<Modal.Backdrop>
<Modal.Container size="lg">
- <Modal.Dialog className="w-[800px] max-w-[calc(100vw-48px)]">
+ <Modal.Dialog className="w-[800px] max-w-[calc(100vw-48px)] pr-2.5">
<Modal.CloseTrigger />
<Modal.Header className="mb-3">
<Modal.Heading>
应用配置
</Modal.Heading>
</Modal.Header>
- <Modal.Body className="flex gap-6">
+ <Modal.Body className="flex gap-6 pr-0">
<aside className="w-[164px]">
<nav className="flex flex-col gap-2 w-full">
{navs.map((item) => {
@@ -59,21 +59,18 @@ export function ConfigDialog() {
key={item.value}
onClick={() => setActiveTab(item.value)}
className={cn(
- 'text-foreground h-[40px] rounded-md flex items-center gap-2 py-[9px] px-[16px] hover:bg-[#ebeef2] cursor-pointer',
- isActive ? 'bg-[#ebeef2]' : '',
+ 'text-foreground h-[40px] rounded-md flex items-center gap-2 py-[9px] px-[16px] hover:bg-background-secondary cursor-pointer',
+ isActive ? 'bg-background-secondary' : '',
)}
>
<item.icon className="w-5 h-5 mr-2" />
- <div className="flex flex-col flex-1 items-start">
- <span>{item.title}</span>
- {/* <span className="text-[10px] text-foreground-2 -mt-1 text-muted">{item.label}</span> */}
- </div>
+ <span>{item.title}</span>
</button>
)
})}
</nav>
</aside>
- <div className="flex flex-col flex-1 overflow-auto h-[628px]">
+ <div className="flex flex-col flex-1 overflow-auto h-[628px] pr-2.5">
<Switch value={activeTab}>
<Case cond="debug">
<ConfigDebug />
diff --git a/src/components/config-plugin.tsx b/src/components/config-plugin.tsx
index a961d31e..410df31d 100644
--- a/src/components/config-plugin.tsx
+++ b/src/components/config-plugin.tsx
@@ -1,4 +1,163 @@
+import { Card, Chip, Label, Spinner, Typography } from '@heroui/react'
+import { useOverlay } from '@overlastic/react'
+import { useTranslation } from 'react-i18next'
+import { If } from 'react-if-lite'
+import { useDshPlugins } from '../hooks/use-dsh-plugins'
+import { Dialog } from './dialog'
+import { Ellipsis as TextEllipsis } from './ellipsis'
+
+/**
+ * 「插件」面板:只读展示已安装插件,作为「插件出问题时」的卸载/升级入口。
+ *
+ * 与「档案」面板保持一致:`Card` 行布局 + `Typography` 标题,行尾放交互操作,
+ * 卸载用 `Dialog`(`useOverlay` holder)二次确认;异常详情因需「复制日志 +
+ * 升级 + 卸载」三个动作,保留为独立 `Modal`。
+ *
+ * - 数据来自 `useDshPlugins`(`get_dsh_plugins` + `dsh-plugins-updated` 实时事件)。
+ * - 卸载 `remove_dsh_plugin`、升级 `upgrade_dsh_plugin` 两个后端命令尚未实现,
+ * 目前按需求约定接入「未来命令」(invoke 会失败并 toast 提示,不崩溃)。
+ * - 「异常」标记:后端暂未提供插件错误字段,前端暂以「元信息解析失败
+ * (version 为空)」粗判为异常并允许查看详情;后端落地后替换为真实 error 字段。
+ */
+
+interface PluginErrorDialogState {
+ id: string
+ name: string
+ log: string
+}
+
export function ConfigPlugin() {
- // TODO
- return null
+ const { t } = useTranslation()
+ const { plugins, loading, error } = useDshPlugins()
+
+ const [dialogHolder, openDialog] = useOverlay(Dialog, { type: 'holder' })
+
+ /** 升级插件(接入尚未实现的后端命令) */
+ function upgrade(_id: string, _source?: PluginErrorDialogState) {
+ }
+
+ /** 卸载插件(接入尚未实现的后端命令) */
+ function remove(_id: string) {
+ }
+
+ /** 卸载确认(用与「档案」面板一致的 Dialog) */
+ async function confirmRemove(id: string, name: string) {
+ await openDialog({
+ status: 'danger',
+ title: t('plugins.remove_confirm_title'),
+ description: (
+ <p>
+ {t('plugins.remove_confirm_desc', { name })}
+ </p>
+ ),
+ confirmText: t('plugins.uninstall'),
+ })
+ remove(id)
+ }
+
+ 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>
+
+ {/* 加载 / 失败 / 空态 */}
+ <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>
+ )}
+ >
+ <If
+ cond={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>
+ )}
+ >
+ <div className="space-y-3 flex-wrap gap-2">
+ {plugins.map(plugin => (
+ <Card key={plugin.id} className="rounded-md bg-[#f5f5f5] py-3">
+ <Card.Content className="flex flex-row items-center justify-between">
+ <div>
+ <div className="flex min-w-0 items-center gap-1">
+ {/* TODO: 检测该插件异常时显示
+ <Button
+ isIconOnly
+ size="sm"
+ variant="ghost"
+ className="size-6 shrink-0 rounded-md text-danger"
+ aria-label={t('plugins.abnormal_tooltip')}
+ >
+ <CircleExclamation />
+ </Button> */}
+ <Label className="min-w-0 truncate text-sm font-medium text-ink">
+ {plugin.name}
+ </Label>
+ <If cond={plugin.version !== ''}>
+ <code className="shrink-0 rounded bg-default px-1.5 py-0.5 font-mono text-[10px] text-muted">
+ {plugin.version}
+ </code>
+ </If>
+ </div>
+ <If cond={plugin.description !== ''}>
+ <TextEllipsis lineClamp={2} className="text-xs text-muted">
+ {plugin.description}
+ </TextEllipsis>
+ </If>
+ </div>
+
+ <div className="flex shrink-0 items-center gap-1.5">
+ <If cond={true /* isNewUpgrade */}>
+ <Chip
+ className="rounded-md cursor-pointer"
+ variant="primary"
+ color="accent"
+ onClick={() => upgrade(plugin.id)}
+ size="sm"
+ >
+ 更新
+ </Chip>
+ </If>
+ <Chip
+ className="rounded-md cursor-pointer"
+ variant="primary"
+ color="danger"
+ size="sm"
+ onClick={() => confirmRemove(plugin.id, plugin.name)}
+ >
+ 卸载
+ </Chip>
+ </div>
+ </Card.Content>
+ </Card>
+ ))}
+ </div>
+ </If>
+ </If>
+
+ {dialogHolder}
+ </div>
+ )
}
diff --git a/src/components/config-profile.tsx b/src/components/config-profile.tsx
index 4a4b7fb0..a0b1a067 100644
--- a/src/components/config-profile.tsx
+++ b/src/components/config-profile.tsx
@@ -1,4 +1,214 @@
+import { Plus } from '@gravity-ui/icons'
+import { Button, Card, Checkbox, Chip, Description, Input, Label, Typography } from '@heroui/react'
+import { useOverlay } from '@overlastic/react'
+import { useState } from 'react'
+
+import { useTranslation } from 'react-i18next'
+import { If } from 'react-if-lite'
+import { toast } from '@/utils'
+import { Dialog } from './dialog'
+import { Ellipsis } from './ellipsis'
+
+/** 档案行:一个 dsh 配置档案(隔离的插件/补丁/设置集合) */
+export interface Profile {
+ id: string
+ name: string
+ /** 是否为默认档案 */
+ default: boolean
+ /** 是否为当前使用的档案 */
+ active: boolean
+ /** 简短说明的 i18n key(可选) */
+ description?: string
+}
+
export function ConfigProfile() {
- // TODO
- return null
+ /**
+ * 「档案」面板:展示 & 切换 dsh 配置档案,支持新建。
+ *
+ * 列表用 HeroUI `ListBox` 标准用法渲染:`selectionMode="single"` + 受控
+ * `selectedKeys` 表示当前激活档案,`ListBox.ItemIndicator` 渲染选中标记。
+ *
+ * 注意:后端尚无 get_profiles / set_active_profile / create_profile 命令,
+ * 按需求约定「仅前端 + 内置示范数据」在此用本地状态驱动 UI(含本地交互演示);
+ * 后端命令落地后,把 `useState` 初始值换成真实查询、把本地更新换成接口调用即可。
+ */
+ const DEMO_PROFILES: Profile[] = [
+ { id: 'web', name: 'Web', default: true, active: true, description: '官方默认' },
+ ]
+
+ const [dialogHolder, openDialog] = useOverlay(Dialog, { type: 'holder' })
+
+ const { t } = useTranslation()
+ const [profiles, setProfiles] = useState<Profile[]>(DEMO_PROFILES)
+ const [creating, setCreating] = useState(false)
+ const [name, setName] = useState('')
+
+ async function activate(id: string) {
+ const target = profiles.find(p => p.id === id)
+ if (!target || target.active)
+ return
+ await openDialog({
+ status: 'warning',
+ title: '确认切换档案?',
+ description: (
+ <p>
+ 切换至
+ {' '}
+ <strong>{target.name}</strong>
+ {' '}
+ 档案,相应的插件与设置将被一同切换。
+ </p>
+ ),
+ })
+ setProfiles(prev => prev.map(p => ({ ...p, active: p.id === id })))
+ toast(t('profiles.activate_toast', { name: target.name }), {})
+ }
+
+ function startCreate() {
+ setCreating(true)
+ setName('')
+ }
+
+ function cancelCreate() {
+ setCreating(false)
+ setName('')
+ }
+
+ function commitCreate() {
+ const trimmed = name.trim()
+ if (!trimmed)
+ return
+ const id = trimmed.toLowerCase().replace(/\s+/g, '-')
+ setProfiles(prev => [
+ ...prev,
+ { id, name: trimmed, default: false, active: false },
+ ])
+ setCreating(false)
+ setName('')
+ toast(t('profiles.created_toast', { name: trimmed }), {})
+ }
+
+ async function remove(id: string) {
+ const target = profiles.find(p => p.id === id)
+ if (!target)
+ return
+ await openDialog({
+ title: 'Remove Profile',
+ status: 'danger',
+ description: (
+ <p>
+ This will permanently delete
+ {' '}
+ <strong>{target.name}</strong>
+ {' '}
+ and all of its
+ data. This action cannot be undone.
+ </p>
+ ),
+ })
+ setProfiles(prev => prev.filter(p => p.id !== id))
+ toast(t('profiles.removed_toast', { name: id }), {})
+ }
+
+ 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>
+
+ <div className="space-y-3 flex-wrap gap-2">
+ {profiles.map(profile => (
+ <Card key={profile.id} className="bg-[#f5f5f5] 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">
+ <Label className="min-w-0 truncate text-sm font-medium text-ink">
+ {profile.name}
+ </Label>
+ <If cond={profile.description != null}>
+ <Description className="min-w-0 text-xs text-muted">
+ <Ellipsis>{t(profile.description as string)}</Ellipsis>
+ </Description>
+ </If>
+ </div>
+ <div className="flex items-center gap-2">
+ <Checkbox
+ isSelected={profile.active}
+ aria-label={profile.name}
+ className="shrink-0"
+ >
+ <Checkbox.Content>
+ <Checkbox.Control>
+ <Checkbox.Indicator />
+ </Checkbox.Control>
+ </Checkbox.Content>
+ </Checkbox>
+ <If cond={!profile.default}>
+ <Chip
+ className="rounded-md"
+ variant="primary"
+ color="danger"
+ size="sm"
+ onClick={(event) => {
+ event.stopPropagation()
+ remove(profile.id)
+ }}
+ >
+ 删除
+ </Chip>
+ </If>
+ </div>
+ </Card.Content>
+ </Card>
+ ))}
+ {/* 新建档案:内联输入 or 触发入口 */}
+ <If
+ cond={!creating}
+ else={(
+ <div className="flex items-center gap-2 px-1">
+ <Input
+ autoFocus
+ variant="secondary"
+ className="h-8 flex-1 rounded-md"
+ placeholder={t('profiles.name_placeholder')}
+ value={name}
+ onChange={e => setName(e.target.value)}
+ onKeyDown={(e) => {
+ if (e.key === 'Enter')
+ commitCreate()
+ }}
+ />
+ <Button size="sm" variant="tertiary" className="h-8 rounded-md" onPress={cancelCreate}>
+ {t('profiles.create_cancel')}
+ </Button>
+ <Button
+ size="sm"
+ variant="primary"
+ className="h-8 rounded-md"
+ isDisabled={!name.trim()}
+ onPress={commitCreate}
+ >
+ {t('profiles.create_confirm')}
+ </Button>
+ </div>
+ )}
+ >
+ <Button
+ onClick={startCreate}
+ variant="tertiary"
+ className="flex w-full rounded-md"
+ >
+ <Plus className="size-3.5" />
+ <span>{t('profiles.new_profile')}</span>
+ </Button>
+ </If>
+ </div>
+ {dialogHolder}
+ </div>
+ )
}
diff --git a/src/components/dialog.tsx b/src/components/dialog.tsx
new file mode 100644
index 00000000..025cef44
--- /dev/null
+++ b/src/components/dialog.tsx
@@ -0,0 +1,47 @@
+import type { PropsWithOverlays } from '@overlastic/react'
+import type { AlertDialogStatus } from 'node_modules/@heroui/react/dist/components/alert-dialog/alert-dialog'
+import type { ReactNode } from 'react'
+import { AlertDialog, Button } from '@heroui/react'
+import { useDisclosure } from '@overlastic/react'
+
+export interface DialogProps extends PropsWithOverlays {
+ status: AlertDialogStatus
+ title?: string
+ description?: ReactNode
+
+ cancelText?: string
+ confirmText?: string
+}
+
+export function Dialog(props: DialogProps) {
+ const disclosure = useDisclosure({ props })
+
+ const buttonVariant = props.status === 'danger' ? 'danger' : 'primary'
+
+ return (
+ <AlertDialog onOpenChange={disclosure.cancel} isOpen={disclosure.visible}>
+ <AlertDialog.Backdrop>
+ <AlertDialog.Container>
+ <AlertDialog.Dialog className="sm:max-w-[400px]">
+ <AlertDialog.CloseTrigger />
+ <AlertDialog.Header>
+ <AlertDialog.Icon status={props.status} />
+ <AlertDialog.Heading>{props.title}</AlertDialog.Heading>
+ </AlertDialog.Header>
+ <AlertDialog.Body>
+ {props.description}
+ </AlertDialog.Body>
+ <AlertDialog.Footer>
+ <Button className="rounded-md" variant="tertiary" onPress={disclosure.cancel}>
+ {props.cancelText || 'Cancel'}
+ </Button>
+ <Button className="rounded-md" variant={buttonVariant} onPress={disclosure.confirm}>
+ {props.confirmText || 'Confirm'}
+ </Button>
+ </AlertDialog.Footer>
+ </AlertDialog.Dialog>
+ </AlertDialog.Container>
+ </AlertDialog.Backdrop>
+ </AlertDialog>
+ )
+}
diff --git a/src/components/ellipsis.tsx b/src/components/ellipsis.tsx
new file mode 100644
index 00000000..574eb76e
--- /dev/null
+++ b/src/components/ellipsis.tsx
@@ -0,0 +1,71 @@
+import type { ReactNode } from 'react'
+import type { VariantProps } from 'tailwind-variants'
+import { Tooltip } from '@heroui/react'
+import { useRef, useState } from 'react'
+import { cn, tv } from 'tailwind-variants'
+
+export interface EllipsisProps {
+ lineClamp?: number
+ tooltip?: ReactNode
+ children?: ReactNode
+ className?: string
+ tooltipClassName?: string
+ forceTooltip?: boolean
+}
+
+const ellipsis = tv({
+ slots: {
+ container: '',
+ tooltip: '',
+ },
+})
+
+export function Ellipsis(props: EllipsisProps & VariantProps<typeof ellipsis>) {
+ const [open, setOpen] = useState(false)
+ const { container, tooltip } = ellipsis(props)
+ const triggerRef = useRef<HTMLDivElement>(null)
+ const triggerInnerRef = useRef<HTMLSpanElement>(null)
+
+ function getDisabled() {
+ if (!triggerRef.current)
+ return true
+ let tooltipDisabled = false
+ const { current: trigger } = triggerRef
+ const { current: triggerInner } = triggerInnerRef
+ if (props.lineClamp !== undefined) {
+ tooltipDisabled = trigger.scrollHeight <= trigger.offsetHeight
+ }
+ else if (triggerInner) {
+ tooltipDisabled = triggerInner.getBoundingClientRect().width <= trigger.getBoundingClientRect().width
+ }
+ return tooltipDisabled
+ }
+
+ function onOpenChange(open: boolean) {
+ if (getDisabled() && !props.forceTooltip)
+ return
+
+ setOpen(open)
+ }
+ return (
+ <Tooltip isOpen={open} onOpenChange={onOpenChange}>
+ <div
+ ref={triggerRef}
+ className={cn(
+ props.lineClamp === undefined ? 'truncate' : 'line-clamp-[var(--line-clamp)] [display:-webkit-inline-box]!',
+ container({ className: props.className }),
+ )}
+ style={
+ {
+ '--line-clamp': props.lineClamp,
+ } as React.CSSProperties
+ }
+ >
+ {props.lineClamp ? props.children : <span ref={triggerInnerRef}>{props.children}</span>}
+ </div>
+ <Tooltip.Content className={cn(tooltip(), props.tooltipClassName)}>
+ {props.tooltip || props.children}
+ </Tooltip.Content>
+ </Tooltip>
+ )
+}
diff --git a/src/components/navbar.tsx b/src/components/navbar.tsx
index 2702fb63..b41a7cfe 100644
--- a/src/components/navbar.tsx
+++ b/src/components/navbar.tsx
@@ -8,7 +8,7 @@ import {
Square,
Xmark,
} from '@gravity-ui/icons'
-import { Button, Description, Dropdown, Label } from '@heroui/react'
+import { Button, Chip, Description, Dropdown, Label } from '@heroui/react'
import { useOverlay } from '@overlastic/react'
import { invoke } from '@tauri-apps/api/core'
import { getCurrentWindow } from '@tauri-apps/api/window'
@@ -146,7 +146,7 @@ export default function Navbar({ iframeRef }: NavbarProps) {
variant="ghost"
onPress={() => openConfigDialog()}
>
- 应用配置
+ {t('app.config')}
</Button>
<Dropdown>
<Button
@@ -191,6 +191,11 @@ export default function Navbar({ iframeRef }: NavbarProps) {
</Dropdown.Menu>
</Dropdown.Popover>
</Dropdown>
+ <If cond={import.meta.env.DEV}>
+ <Chip size="sm" variant="primary" color="warning" className="text-xs text-background ml-1">
+ {t('app.dev_env')}
+ </Chip>
+ </If>
</div>
diff --git a/src/i18n/locales/en-US.json b/src/i18n/locales/en-US.json
index cb67b4c2..5aa74661 100644
--- a/src/i18n/locales/en-US.json
+++ b/src/i18n/locales/en-US.json
@@ -134,5 +134,44 @@
"messages.logs_copied": "Logs copied to clipboard",
"app.debug": "Debug",
"app.help": "Help",
- "app.application": "Application"
+ "app.application": "Application",
+ "profiles.title": "Profiles",
+ "profiles.tooltip": "Profiles are isolated bundles of plugins, patches and settings in dsh. The desktop runs in the default web profile; create new profiles to trial different plugin combinations without affecting the current setup.",
+ "profiles.active": "Active",
+ "profiles.default_desc": "Desktop's default profile",
+ "profiles.new_profile": "New Profile",
+ "profiles.name_placeholder": "Profile name",
+ "profiles.create_cancel": "Cancel",
+ "profiles.create_confirm": "Create",
+ "profiles.activate_toast": "{{name}} is now the active profile",
+ "profiles.created_toast": "Created profile {{name}}",
+ "plugins.panel_tooltip": "Installed plugins, read-only. Plugins normally need no management here — upgrade or uninstall one only when it is causing problems.",
+ "plugins.uninstall": "Uninstall",
+ "plugins.upgrade": "Upgrade",
+ "plugins.open_repo": "Open repository",
+ "plugins.abnormal_tooltip": "This plugin is running abnormally. Click to view details.",
+ "plugins.error_parse": "Failed to read the plugin's metadata (package.json is missing or corrupt).",
+ "plugins.abnormal_desc": "Plugin {{name}} is abnormal and may be corrupted or incompatible with the current environment.",
+ "plugins.error_log": "Error log",
+ "plugins.remove_confirm_title": "Uninstall plugin",
+ "plugins.remove_confirm_desc": "Uninstall {{name}}? Its features will no longer be available after removal.",
+ "plugins.remove_failed": "Uninstall failed — the backend command is not wired up yet.",
+ "plugins.upgrade_failed": "Upgrade failed — the backend command is not wired up yet.",
+ "plugins.close": "Close",
+ "plugins.copy_failed": "Failed to copy the error log",
+ "core.title": "Harness Core",
+ "core.tooltip": "Harness Core is the dsh engine powering the desktop. Manage local copies of each version here — switch the running version, or uninstall ones you no longer need.",
+ "core.local": "Local",
+ "core.local_hint": "installed via CLI before Desktop was set up",
+ "core.in_use": "In use",
+ "core.uninstall": "Uninstall",
+ "core.not_downloaded": "not downloaded",
+ "core.switch_confirm_title": "Switch version",
+ "core.switch_confirm_desc": "Switch to the {{version}} version? The running engine will change to this copy.",
+ "core.activate_toast": "Switched to {{version}}",
+ "core.uninstalled_toast": "Uninstalled {{version}}",
+ "core.remove_confirm_title": "Uninstall version",
+ "core.remove_confirm_desc": "Uninstall {{version}}? The engine copy will be removed from this device (other copies are unaffected).",
+ "app.dev_env": "Development",
+ "app.config": "Configuration"
}
diff --git a/src/i18n/locales/zh-CN.json b/src/i18n/locales/zh-CN.json
index 8b0fe332..a9c4843b 100644
--- a/src/i18n/locales/zh-CN.json
+++ b/src/i18n/locales/zh-CN.json
@@ -134,5 +134,44 @@
"messages.logs_copied": "日志已复制到剪贴板",
"app.debug": "调试",
"app.help": "帮助",
- "app.application": "应用"
+ "app.application": "应用",
+ "profiles.title": "档案",
+ "profiles.tooltip": "档案是 dsh 中一组相互隔离的配置集合,包含各自的插件、补丁与设置。桌面端运行在默认的 web 档案中;新建档案可试用不同的插件组合而不影响当前配置。",
+ "profiles.active": "使用中",
+ "profiles.default_desc": "桌面端默认档案",
+ "profiles.new_profile": "新建档案",
+ "profiles.name_placeholder": "档案名称",
+ "profiles.create_cancel": "取消",
+ "profiles.create_confirm": "创建",
+ "profiles.activate_toast": "已将 {{name}} 设为使用中",
+ "profiles.created_toast": "已创建档案 {{name}}",
+ "plugins.panel_tooltip": "该面板只读展示已安装插件。插件通常无需在此管理;仅当某个插件出现问题时,才需要在这里升级或卸载它。",
+ "plugins.uninstall": "卸载",
+ "plugins.upgrade": "升级",
+ "plugins.open_repo": "打开仓库",
+ "plugins.abnormal_tooltip": "此插件运行异常,点击查看详情。",
+ "plugins.error_parse": "读取插件元信息失败(package.json 缺失或损坏)。",
+ "plugins.abnormal_desc": "插件 {{name}} 运行异常,可能已损坏或与当前环境不兼容。",
+ "plugins.error_log": "错误日志",
+ "plugins.remove_confirm_title": "卸载插件",
+ "plugins.remove_confirm_desc": "确定卸载插件 {{name}} 吗?卸载后其功能将不可用。",
+ "plugins.remove_failed": "卸载失败(后端命令尚未接入)。",
+ "plugins.upgrade_failed": "升级失败(后端命令尚未接入)。",
+ "plugins.close": "关闭",
+ "plugins.copy_failed": "复制错误日志失败",
+ "core.title": "核心引擎",
+ "core.tooltip": "Harness Core 是驱动桌面端的 dsh 引擎。这里管理各版本的本地副本:切换到指定版本运行,或卸载不再需要的版本。",
+ "core.local": "本地",
+ "core.local_hint": "未安装桌面端前由 CLI 安装的版本",
+ "core.in_use": "使用中",
+ "core.uninstall": "卸载",
+ "core.not_downloaded": "未下载",
+ "core.switch_confirm_title": "切换版本",
+ "core.switch_confirm_desc": "切换至 {{version}} 版本吗?运行中的引擎将切换为该副本。",
+ "core.activate_toast": "已切换到 {{version}}",
+ "core.uninstalled_toast": "已卸载 {{version}}",
+ "core.remove_confirm_title": "卸载版本",
+ "core.remove_confirm_desc": "确定卸载 {{version}} 吗?将移除本机的该引擎副本(其余副本不受影响)。",
+ "app.dev_env": "开发环境",
+ "app.config": "应用配置"
}