feat: 添加批量删除功能
This commit is contained in:
@@ -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 = () => {
|
||||
<i class="fas fa-tags mr-3 w-4 text-center text-text-secondary group-hover:text-primary"></i>
|
||||
<span>{{ t('workspaceConnectionList.manageTags.menuItem') }}</span>
|
||||
</li>
|
||||
<li class="my-1 border-t border-border/50" v-if="contextTargetTagGroup && contextTargetTagGroup.tagId !== null && contextTargetTagGroup.connections.length > 0"></li>
|
||||
<li
|
||||
v-if="contextTargetTagGroup && contextTargetTagGroup.tagId !== null && contextTargetTagGroup.connections.length > 0"
|
||||
class="group px-4 py-1.5 cursor-pointer flex items-center text-error hover:bg-error/10 text-sm transition-colors duration-150 rounded-md mx-1"
|
||||
@click="handleTagMenuAction('deleteAllConnections')"
|
||||
>
|
||||
<i class="fas fa-trash-alt mr-3 w-4 text-center text-error/80 group-hover:text-error"></i>
|
||||
<span>{{ t('workspaceConnectionList.deleteAllConnectionsInGroupMenu') }}</span> <!-- 新增i18n -->
|
||||
</li>
|
||||
<!-- Future: Add "Rename Tag" or "Delete Tag (if empty)" options here -->
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -1203,7 +1203,13 @@
|
||||
"menuItem": "タグを管理",
|
||||
"cannotManageUntagged": "「タグなし」グループの接続は管理できません。",
|
||||
"invertSelection": "選択を反転"
|
||||
}
|
||||
},
|
||||
"deleteAllConnectionsInGroupMenu": "グループ内の全接続を削除",
|
||||
"noConnectionsToDeleteInGroup": "グループ '{groupName}' に削除可能な接続がありません。",
|
||||
"confirmDeleteAllConnectionsInGroup": "グループ '{groupName}' 内の全 {count} 個の接続を削除してもよろしいですか?この操作は元に戻せません。",
|
||||
"allConnectionsInGroupDeletedSuccess": "グループ '{groupName}' から {count} 個の接続を正常に削除しました。",
|
||||
"cannotDeleteFromUntagged": "このオプションを使用して「未分類」グループから接続を削除することはできません。",
|
||||
"someConnectionsInGroupDeleteFailed": "グループ '{groupName}' 内の {count} 個の接続の削除に失敗しました。"
|
||||
},
|
||||
"sshKeys": {
|
||||
"selector": {
|
||||
|
||||
@@ -985,7 +985,13 @@
|
||||
"menuItem": "管理标签",
|
||||
"cannotManageUntagged": "无法管理“未标记”分组的连接。",
|
||||
"invertSelection": "反选"
|
||||
}
|
||||
},
|
||||
"deleteAllConnectionsInGroupMenu": "删除分组内所有连接",
|
||||
"noConnectionsToDeleteInGroup": "分组 '{groupName}' 中没有可删除的连接。",
|
||||
"confirmDeleteAllConnectionsInGroup": "确定要删除分组 '{groupName}' 中的全部 {count} 个连接吗?此操作不可撤销。",
|
||||
"allConnectionsInGroupDeletedSuccess": "已成功从分组 '{groupName}' 中删除 {count} 个连接。",
|
||||
"cannotDeleteFromUntagged": "不能使用此选项从“未标记”分组中删除连接。",
|
||||
"someConnectionsInGroupDeleteFailed": "分组 '{groupName}' 中的 {count} 个连接未能删除。"
|
||||
},
|
||||
"remoteDesktopModal": {
|
||||
"title": "远程桌面",
|
||||
|
||||
Reference in New Issue
Block a user