diff --git a/src/App.vue b/src/App.vue index 3f3f9a83ad..ce1c49e93d 100644 --- a/src/App.vue +++ b/src/App.vue @@ -377,9 +377,18 @@ async function reconnectRestoredTabs() { } } +function handleContextMenu(e: MouseEvent) { + if (!(e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement)) { + e.preventDefault(); + } +} + onMounted(async () => { applyTheme(); window.addEventListener("keydown", handleKeydown, true); + if (isDesktop) { + document.addEventListener("contextmenu", handleContextMenu); + } if (!isDesktop) { try { const res = await fetch("/api/auth/check"); @@ -416,6 +425,7 @@ onMounted(async () => { onUnmounted(() => { window.removeEventListener("keydown", handleKeydown, true); + document.removeEventListener("contextmenu", handleContextMenu); }); diff --git a/src/components/layout/AppSidebar.vue b/src/components/layout/AppSidebar.vue index 2f5aa1f5cf..30d21171b6 100644 --- a/src/components/layout/AppSidebar.vue +++ b/src/components/layout/AppSidebar.vue @@ -1,9 +1,10 @@ @@ -24,6 +26,14 @@ const { t } = useI18n(); {{ t("sidebar.connections") }} + + + + + + + {{ t("contextMenu.refreshChildren") }} + diff --git a/src/i18n/locales/en.ts b/src/i18n/locales/en.ts index 6ef57c6f62..49cde113ba 100644 --- a/src/i18n/locales/en.ts +++ b/src/i18n/locales/en.ts @@ -419,6 +419,7 @@ export default { refreshChildren: "Refresh", pin: "Pin", unpin: "Unpin", + refreshTab: "Refresh Data", closeTab: "Close Tab", closeOtherTabs: "Close Other Tabs", closeAllTabs: "Close All Tabs", diff --git a/src/i18n/locales/zh-CN.ts b/src/i18n/locales/zh-CN.ts index 57f30ccd11..d872778797 100644 --- a/src/i18n/locales/zh-CN.ts +++ b/src/i18n/locales/zh-CN.ts @@ -411,6 +411,7 @@ export default { refreshChildren: "刷新", pin: "置顶", unpin: "取消置顶", + refreshTab: "刷新数据", closeTab: "关闭标签页", closeOtherTabs: "关闭其他标签页", closeAllTabs: "关闭全部标签页", diff --git a/src/stores/connectionStore.ts b/src/stores/connectionStore.ts index c98169d50f..ca92a5ed18 100644 --- a/src/stores/connectionStore.ts +++ b/src/stores/connectionStore.ts @@ -800,6 +800,22 @@ export const useConnectionStore = defineStore("connection", () => { persistSidebarLayoutDebounced(); } + function refreshAllTree() { + const resetChildren = (nodes: TreeNode[]) => { + for (const node of nodes) { + if (node.type === "connection-group") { + if (node.children) resetChildren(node.children); + continue; + } + if (node.isExpanded) { + node.isExpanded = false; + node.children = []; + } + } + }; + resetChildren(treeNodes.value); + } + async function exportConnectionsToFile(passphrase: string) { const { encryptConfig } = await import("@/lib/configCrypto"); const exportData = { connections: connections.value, layout: sidebarLayout.value }; @@ -946,6 +962,7 @@ export const useConnectionStore = defineStore("connection", () => { connections, activeConnectionId, treeNodes, + refreshAllTree, connectedIds, connectionErrors, setConnectionError,