From 1d2197a000331cb06e4f3f0424471d153802b383 Mon Sep 17 00:00:00 2001 From: Baobhan Sith <80159437+Heavrnl@users.noreply.github.com> Date: Sun, 11 May 2025 18:44:50 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/WorkspaceConnectionList.vue | 58 ++++++++++++++++++- packages/frontend/src/locales/en-US.json | 8 ++- packages/frontend/src/locales/ja-JP.json | 8 ++- packages/frontend/src/locales/zh-CN.json | 8 ++- 4 files changed, 78 insertions(+), 4 deletions(-) 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') }} +
+