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') }} +
+