From 6971bd32e8e4b7a93c77a6bb7eae9214bf390666 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=B4=E5=A4=A9?= Date: Mon, 13 Apr 2026 10:24:03 +0800 Subject: [PATCH] feat(about): add Hermes Agent upgrade/uninstall/config buttons MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hermes 卡片已安装状态下新增三个操作按钮: - 配置: 跳转到 Hermes 设置页 - 升级: 调用 updateHermes() 重新安装最新版 - 卸载: 调用 uninstallHermes(),支持选择是否清除配置 新增 12 个 i18n 键 (zh/en/繁/ja/ko) --- src/locales/modules/about.js | 11 ++++++++ src/pages/about.js | 52 +++++++++++++++++++++++++++++++++++- 2 files changed, 62 insertions(+), 1 deletion(-) diff --git a/src/locales/modules/about.js b/src/locales/modules/about.js index 78e5324..4963667 100644 --- a/src/locales/modules/about.js +++ b/src/locales/modules/about.js @@ -20,6 +20,17 @@ export default { notInstalled: _('未安装', 'Not installed', '未安裝', '未インストール', '미설치', 'Chưa cài đặt', 'No instalado', 'Não instalado', 'Не установлен', 'Non installé', 'Nicht installiert'), installed: _('已安装', 'Installed', '已安裝'), hermesSetup: _('前往配置', 'Go to Setup', '前往配置'), + hermesConfig: _('配置', 'Config', '配置', '設定', '설정'), + hermesUpgrade: _('升级', 'Upgrade', '升級', 'アップグレード', '업그레이드'), + hermesUninstall: _('卸载', 'Uninstall', '卸載', 'アンインストール', '제거'), + upgrading: _('升级中...', 'Upgrading...', '升級中...', 'アップグレード中...', '업그레이드 중...'), + uninstalling: _('卸载中...', 'Uninstalling...', '卸載中...', 'アンインストール中...', '제거 중...'), + hermesUpgradeOk: _('Hermes Agent 已升级到 {version}', 'Hermes Agent upgraded to {version}', 'Hermes Agent 已升級到 {version}'), + hermesUpgradeFail: _('升级失败: {error}', 'Upgrade failed: {error}', '升級失敗: {error}'), + hermesUninstallConfirm: _('确定要卸载 Hermes Agent 吗?', 'Are you sure you want to uninstall Hermes Agent?', '確定要卸載 Hermes Agent 嗎?'), + hermesUninstallCleanConfig: _('是否同时清除配置文件?(选「取消」保留配置)', 'Also remove config files? (Cancel to keep)', '是否同時清除配置文件?(選「取消」保留配置)'), + hermesUninstallOk: _('Hermes Agent 已卸载', 'Hermes Agent uninstalled', 'Hermes Agent 已卸載'), + hermesUninstallFail: _('卸载失败: {error}', 'Uninstall failed: {error}', '卸載失敗: {error}'), aheadOfRecommended: _('当前版本高于推荐稳定版: {ver}', 'Current version is ahead of recommended stable: {ver}', '目前版本高於推薦穩定版: {ver}'), rollbackToRecommended: _('回退到推荐版', 'Rollback to recommended', '回退到推薦版'), recommendedStable: _('推荐稳定版: {ver}', 'Recommended stable: {ver}', '推薦穩定版: {ver}', '推奨安定版: {ver}', '권장 안정 버전: {ver}'), diff --git a/src/pages/about.js b/src/pages/about.js index ba99133..c2eb086 100644 --- a/src/pages/about.js +++ b/src/pages/about.js @@ -89,6 +89,8 @@ async function loadHermesData(page) { const esc = s => String(s || '').replace(/&/g, '&').replace(//g, '>') + const btnSm = 'padding:2px 8px;font-size:var(--font-size-xs)' + cards.innerHTML = `
ClawPanel
@@ -103,7 +105,12 @@ async function loadHermesData(page) { ? `● Gateway ${t('engine.dashRunning')} · :${port}` : `○ Gateway ${t('engine.dashStopped')}`} ${model ? `${t('engine.dashModel')}: ${esc(model)}` : ''} - ${!installed ? `${t('about.hermesSetup')}` : ''} + ${!installed ? `${t('about.hermesSetup')}` : ''} + ${installed ? ` + ${t('about.hermesConfig')} + + + ` : ''}
@@ -112,6 +119,49 @@ async function loadHermesData(page) {
${esc(pyPath)}
` + + // Hermes 管理按钮事件 + if (installed) { + const upgradeBtn = cards.querySelector('#btn-hermes-upgrade') + const uninstallBtn = cards.querySelector('#btn-hermes-uninstall') + + if (upgradeBtn) { + upgradeBtn.onclick = async () => { + upgradeBtn.disabled = true + upgradeBtn.textContent = t('about.upgrading') + try { + const ver = await api.updateHermes() + toast(t('about.hermesUpgradeOk', { version: ver || '' }), 'success') + loadHermesData(page) + } catch (e) { + toast(t('about.hermesUpgradeFail', { error: e.message || e }), 'error') + } finally { + upgradeBtn.disabled = false + upgradeBtn.textContent = t('about.hermesUpgrade') + } + } + } + + if (uninstallBtn) { + uninstallBtn.onclick = async () => { + const confirmed = confirm(t('about.hermesUninstallConfirm')) + if (!confirmed) return + const cleanConfig = confirm(t('about.hermesUninstallCleanConfig')) + uninstallBtn.disabled = true + uninstallBtn.textContent = t('about.uninstalling') + try { + await api.uninstallHermes(cleanConfig) + toast(t('about.hermesUninstallOk'), 'success') + loadHermesData(page) + } catch (e) { + toast(t('about.hermesUninstallFail', { error: e.message || e }), 'error') + } finally { + uninstallBtn.disabled = false + uninstallBtn.textContent = t('about.hermesUninstall') + } + } + } + } } catch { cards.innerHTML = `
${t('common.loadFailed')}
` }