From 8e890a2a80ca5f98a4b20120bd7cb8c084f8c67e Mon Sep 17 00:00:00 2001 From: Jorylee <1747358809@qq.com> Date: Fri, 24 Jan 2025 00:13:38 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=BC=A0=E6=A0=87?= =?UTF-8?q?=E6=8B=96=E5=87=BA=E7=AA=97=E5=8F=A3=E5=90=8E=E8=A7=A6=E5=8F=91?= =?UTF-8?q?=E4=B8=8A=E4=B8=8B=E6=96=87=E8=8F=9C=E5=8D=95=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在窗口外侧拖动鼠标时,不再显示上下文菜单 - 通过监听 contextmenu 事件并检查鼠标位置来实现修复 --- src/pages/_app.tsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index f263e5c3..ed35a346 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -86,6 +86,17 @@ export default function App() { }); } }); + // 修复鼠标拖出窗口后触发上下文菜单的问题 + window.addEventListener("contextmenu", (event) => { + console.log(event, window.screen); + if ( + event.clientX < 0 || + event.clientX > window.innerWidth || + event.clientY < 0 || + event.clientY > window.innerHeight + ) + event.preventDefault(); + }); Settings.get("useNativeTitleBar").then((useNativeTitleBar) => { setUseNativeTitleBar(useNativeTitleBar); if (useNativeTitleBar) {