Browse Source

离开homepage时卸载禁止滚动的组件,安卓输入框1

master
no99 1 day ago
parent
commit
5a50f7ff0d
  1. 72
      src/views/homePage.vue

72
src/views/homePage.vue

@ -487,21 +487,19 @@ const onBlur = function () {
}, 200); }, 200);
}; };
window.addEventListener("resize", () => {
// iOS
const isIOS = /iPhone|iPad|iPod|ios/i.test(navigator.userAgent);
console.log("是否为iOS设备:", isIOS);
if (!isIOS) {
console.log("窗口大小变化");
const homePage = document.querySelector(".homepage");
homePage.style.height = `${window.innerHeight}px`;
}
});
//
document.addEventListener(
"touchmove",
(e) => {
// window.addEventListener("resize", () => {
// // iOS
// const isIOS = /iPhone|iPad|iPod|ios/i.test(navigator.userAgent);
// console.log("iOS:", isIOS);
// if (!isIOS) {
// console.log("");
// const homePage = document.querySelector(".homepage");
// homePage.style.height = `${window.innerHeight}px`;
// }
// });
let touchmoveHandlerRef = null;
const touchmoveHandler = (e) => {
if (!dataStore.isFeedback) { if (!dataStore.isFeedback) {
// //
const isScrollableArea = e.target.closest(".tab-content"); const isScrollableArea = e.target.closest(".tab-content");
@ -511,9 +509,7 @@ document.addEventListener(
e.preventDefault(); e.preventDefault();
} }
} }
},
{ passive: false }
);
};
onMounted(async () => { onMounted(async () => {
// const isPhone = // const isPhone =
@ -525,6 +521,13 @@ onMounted(async () => {
// "localToken", // "localToken",
// decodeURIComponent(String(getQueryVariable("token"))) // decodeURIComponent(String(getQueryVariable("token")))
// ); // );
//
touchmoveHandlerRef = touchmoveHandler;
document.addEventListener("touchmove", touchmoveHandlerRef, {
passive: false,
});
setHeight(document.getElementById("testId")); // setHeight(document.getElementById("testId")); //
// //
await chatStore.getUserCount(); await chatStore.getUserCount();
@ -533,12 +536,45 @@ onMounted(async () => {
// //
throttledHeightListener(); throttledHeightListener();
const isAndroid = /Android/i.test(navigator.userAgent);
if (isAndroid) {
window.visualViewport.addEventListener("resize", () => {
const keyboardHeight = window.innerHeight - window.visualViewport.height;
console.log("视口大小变化", keyboardHeight);
// 100px
if (keyboardHeight > 100) {
const footer = document.querySelector(".el-footer");
footer.style.paddingBottom = `${keyboardHeight}px`;
//
setTimeout(() => {
const msgInput = document.querySelector(".msg-input");
if (msgInput) {
msgInput.scrollIntoView({ behavior: "smooth" });
}
}, 300);
} else {
//
const footer = document.querySelector(".el-footer");
footer.style.paddingBottom = "0px";
}
});
}
// //
// handleInputFocus(); // handleInputFocus();
// //
// updateAppHeight(); // updateAppHeight();
}); });
onUnmounted(() => {
if (touchmoveHandlerRef) {
console.log("卸载touchmoveHandlerRef组件");
document.removeEventListener("touchmove", touchmoveHandlerRef);
}
});
</script> </script>
<template> <template>

Loading…
Cancel
Save