perf: 优化Android长按事件

This commit is contained in:
kuaifan 2023-12-21 13:03:19 +08:00
parent e99e069e55
commit 66135d8222
3 changed files with 16 additions and 4 deletions

View File

@ -395,6 +395,8 @@ export default {
window.__handleLink = (path) => {
this.goForward({ path: (path || '').indexOf('/') !==0 ? "/" + path : path });
}
//
$A.eeuiAppSetHapticBackEnabled(false)
},
otherEvents() {

View File

@ -1,4 +1,4 @@
const isSupportTouch = "ontouchend" in document;
const useModeTouch = $A.isIos() && "ontouchend" in document;
// 长按或右键指令
const longpress = {
bind: function (el, binding) {
@ -16,13 +16,13 @@ const longpress = {
el.__longpressContextmenu__ = (e) => {
e.preventDefault()
e.stopPropagation()
if (!isSupportTouch) {
if (!useModeTouch) {
callback(e, el)
}
}
el.addEventListener('contextmenu', el.__longpressContextmenu__);
// 不支持touch
if (!isSupportTouch) {
if (!useModeTouch) {
return
}
// 定义变量
@ -68,7 +68,7 @@ const longpress = {
unbind(el) {
el.removeEventListener('contextmenu', el.__longpressContextmenu__)
delete el.__longpressContextmenu__
if (!isSupportTouch) {
if (!useModeTouch) {
return
}
el.removeEventListener('touchstart', el.__longpressStart__)

View File

@ -93,6 +93,16 @@
if (!$A.isEEUiApp) return;
return requireModuleJs("eeui").keyboardStatus();
},
eeuiAppSetHapticBackEnabled(val) {
if (!$A.isEEUiApp) return;
return requireModuleJs("webview").setHapticBackEnabled(val);
},
eeuiAppSetDisabledUserLongClickSelect(val) {
if (!$A.isEEUiApp) return;
return requireModuleJs("webview").setDisabledUserLongClickSelect(val);
},
});
window.$A = $;