Skip to content

Commit

Permalink
fix: 修复鼠标拖出窗口后触发上下文菜单的问题
Browse files Browse the repository at this point in the history
- 在窗口外侧拖动鼠标时,不再显示上下文菜单
- 通过监听 contextmenu 事件并检查鼠标位置来实现修复
  • Loading branch information
neooier committed Jan 23, 2025
1 parent 34934cf commit 8e890a2
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 8e890a2

Please sign in to comment.