Skip to content

Commit

Permalink
修复频繁多次右键时出现多个解码菜单的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
xh321 committed Jul 28, 2023
1 parent cfcb457 commit bcb63b6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async function onLoad() {
document.addEventListener("contextmenu", (event) => {
var element = document.querySelector(".main-area__image");
if (element == null) return;

//如果是图片内容
if (location.href.includes("/imageViewer")) {
var hasFound = false;
Expand All @@ -38,6 +38,11 @@ async function onLoad() {
clearInterval(timer);
}

if (qContextMenu.querySelector(".qr-decode-menu") != null) {
//已经插入了一次,无需重复插入
return;
}

// 插入分隔线
const separator = document.createElement("div");
separator.classList.add("q-context-menu-separator");
Expand All @@ -47,7 +52,8 @@ async function onLoad() {
const qrcodeElement = document.createElement("a");
qrcodeElement.classList.add(
"q-context-menu-item",
"q-context-menu-item--normal"
"q-context-menu-item--normal",
"qr-decode-menu"
);
qrcodeElement.setAttribute("aria-disabled", "false");
qrcodeElement.setAttribute("role", "menuitem");
Expand Down

0 comments on commit bcb63b6

Please sign in to comment.