Skip to content

Commit

Permalink
fix: Mobile long press menu does not work
Browse files Browse the repository at this point in the history
  • Loading branch information
theajack3 committed Dec 22, 2023
1 parent 4c8a2a0 commit 741a600
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
1 change: 1 addition & 0 deletions scripts/dev/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<script src="//cdn.jsdelivr.net/npm/eruda"></script>
<script>eruda.init();</script>
<script src="./bundle.js"></script>
<!-- <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> -->
<div>Test disable select</div>
<input/>
</body>
Expand Down
15 changes: 9 additions & 6 deletions scripts/dev/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@
import disableDevtool from '../../src';
// import disableDevtool from '../../npm';

// window.addEventListener('popstate', function (event) {
// event.preventDefault();
// });
disableDevtool({
md5: '0b9e05caf5000360ec1c263335bd83fe', // ddtk
// url: 'https://www.qq.com',
ondevtoolopen: (type, next) => {
// window.location.href = 'https://www.qq.com';
document.body.innerHTML = 'devtool opened!; type =' + type;
next();
// next();
// console.log(next);
},
ondevtoolclose: () => {
Expand All @@ -27,9 +30,9 @@ disableDevtool({
// tkName: 'ddtk',
// disableMenu: false,
// clearLog: false,
disableCopy: true,
disableSelect: true,
disablePaste: true,
// disableCopy: true,
// disableSelect: true,
// disablePaste: true,
// url: 'https://www.baidu.com'
// detectors: [disableDevtool.DetectorType.DATE_TO_STRING],

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

// console.log(disableDevtool.version);
// console.log(disableDevtool.md5('xx'));
console.log(disableDevtool.version);
console.log(disableDevtool.md5('xx'));


// import {log} from '../src/log';
Expand Down
5 changes: 4 additions & 1 deletion src/utils/key-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ function disableTarget (target: Window) {

function disableMenu (target: Window) {
if (config.disableMenu) {
addPreventListener(target, 'contextmenu');
target.addEventListener('contextmenu', (e: Event & {pointerType: string}) => {
if (e.pointerType === 'touch') return;
return preventEvent(target, e);
});
}
}
function disableSelect (target: Window) {
Expand Down

0 comments on commit 741a600

Please sign in to comment.