Skip to content

Commit 741a600

Browse files
committed
fix: Mobile long press menu does not work
1 parent 4c8a2a0 commit 741a600

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

scripts/dev/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<script src="//cdn.jsdelivr.net/npm/eruda"></script>
1616
<script>eruda.init();</script>
1717
<script src="./bundle.js"></script>
18+
<!-- <p>Test copy Test copy Test copy Test copy Test copy Test copy Test copy Test copy Test copy Test copy Test copy Test copy Test copy Test copy Test copy Test copy Test copy Test copy Test copy Test copy Test copy Test copy Test copy Test copy Test copy Test copy </p> -->
1819
<div>Test disable select</div>
1920
<input/>
2021
</body>

scripts/dev/index.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@
66
import disableDevtool from '../../src';
77
// import disableDevtool from '../../npm';
88

9+
// window.addEventListener('popstate', function (event) {
10+
// event.preventDefault();
11+
// });
912
disableDevtool({
1013
md5: '0b9e05caf5000360ec1c263335bd83fe', // ddtk
1114
// url: 'https://www.qq.com',
1215
ondevtoolopen: (type, next) => {
1316
// window.location.href = 'https://www.qq.com';
1417
document.body.innerHTML = 'devtool opened!; type =' + type;
15-
next();
18+
// next();
1619
// console.log(next);
1720
},
1821
ondevtoolclose: () => {
@@ -27,9 +30,9 @@ disableDevtool({
2730
// tkName: 'ddtk',
2831
// disableMenu: false,
2932
// clearLog: false,
30-
disableCopy: true,
31-
disableSelect: true,
32-
disablePaste: true,
33+
// disableCopy: true,
34+
// disableSelect: true,
35+
// disablePaste: true,
3336
// url: 'https://www.baidu.com'
3437
// detectors: [disableDevtool.DetectorType.DATE_TO_STRING],
3538

@@ -47,8 +50,8 @@ document.addEventListener('click', () => {
4750
// alert(disableDevtool.isSuspend);
4851
});
4952

50-
// console.log(disableDevtool.version);
51-
// console.log(disableDevtool.md5('xx'));
53+
console.log(disableDevtool.version);
54+
console.log(disableDevtool.md5('xx'));
5255

5356

5457
// import {log} from '../src/log';

src/utils/key-menu.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@ function disableTarget (target: Window) {
6060

6161
function disableMenu (target: Window) {
6262
if (config.disableMenu) {
63-
addPreventListener(target, 'contextmenu');
63+
target.addEventListener('contextmenu', (e: Event & {pointerType: string}) => {
64+
if (e.pointerType === 'touch') return;
65+
return preventEvent(target, e);
66+
});
6467
}
6568
}
6669
function disableSelect (target: Window) {

0 commit comments

Comments
 (0)