mirror of
https://github.com/kuaifan/dootask.git
synced 2026-02-01 18:38:13 +00:00
perf: 优化android体验
This commit is contained in:
parent
fe5f56e98b
commit
985c5ff54b
62
resources/assets/js/directives/touchclick.js
vendored
Executable file
62
resources/assets/js/directives/touchclick.js
vendored
Executable file
@ -0,0 +1,62 @@
|
|||||||
|
const isSupportTouch = "ontouchend" in document;
|
||||||
|
export default {
|
||||||
|
bind (el, binding) {
|
||||||
|
if (isSupportTouch) {
|
||||||
|
const touchData = {
|
||||||
|
move: false,
|
||||||
|
time: 0,
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
};
|
||||||
|
el.__touchEvent__ = {
|
||||||
|
start: e => {
|
||||||
|
e.preventDefault();
|
||||||
|
touchData.move = false;
|
||||||
|
touchData.time = new Date().getTime();
|
||||||
|
touchData.x = e.touches ? e.touches[0].clientX : e.clientX;
|
||||||
|
touchData.y = e.touches ? e.touches[0].clientY : e.clientY;
|
||||||
|
},
|
||||||
|
move: e => {
|
||||||
|
if (touchData.time > 0) {
|
||||||
|
const x = e.touches ? e.touches[0].clientX : e.clientX;
|
||||||
|
const y = e.touches ? e.touches[0].clientY : e.clientY;
|
||||||
|
if (Math.abs(x - touchData.x) > 5 || Math.abs(y - touchData.y) > 5) {
|
||||||
|
touchData.move = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
end: _ => {
|
||||||
|
if (touchData.time > 0) {
|
||||||
|
if (!touchData.move && new Date().getTime() - touchData.time < 300) {
|
||||||
|
binding.value();
|
||||||
|
}
|
||||||
|
touchData.time = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
el.addEventListener('touchstart', el.__touchEvent__.start);
|
||||||
|
el.addEventListener('touchmove', el.__touchEvent__.move);
|
||||||
|
el.addEventListener('touchend', el.__touchEvent__.end);
|
||||||
|
} else {
|
||||||
|
el.__clickEvent__ = e => {
|
||||||
|
e.preventDefault();
|
||||||
|
binding.value();
|
||||||
|
};
|
||||||
|
el.addEventListener('click', el.__clickEvent__);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
update () {
|
||||||
|
|
||||||
|
},
|
||||||
|
unbind (el) {
|
||||||
|
if (isSupportTouch) {
|
||||||
|
el.removeEventListener('touchstart', el.__touchEvent__.start);
|
||||||
|
el.removeEventListener('touchmove', el.__touchEvent__.move);
|
||||||
|
el.removeEventListener('touchend', el.__touchEvent__.end);
|
||||||
|
delete el.__touchEvent__;
|
||||||
|
} else {
|
||||||
|
el.removeEventListener('click', el.__clickEvent__);
|
||||||
|
delete el.__clickEvent__;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
58
resources/assets/js/directives/touchmouse.js
vendored
58
resources/assets/js/directives/touchmouse.js
vendored
@ -2,30 +2,32 @@ const isSupportTouch = "ontouchend" in document;
|
|||||||
export default {
|
export default {
|
||||||
bind (el, binding) {
|
bind (el, binding) {
|
||||||
let isTouch = false;
|
let isTouch = false;
|
||||||
el.__touchMouseDown__ = e => {
|
el.__touchEvent__ = {
|
||||||
e.preventDefault();
|
start: e => {
|
||||||
isTouch = true;
|
e.preventDefault();
|
||||||
binding.value("down", e);
|
isTouch = true;
|
||||||
};
|
binding.value("down", e);
|
||||||
el.__touchMouseMove__ = e => {
|
},
|
||||||
if (isTouch) {
|
move: e => {
|
||||||
binding.value("move", e);
|
if (isTouch) {
|
||||||
}
|
binding.value("move", e);
|
||||||
};
|
}
|
||||||
el.__touchMouseUp__ = _ => {
|
},
|
||||||
if (isTouch) {
|
end: _ => {
|
||||||
isTouch = false;
|
if (isTouch) {
|
||||||
binding.value("up");
|
isTouch = false;
|
||||||
|
binding.value("up");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (isSupportTouch) {
|
if (isSupportTouch) {
|
||||||
el.addEventListener('touchstart', el.__touchMouseDown__);
|
el.addEventListener('touchstart', el.__touchEvent__.start);
|
||||||
el.addEventListener('touchmove', el.__touchMouseMove__);
|
el.addEventListener('touchmove', el.__touchEvent__.move);
|
||||||
el.addEventListener('touchend', el.__touchMouseUp__);
|
el.addEventListener('touchend', el.__touchEvent__.end);
|
||||||
} else {
|
} else {
|
||||||
el.addEventListener('mousedown', el.__touchMouseDown__);
|
el.addEventListener('mousedown', el.__touchEvent__.start);
|
||||||
document.addEventListener('mousemove', el.__touchMouseMove__);
|
document.addEventListener('mousemove', el.__touchEvent__.move);
|
||||||
document.addEventListener('mouseup', el.__touchMouseUp__);
|
document.addEventListener('mouseup', el.__touchEvent__.end);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
update () {
|
update () {
|
||||||
@ -33,16 +35,14 @@ export default {
|
|||||||
},
|
},
|
||||||
unbind (el) {
|
unbind (el) {
|
||||||
if (isSupportTouch) {
|
if (isSupportTouch) {
|
||||||
el.removeEventListener('touchstart', el.__touchMouseDown__);
|
el.removeEventListener('touchstart', el.__touchEvent__.start);
|
||||||
el.removeEventListener('touchmove', el.__touchMouseMove__);
|
el.removeEventListener('touchmove', el.__touchEvent__.move);
|
||||||
el.removeEventListener('touchend', el.__touchMouseUp__);
|
el.removeEventListener('touchend', el.__touchEvent__.end);
|
||||||
} else {
|
} else {
|
||||||
el.removeEventListener('mousedown', el.__touchMouseDown__);
|
el.removeEventListener('mousedown', el.__touchEvent__.start);
|
||||||
document.removeEventListener('mousemove', el.__touchMouseMove__);
|
document.removeEventListener('mousemove', el.__touchEvent__.move);
|
||||||
document.removeEventListener('mouseup', el.__touchMouseUp__);
|
document.removeEventListener('mouseup', el.__touchEvent__.end);
|
||||||
}
|
}
|
||||||
delete el.__touchMouseDown__;
|
delete el.__touchEvent__;
|
||||||
delete el.__touchMouseMove__;
|
|
||||||
delete el.__touchMouseUp__;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
16
resources/assets/js/functions/eeui.js
vendored
16
resources/assets/js/functions/eeui.js
vendored
@ -153,18 +153,28 @@
|
|||||||
|
|
||||||
eeuiAppSetVariate(key, value) {
|
eeuiAppSetVariate(key, value) {
|
||||||
if (!$A.isEEUiApp) return;
|
if (!$A.isEEUiApp) return;
|
||||||
return $A.eeuiModuleSync("eeui").setVariate(key, value);
|
$A.eeuiModuleSync("eeui").setVariate(key, value);
|
||||||
},
|
},
|
||||||
|
|
||||||
eeuiAppSetHapticBackEnabled(val) {
|
eeuiAppSetHapticBackEnabled(val) {
|
||||||
if (!$A.isEEUiApp) return;
|
if (!$A.isEEUiApp) return;
|
||||||
return $A.eeuiModuleSync("webview").setHapticBackEnabled(val);
|
$A.eeuiModuleSync("webview").setHapticBackEnabled(val);
|
||||||
},
|
},
|
||||||
|
|
||||||
eeuiAppSetDisabledUserLongClickSelect(val) {
|
eeuiAppSetDisabledUserLongClickSelect(val) {
|
||||||
if (!$A.isEEUiApp) return;
|
if (!$A.isEEUiApp) return;
|
||||||
return $A.eeuiModuleSync("webview").setDisabledUserLongClickSelect(val);
|
$A.__disabledUserLongClickSelectTimer && clearTimeout($A.__disabledUserLongClickSelectTimer);
|
||||||
|
if (/^\d+$/.test(val)) {
|
||||||
|
$A.eeuiModuleSync("webview").setDisabledUserLongClickSelect(true);
|
||||||
|
$A.__disabledUserLongClickSelectTimer = setTimeout(() => {
|
||||||
|
$A.__disabledUserLongClickSelectTimer = null;
|
||||||
|
$A.eeuiModuleSync("webview").setDisabledUserLongClickSelect(false);
|
||||||
|
}, val);
|
||||||
|
} else {
|
||||||
|
$A.eeuiModuleSync("webview").setDisabledUserLongClickSelect(val);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
__disabledUserLongClickSelectTimer: null,
|
||||||
|
|
||||||
eeuiAppCopyText(text) {
|
eeuiAppCopyText(text) {
|
||||||
if (!$A.isEEUiApp) return;
|
if (!$A.isEEUiApp) return;
|
||||||
|
|||||||
@ -29,7 +29,7 @@
|
|||||||
<div v-if="quoteUpdate" class="quote-label">{{$L('编辑消息')}}</div>
|
<div v-if="quoteUpdate" class="quote-label">{{$L('编辑消息')}}</div>
|
||||||
<UserAvatar v-else :userid="quoteData.userid" :userResult="onQuoteUserResult" :show-icon="false" :show-name="true"/>
|
<UserAvatar v-else :userid="quoteData.userid" :userResult="onQuoteUserResult" :show-icon="false" :show-name="true"/>
|
||||||
<div class="quote-desc no-dark-content">{{$A.getMsgSimpleDesc(quoteData)}}</div>
|
<div class="quote-desc no-dark-content">{{$A.getMsgSimpleDesc(quoteData)}}</div>
|
||||||
<i class="taskfont" @click.stop="cancelQuote"></i>
|
<i class="taskfont" v-touchclick="cancelQuote"></i>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 输入框 -->
|
<!-- 输入框 -->
|
||||||
@ -215,6 +215,7 @@ import Quill from 'quill';
|
|||||||
import "quill-mention-hi";
|
import "quill-mention-hi";
|
||||||
import ChatEmoji from "./emoji";
|
import ChatEmoji from "./emoji";
|
||||||
import touchmouse from "../../../../directives/touchmouse";
|
import touchmouse from "../../../../directives/touchmouse";
|
||||||
|
import touchclick from "../../../../directives/touchclick";
|
||||||
import TransferDom from "../../../../directives/transfer-dom";
|
import TransferDom from "../../../../directives/transfer-dom";
|
||||||
import clickoutside from "../../../../directives/clickoutside";
|
import clickoutside from "../../../../directives/clickoutside";
|
||||||
import longpress from "../../../../directives/longpress";
|
import longpress from "../../../../directives/longpress";
|
||||||
@ -224,7 +225,7 @@ import {Store} from "le5le-store";
|
|||||||
export default {
|
export default {
|
||||||
name: 'ChatInput',
|
name: 'ChatInput',
|
||||||
components: {ChatEmoji},
|
components: {ChatEmoji},
|
||||||
directives: {touchmouse, TransferDom, clickoutside, longpress},
|
directives: {touchmouse, touchclick, TransferDom, clickoutside, longpress},
|
||||||
props: {
|
props: {
|
||||||
value: {
|
value: {
|
||||||
type: [String, Number],
|
type: [String, Number],
|
||||||
|
|||||||
@ -214,7 +214,7 @@
|
|||||||
<div
|
<div
|
||||||
v-if="scrollTail > 500 || (msgNew > 0 && allMsgs.length > 0)"
|
v-if="scrollTail > 500 || (msgNew > 0 && allMsgs.length > 0)"
|
||||||
class="dialog-goto"
|
class="dialog-goto"
|
||||||
@click="onToBottom">
|
v-touchclick="onToBottom">
|
||||||
<Badge :overflow-count="999" :count="msgNew">
|
<Badge :overflow-count="999" :count="msgNew">
|
||||||
<i class="taskfont"></i>
|
<i class="taskfont"></i>
|
||||||
</Badge>
|
</Badge>
|
||||||
@ -630,7 +630,7 @@ import DialogGroupInfo from "./DialogGroupInfo";
|
|||||||
import DialogRespond from "./DialogRespond";
|
import DialogRespond from "./DialogRespond";
|
||||||
import ChatInput from "./ChatInput";
|
import ChatInput from "./ChatInput";
|
||||||
|
|
||||||
import VirtualList from 'vue-virtual-scroll-list-hi'
|
import VirtualList from "vue-virtual-scroll-list-hi"
|
||||||
import {Store} from "le5le-store";
|
import {Store} from "le5le-store";
|
||||||
import ImgUpload from "../../../components/ImgUpload.vue";
|
import ImgUpload from "../../../components/ImgUpload.vue";
|
||||||
import {choiceEmojiOne} from "./ChatInput/one";
|
import {choiceEmojiOne} from "./ChatInput/one";
|
||||||
@ -640,6 +640,7 @@ import UserSelect from "../../../components/UserSelect.vue";
|
|||||||
import UserAvatarTip from "../../../components/UserAvatar/tip.vue";
|
import UserAvatarTip from "../../../components/UserAvatar/tip.vue";
|
||||||
import DialogGroupWordChain from "./DialogGroupWordChain";
|
import DialogGroupWordChain from "./DialogGroupWordChain";
|
||||||
import DialogGroupVote from "./DialogGroupVote";
|
import DialogGroupVote from "./DialogGroupVote";
|
||||||
|
import touchclick from "../../../directives/touchclick";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "DialogWrapper",
|
name: "DialogWrapper",
|
||||||
@ -658,6 +659,7 @@ export default {
|
|||||||
DialogGroupWordChain,
|
DialogGroupWordChain,
|
||||||
DialogGroupVote,
|
DialogGroupVote,
|
||||||
},
|
},
|
||||||
|
directives: {touchclick},
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
dialogId: {
|
dialogId: {
|
||||||
@ -1427,6 +1429,12 @@ export default {
|
|||||||
readLoadNum() {
|
readLoadNum() {
|
||||||
this.positionShow = true
|
this.positionShow = true
|
||||||
},
|
},
|
||||||
|
|
||||||
|
operateVisible(val) {
|
||||||
|
if (!val) {
|
||||||
|
document.getSelection().removeAllRanges();
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
@ -1958,6 +1966,9 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
onTouchStart(e) {
|
onTouchStart(e) {
|
||||||
|
if ($A.isAndroid() && $A.eeuiAppKeyboardStatus()) {
|
||||||
|
$A.eeuiAppSetDisabledUserLongClickSelect(500);
|
||||||
|
}
|
||||||
this.wrapperStart = null;
|
this.wrapperStart = null;
|
||||||
if (this.selectedTextStatus) {
|
if (this.selectedTextStatus) {
|
||||||
this.wrapperStart = window.scrollY
|
this.wrapperStart = window.scrollY
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user