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', () => {}) +})