From 2d7a27c8afb9fa5a2766d01069cc74a8c693b988 Mon Sep 17 00:00:00 2001 From: PJ568 Date: Mon, 12 Jun 2023 22:40:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8F=B3=E9=94=AE=E8=8F=9C?= =?UTF-8?q?=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 404.html | 2 +- comment/index.html | 2 ++ contextmenu.html | 10 ++++++++++ css/tool_type.css | 39 ++++++++++++++++++++++++++++++++++++ index.html | 2 ++ js/contextmenu.js | 50 ++++++++++++++++++++++++++++++++++++++++++++++ js/popup.js | 4 ++-- 7 files changed, 106 insertions(+), 3 deletions(-) create mode 100644 contextmenu.html create mode 100644 js/contextmenu.js diff --git a/404.html b/404.html index c5abc912..188ed366 100644 --- a/404.html +++ b/404.html @@ -23,6 +23,6 @@ - + diff --git a/comment/index.html b/comment/index.html index 14f6a895..c4d7bd67 100644 --- a/comment/index.html +++ b/comment/index.html @@ -7,6 +7,7 @@ 568Tools | Comment +
@@ -59,5 +60,6 @@ + diff --git a/contextmenu.html b/contextmenu.html new file mode 100644 index 00000000..f1443c59 --- /dev/null +++ b/contextmenu.html @@ -0,0 +1,10 @@ + + \ No newline at end of file diff --git a/css/tool_type.css b/css/tool_type.css index 0f6bd459..2e9a42db 100644 --- a/css/tool_type.css +++ b/css/tool_type.css @@ -365,3 +365,42 @@ ins.adsbygoogle[data-ad-status="unfilled"]{ background: #424242; color: #ccc; } + +/* 右键菜单 */ + +#rcb_menu{ + display: none; + position: fixed; + margin: 0; + padding: 0; + list-style: none; + width: 150px; + box-sizing: border-box; + border: 1px solid #fff; + border-radius: 5px; + z-index: 1100; + background-color: #f9f9f9; + box-shadow:0 0 10px #252423 +} +#rcb_menu>li{ + border-radius: 10px; + padding: 5px 10px 0 10px; + height: 30px +} +#rcb_menu>li:hover{ + background-color: #252423; + color: #F7F6F2; + cursor: pointer +} +#rcb_menu>.hr_break{ + padding: 0; + height: 1px; + background-color:#A2A2A2 +} +#rcb_menu>.hr_break:hover{ + background-color:#A2A2A2; + cursor: default +} +#rcb_menu>#rcb_t6{ + display: none +} \ No newline at end of file diff --git a/index.html b/index.html index 708b29c1..3f156608 100644 --- a/index.html +++ b/index.html @@ -6,6 +6,7 @@ 568Tools 在线工具箱 +
@@ -36,6 +37,7 @@ + diff --git a/js/contextmenu.js b/js/contextmenu.js new file mode 100644 index 00000000..b3371bcb --- /dev/null +++ b/js/contextmenu.js @@ -0,0 +1,50 @@ +window.addEventListener('contextmenu', RightClickMenu); +const rightMenu = document.querySelector('#rcb_menu'); +const newTab = document.querySelector('#rcb_t6'); +function RightClickMenu(e) { + e.preventDefault(); + rightMenu.style.display = 'block'; + if (e.target.closest('a')) { + newTab.style.display = 'block'; + } else { + newTab.style.display = 'none'; + } + let x = e.clientX, y = e.clientY, + menuWidth = rightMenu.offsetWidth, menuHeight = rightMenu.offsetHeight, + htmlWidth = document.body.clientWidth, htmlHeight = document.body.clientHeight; + if (x + menuWidth < htmlWidth) rightMenu.style.left = x + 'px'; + else rightMenu.style.left = htmlWidth - menuWidth + 'px'; + if (y + menuHeight < htmlHeight) rightMenu.style.top = y + 'px'; + else rightMenu.style.top = htmlHeight - menuHeight + "px"; +} +document.body.addEventListener('click', function () { + rightMenu.style.display = 'none'; +}); +// document.querySelector('#rcb_menu').addEventListener('click', function (e) { +rightMenu.addEventListener('click', function (e) { + switch (e.target.id) { + case "rcb_t1": + window.location.href="temp.html"; + break; + case "rcb_t2": + window.location.href="#"; + break; + case "rcb_t3": + window.history.back(-1); + break; + case "rcb_t4": + window.history.forward(1); + break; + case "rcb_t5": + window.location.reload(); + break; + case "rcb_t6": + if (e.target.closest('.open-in-new-tab')) { + window.open(e.target.closest('.open-in-new-tab').getAttribute('href'), '_blank'); + } + break; + default: + console.error(e.target.id); + break; + } +}); \ No newline at end of file diff --git a/js/popup.js b/js/popup.js index 1e51fecb..8c38a32e 100644 --- a/js/popup.js +++ b/js/popup.js @@ -48,7 +48,7 @@ function initData(){ list_html+=`

最近访问

`; for(var i in sotreList){ var li = sotreList[i]; - list_html+=`${li.name}`; + list_html+=`${li.name}`; } list_html+=`
`; } @@ -60,7 +60,7 @@ function initData(){ list_html+=`

${item.name}

`; for(var j in item.list){ var li=item.list[j]; - list_html+=`${li.name}`; + list_html+=`${li.name}`; } list_html+=`
`; }