From 58843a1ef41e15eda669debec99eaba1a8614523 Mon Sep 17 00:00:00 2001 From: r Date: Sun, 21 Jun 2026 11:23:39 +0800 Subject: [PATCH] =?UTF-8?q?refactor(servers):=20=E7=B2=BE=E7=AE=80?= =?UTF-8?q?=E8=A1=8C=E6=93=8D=E4=BD=9C=E5=B9=B6=E6=94=B6=E6=8B=A2=E6=89=B9?= =?UTF-8?q?=E9=87=8F=E8=AF=8A=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 一键登录文案、移除监测/站点行按钮,检测路径与诊断移至批量栏。 Co-authored-by: Cursor --- .../2026-06-21-servers-row-actions-batch.md | 32 ++++++++++ .../servers/ServerBatchActionBar.vue | 5 +- .../servers/ServerTableRowActions.vue | 62 ++----------------- .../servers/ServerUnsetPathPanel.vue | 21 ++----- frontend/src/constants/serverTableHeaders.ts | 2 +- frontend/src/pages/ServersPage.vue | 57 +++++++++-------- 6 files changed, 77 insertions(+), 102 deletions(-) create mode 100644 docs/changelog/2026-06-21-servers-row-actions-batch.md diff --git a/docs/changelog/2026-06-21-servers-row-actions-batch.md b/docs/changelog/2026-06-21-servers-row-actions-batch.md new file mode 100644 index 00000000..4b4dfa7a --- /dev/null +++ b/docs/changelog/2026-06-21-servers-row-actions-batch.md @@ -0,0 +1,32 @@ +# 服务器列表操作列与批量栏调整 + +**日期**:2026-06-21 + +## 变更摘要 + +- 行内宝塔按钮文案改为「一键登录」 +- 移除行内「监测」「站点」按钮(站点链接仍在名称/域名列可点) +- 「检测路径」「诊断」从每行操作移至顶部批量操作栏(需勾选服务器) +- 批量「检测路径」文案统一;「诊断」须单选 1 台 + +## 动机 + +行操作过多拥挤;路径检测与 Agent 诊断属批量运维动作,与「健康检查」同类。 + +## 涉及文件 + +- `frontend/src/components/servers/ServerTableRowActions.vue` +- `frontend/src/components/servers/ServerBatchActionBar.vue` +- `frontend/src/pages/ServersPage.vue` +- `frontend/src/components/servers/ServerUnsetPathPanel.vue` +- `frontend/src/constants/serverTableHeaders.ts` + +## 迁移 / 重启 + +仅前端构建部署。 + +## 验证 + +1. `#/servers` 行内见「一键登录」,无「检测路径/诊断」 +2. 勾选多台 → 批量栏可「检测路径」 +3. 单选 1 台 → 批量栏「诊断」弹出 Agent 诊断对话框 diff --git a/frontend/src/components/servers/ServerBatchActionBar.vue b/frontend/src/components/servers/ServerBatchActionBar.vue index 0464e585..7bbd30f8 100644 --- a/frontend/src/components/servers/ServerBatchActionBar.vue +++ b/frontend/src/components/servers/ServerBatchActionBar.vue @@ -5,7 +5,8 @@ 修改分类 健康检查 - 检测目标路径 + 检测路径 + 诊断 安装Agent 升级Agent 卸载Agent @@ -18,12 +19,14 @@ diff --git a/frontend/src/components/servers/ServerUnsetPathPanel.vue b/frontend/src/components/servers/ServerUnsetPathPanel.vue index 3431031e..0069d0fe 100644 --- a/frontend/src/components/servers/ServerUnsetPathPanel.vue +++ b/frontend/src/components/servers/ServerUnsetPathPanel.vue @@ -52,9 +52,11 @@ @@ -214,7 +207,6 @@ import ServerInlineDetail from '@/components/servers/ServerInlineDetail.vue' import ServerBatchActionBar from '@/components/servers/ServerBatchActionBar.vue' import ServerTableRowActions from '@/components/servers/ServerTableRowActions.vue' import { SERVER_DATA_TABLE_HEADERS } from '@/constants/serverTableHeaders' -import { resolveServerSiteHost, resolveServerSiteUrl } from '@/utils/serverSiteUrl' const props = defineProps<{ highlight?: boolean @@ -231,10 +223,8 @@ const props = defineProps<{ editingPathId: number | null editingPathValue: string savingPathId: number | null - pinnedMap: Record - pinLoadingId: number | null btLoginLoadingId: number | null - agentDiagnoseLoadingId: number | null + agentDiagnoseLoading: boolean }>() const emit = defineEmits<{ @@ -250,10 +240,6 @@ const emit = defineEmits<{ terminal: [item: ServerApiItem] 'bt-login': [item: ServerApiItem] files: [item: ServerApiItem] - site: [item: ServerApiItem] - pin: [item: ServerApiItem] - 'detect-path-single': [item: ServerApiItem] - 'agent-diagnose': [item: ServerApiItem] edit: [item: ServerApiItem] delete: [item: ServerApiItem] 'edit-path': [item: ServerApiItem] @@ -262,6 +248,7 @@ const emit = defineEmits<{ 'batch-category': [] 'health-check': [] 'detect-path': [] + 'agent-diagnose': [] 'install-agent': [] 'upgrade-agent': [] 'uninstall-agent': [] diff --git a/frontend/src/constants/serverTableHeaders.ts b/frontend/src/constants/serverTableHeaders.ts index a5496fd0..db1ec8c2 100644 --- a/frontend/src/constants/serverTableHeaders.ts +++ b/frontend/src/constants/serverTableHeaders.ts @@ -7,5 +7,5 @@ export const SERVER_DATA_TABLE_HEADERS = [ { title: '目标路径', key: 'target_path', width: 200 }, { title: 'Agent', key: 'agent_version', width: 100 }, { title: '心跳', key: 'last_heartbeat', width: 120 }, - { title: '操作', key: 'actions', width: 380, align: 'end' as const, sortable: false }, + { title: '操作', key: 'actions', width: 280, align: 'end' as const, sortable: false }, ] diff --git a/frontend/src/pages/ServersPage.vue b/frontend/src/pages/ServersPage.vue index 141fbc4e..0163e75c 100644 --- a/frontend/src/pages/ServersPage.vue +++ b/frontend/src/pages/ServersPage.vue @@ -49,10 +49,8 @@ :editing-path-id="editingPathId" :editing-path-value="editingPathValue" :saving-path-id="savingPathId" - :pinned-map="pinnedMap" - :pin-loading-id="pinLoadingId" :bt-login-loading-id="btLoginLoadingId" - :agent-diagnose-loading-id="agentDiagnoseLoadingId" + :agent-diagnose-loading="agentDiagnoseLoading" @refresh="loadUnsetPathServers()" @update:page="onUnsetPageChange" @update:items-per-page="onUnsetItemsPerPageChange" @@ -63,10 +61,6 @@ @terminal="openTerminal" @bt-login="openBtLogin($event.id)" @files="openFiles" - @site="openBrowser" - @pin="onPinServer" - @detect-path-single="detectPathSingle" - @agent-diagnose="openAgentDiagnose" @edit="editServer" @delete="confirmDelete" @edit-path="startEditPath" @@ -75,6 +69,7 @@ @batch-category="openBatchCategory('unset')" @health-check="batchHealthCheck('unset')" @detect-path="openDetectPathConfirm('unset')" + @agent-diagnose="batchAgentDiagnose('unset')" @install-agent="batchInstallAgent('unset')" @upgrade-agent="batchUpgradeAgent('unset')" @uninstall-agent="batchUninstallAgent('unset')" @@ -182,9 +177,11 @@ @@ -1086,14 +1074,6 @@ function onUnsetItemsPerPageChange(n: number) { void loadUnsetPathServers() } -async function detectPathSingle(item: ServerApiItem) { - try { - await submitServerBatchJob('detect-path', [item.id]) - } catch (e: unknown) { - snackbar(formatApiError(e, '提交检测任务失败'), 'error') - } -} - function clearExpandedForPathMigration(serverId: number, newPath: string) { const unset = isUnsetTargetPath(newPath) if (expandedMainIds.value.includes(serverId) && unset) expandedMainIds.value = [] @@ -1571,17 +1551,41 @@ function openFiles(item: ServerApiItem) { const showAgentDiagnose = ref(false) const agentDiagnoseLoading = ref(false) -const agentDiagnoseLoadingId = ref(null) const agentActionLoadingId = ref(null) const agentDiagnoseResult = ref(null) const agentDiagnoseTarget = ref(null) +function resolveBatchServerItem(scope: BatchScope, serverId: number): ServerApiItem | undefined { + const { items } = batchSelection(scope) + const fromSelection = items.value.find( + (entry): entry is ServerApiItem => typeof entry === 'object' && entry.id === serverId, + ) + if (fromSelection) return fromSelection + const list = scope === 'main' ? servers.value : unsetPathServers.value + return list.find(s => s.id === serverId) +} + +async function batchAgentDiagnose(scope: BatchScope) { + batchScope.value = scope + const { items } = batchSelection(scope) + const ids = normalizeServerIds(items.value) + if (ids.length !== 1) { + snackbar(ids.length === 0 ? '请先选择 1 台服务器' : 'Agent 诊断每次仅支持单选 1 台', 'warning') + return + } + const item = resolveBatchServerItem(scope, ids[0]) + if (!item) { + snackbar('未找到所选服务器', 'error') + return + } + await openAgentDiagnose(item) +} + async function openAgentDiagnose(item: ServerApiItem) { agentDiagnoseTarget.value = item agentDiagnoseResult.value = null showAgentDiagnose.value = true agentDiagnoseLoading.value = true - agentDiagnoseLoadingId.value = item.id try { agentDiagnoseResult.value = await http.post(`/servers/${item.id}/agent-diagnose`, {}) } catch (e: unknown) { @@ -1589,7 +1593,6 @@ async function openAgentDiagnose(item: ServerApiItem) { snackbar(formatApiError(e, 'Agent 诊断失败'), 'error') } finally { agentDiagnoseLoading.value = false - agentDiagnoseLoadingId.value = null } }