From acfe9d1b239437a835f79649682c8636a3fabd2d Mon Sep 17 00:00:00 2001 From: t8y2 <1156263951@qq.com> Date: Fri, 8 May 2026 19:05:21 +0800 Subject: [PATCH] fix: disable native context menu and add sidebar refresh button (#159) Prevent browser native "Reload" from resetting app state in Tauri, and add a refresh button to the sidebar header for convenience. --- src/App.vue | 10 ++++++++++ src/components/layout/AppSidebar.vue | 12 +++++++++++- src/i18n/locales/en.ts | 1 + src/i18n/locales/zh-CN.ts | 1 + src/stores/connectionStore.ts | 17 +++++++++++++++++ 5 files changed, 40 insertions(+), 1 deletion(-) 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 @@