From 33bafebfdfab2eef105acebc3dd439b5541d7701 Mon Sep 17 00:00:00 2001 From: xingyy <64720302+Concur-max@users.noreply.github.com> Date: Tue, 25 Feb 2025 15:24:09 +0800 Subject: [PATCH] =?UTF-8?q?feat(login):=20=E6=A0=B9=E6=8D=AE=E9=94=AE?= =?UTF-8?q?=E7=9B=98=E7=8A=B6=E6=80=81=E8=B0=83=E6=95=B4=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加键盘可见性检测功能 - 在键盘弹出时隐藏登录按钮 - 使用 Vue 生命周期钩子监听窗口大小变化 --- app/pages/login/index.vue | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/app/pages/login/index.vue b/app/pages/login/index.vue index 0c88990..4e6ceb3 100644 --- a/app/pages/login/index.vue +++ b/app/pages/login/index.vue @@ -141,6 +141,23 @@ const goLogin =async () => { } loadingRef.value.loading2=false } +const isKeyboardVisible = ref(false) +const windowHeight = ref(window.innerHeight) + +onMounted(() => { + // 记录初始窗口高度 + windowHeight.value = window.innerHeight + + // 监听窗口大小变化 + window.addEventListener('resize', () => { + // 如果当前高度明显小于初始高度,认为键盘已打开 + isKeyboardVisible.value = window.innerHeight < windowHeight.value * 0.8 + }) +}) + +onUnmounted(() => { + window.removeEventListener('resize', () => {}) +})