fix(工具箱): 优化阻止默认右键菜单处理逻辑

This commit is contained in:
2025-02-09 22:54:30 +08:00
parent ba238a44d9
commit d616564a55
5 changed files with 13 additions and 10 deletions

View File

@@ -54,17 +54,26 @@ const themeVars = useThemeVars();
function handleContextMenu(event) {
let element = event.target;
let classValue = '';
let classRegExp = /(__code__|n-code|n-input|n-input-number|n-select)/;
// 排除按住 Ctrl 键时
if (event.ctrlKey) {
return;
}
// 获取元素 class 信息
if (element instanceof HTMLElement) {
classValue = element.classList.value;
}
// 排除输入框元素
if (
element instanceof HTMLInputElement &&
['password', 'text', 'textarea'].includes(element.type)
) {
if (element instanceof HTMLInputElement) {
return;
}
// 排除指定元素
if (classValue && classRegExp.test(classValue)) {
return;
}

View File

@@ -57,7 +57,6 @@
label-align="right"
label-placement="left"
label-width="9em"
@contextmenu.stop
>
<n-form-item label="本地时间:">
@@ -88,7 +87,6 @@
label-align="right"
label-placement="left"
label-width="9em"
@contextmenu.stop
>
<n-form-item label="本地时间:">

View File

@@ -61,7 +61,6 @@
placeholder="请输入 JSON 字符串"
type="textarea"
:rows="8"
@contextmenu.stop
></n-input>
</n-card>
@@ -72,7 +71,6 @@
language="json"
:code="data.jsonOutput"
:show-line-numbers="true"
@contextmenu.stop
/>
</n-card>

View File

@@ -14,7 +14,6 @@
label-align="left"
label-placement="top"
label-width="auto"
@contextmenu.stop
>
<n-form-item label="连接地址">

View File

@@ -8,7 +8,6 @@
label-align="left"
label-placement="left"
label-width="auto"
@contextmenu.stop
>
<n-form-item label="目标链接:">