diff --git a/src/components/sidebar/TreeItem.vue b/src/components/sidebar/TreeItem.vue index b092b8d04..e2bd2736b 100644 --- a/src/components/sidebar/TreeItem.vue +++ b/src/components/sidebar/TreeItem.vue @@ -54,6 +54,7 @@ import { useToast } from "@/composables/useToast"; import { useDatabaseOptions } from "@/composables/useDatabaseOptions"; import type { DatabaseType, QueryResult, TreeNode, TreeNodeType } from "@/types/database"; import * as api from "@/lib/api"; +import { uuid } from "@/lib/utils"; import { resolveDefaultDatabase } from "@/lib/defaultDatabase"; import { DATABASE_EXPORT_PAGE_SIZE, @@ -361,6 +362,15 @@ function copyName() { navigator.clipboard.writeText(props.node.label); } +async function duplicateConnection() { + const connId = props.node.connectionId; + if (!connId) return; + const config = connectionStore.getConfig(connId); + if (!config) return; + const newConfig = { ...config, id: uuid(), name: `${config.name} (Copy)` }; + await connectionStore.addConnection(newConfig); +} + // --- Table Management Operations --- const showDropTableConfirm = ref(false); const showEmptyTableConfirm = ref(false); @@ -1186,6 +1196,9 @@ const isDragging = computed(() => dragState.active && dragState.draggedId === pr {{ t("contextMenu.editConnection") }} + + {{ t("contextMenu.duplicateConnection") }} + {{ t("contextMenu.deleteConnection") }} @@ -1317,8 +1330,10 @@ const isDragging = computed(() => dragState.active && dragState.draggedId === pr - - {{ t("contextMenu.copyName") }} + diff --git a/src/i18n/locales/en.ts b/src/i18n/locales/en.ts index cf5d319dd..0f88db92d 100644 --- a/src/i18n/locales/en.ts +++ b/src/i18n/locales/en.ts @@ -411,6 +411,7 @@ export default { confirmDeleteTitle: "Delete Connection", confirmDeleteMessage: 'Are you sure you want to delete "{name}"? This cannot be undone.', editConnection: "Edit Connection", + duplicateConnection: "Duplicate Connection", newQuery: "New Query", viewData: "View Data", editStructure: "Edit Structure", diff --git a/src/i18n/locales/zh-CN.ts b/src/i18n/locales/zh-CN.ts index 29929d2f5..58de1588d 100644 --- a/src/i18n/locales/zh-CN.ts +++ b/src/i18n/locales/zh-CN.ts @@ -403,6 +403,7 @@ export default { confirmDeleteTitle: "删除连接", confirmDeleteMessage: "确定要删除「{name}」吗?此操作不可撤销。", editConnection: "编辑连接", + duplicateConnection: "复制连接", newQuery: "新建查询", viewData: "查看数据", editStructure: "编辑表结构",