diff --git a/packages/frontend/src/components/WorkspaceConnectionList.vue b/packages/frontend/src/components/WorkspaceConnectionList.vue index 4873a58..67af31e 100644 --- a/packages/frontend/src/components/WorkspaceConnectionList.vue +++ b/packages/frontend/src/components/WorkspaceConnectionList.vue @@ -411,7 +411,7 @@ const closeTagContextMenu = () => { // 处理标签右键菜单操作 // 修改:允许直接传递 groupData,用于新的行内编辑按钮 -const handleTagMenuAction = (action: 'connectAll' | 'manageTag', directGroupData?: (typeof filteredAndGroupedConnections.value)[0]) => { +const handleTagMenuAction = (action: 'connectAll' | 'manageTag' | 'deleteAllConnections', directGroupData?: (typeof filteredAndGroupedConnections.value)[0]) => { const group = directGroupData || contextTargetTagGroup.value; // 优先使用直接传递的 groupData closeTagContextMenu(); // 先关闭菜单 @@ -447,6 +447,53 @@ const handleTagMenuAction = (action: 'connectAll' | 'manageTag', directGroupData type: 'warning', }); } + } else if (group && action === 'deleteAllConnections') { + // 确保是已标记的组 + if (group.tagId === null) { + uiNotificationsStore.addNotification({ + message: t('workspaceConnectionList.cannotDeleteFromUntagged'), // 新增i18n + type: 'warning', + }); + return; + } + // 确保组内有连接 + if (group.connections.length === 0) { + uiNotificationsStore.addNotification({ + message: t('workspaceConnectionList.noConnectionsToDeleteInGroup', { groupName: group.groupName }), // 新增i18n + type: 'info', + }); + return; + } + + if (confirm(t('workspaceConnectionList.confirmDeleteAllConnectionsInGroup', { count: group.connections.length, groupName: group.groupName }))) { // 新增i18n + const connectionIdsToDelete = group.connections.map(conn => conn.id); + + const deletePromises = connectionIdsToDelete.map(connId => + connectionsStore.deleteConnection(connId).catch(err => { + console.error(`[WkspConnList] Failed to delete connection ${connId} in group ${group.groupName}:`, err); + return Promise.reject({ connId, error: err }); + }) + ); + + Promise.allSettled(deletePromises) + .then(results => { + const successfulDeletes = results.filter(result => result.status === 'fulfilled').length; + const failedDeletes = results.filter(result => result.status === 'rejected').length; + + if (successfulDeletes > 0) { + uiNotificationsStore.addNotification({ + message: t('workspaceConnectionList.allConnectionsInGroupDeletedSuccess', { count: successfulDeletes, groupName: group.groupName }), // 新增i18n + type: 'success', + }); + } + if (failedDeletes > 0) { + uiNotificationsStore.addNotification({ + message: t('workspaceConnectionList.someConnectionsInGroupDeleteFailed', { count: failedDeletes, groupName: group.groupName }), // 新增i18n + type: 'error', + }); + } + }); + } } }; @@ -853,6 +900,15 @@ const cancelEditingTag = () => { {{ t('workspaceConnectionList.manageTags.menuItem') }} +
  • +
  • + + {{ t('workspaceConnectionList.deleteAllConnectionsInGroupMenu') }} +
  • diff --git a/packages/frontend/src/locales/en-US.json b/packages/frontend/src/locales/en-US.json index c6fee38..a287af5 100644 --- a/packages/frontend/src/locales/en-US.json +++ b/packages/frontend/src/locales/en-US.json @@ -983,7 +983,13 @@ "menuItem": "Manage Tag", "cannotManageUntagged": "Cannot manage connections for 'Untagged' group.", "invertSelection": "Invert Selection" - } + }, + "deleteAllConnectionsInGroupMenu": "Delete All Connections in Group", + "noConnectionsToDeleteInGroup": "No connections to delete in group '{groupName}'.", + "confirmDeleteAllConnectionsInGroup": "Are you sure you want to delete all {count} connections in group '{groupName}'? This cannot be undone.", + "allConnectionsInGroupDeletedSuccess": "{count} connections successfully deleted from group '{groupName}'.", + "cannotDeleteFromUntagged": "Cannot use this option to delete connections from the 'Untagged' group.", + "someConnectionsInGroupDeleteFailed": "{count} connections in group '{groupName}' failed to delete." }, "remoteDesktopModal": { "title": "Remote Desktop", diff --git a/packages/frontend/src/locales/ja-JP.json b/packages/frontend/src/locales/ja-JP.json index 1a4d31d..b1781c1 100644 --- a/packages/frontend/src/locales/ja-JP.json +++ b/packages/frontend/src/locales/ja-JP.json @@ -1203,7 +1203,13 @@ "menuItem": "タグを管理", "cannotManageUntagged": "「タグなし」グループの接続は管理できません。", "invertSelection": "選択を反転" - } + }, + "deleteAllConnectionsInGroupMenu": "グループ内の全接続を削除", + "noConnectionsToDeleteInGroup": "グループ '{groupName}' に削除可能な接続がありません。", + "confirmDeleteAllConnectionsInGroup": "グループ '{groupName}' 内の全 {count} 個の接続を削除してもよろしいですか?この操作は元に戻せません。", + "allConnectionsInGroupDeletedSuccess": "グループ '{groupName}' から {count} 個の接続を正常に削除しました。", + "cannotDeleteFromUntagged": "このオプションを使用して「未分類」グループから接続を削除することはできません。", + "someConnectionsInGroupDeleteFailed": "グループ '{groupName}' 内の {count} 個の接続の削除に失敗しました。" }, "sshKeys": { "selector": { diff --git a/packages/frontend/src/locales/zh-CN.json b/packages/frontend/src/locales/zh-CN.json index 211ae98..f27e77d 100644 --- a/packages/frontend/src/locales/zh-CN.json +++ b/packages/frontend/src/locales/zh-CN.json @@ -985,7 +985,13 @@ "menuItem": "管理标签", "cannotManageUntagged": "无法管理“未标记”分组的连接。", "invertSelection": "反选" - } + }, + "deleteAllConnectionsInGroupMenu": "删除分组内所有连接", + "noConnectionsToDeleteInGroup": "分组 '{groupName}' 中没有可删除的连接。", + "confirmDeleteAllConnectionsInGroup": "确定要删除分组 '{groupName}' 中的全部 {count} 个连接吗?此操作不可撤销。", + "allConnectionsInGroupDeletedSuccess": "已成功从分组 '{groupName}' 中删除 {count} 个连接。", + "cannotDeleteFromUntagged": "不能使用此选项从“未标记”分组中删除连接。", + "someConnectionsInGroupDeleteFailed": "分组 '{groupName}' 中的 {count} 个连接未能删除。" }, "remoteDesktopModal": { "title": "远程桌面",