1405/04/10-fix bugs

This commit is contained in:
2026-07-01 18:18:46 +03:30
parent c3aaeaf91a
commit 3a3a55287b
19 changed files with 2053 additions and 0 deletions
@@ -0,0 +1,35 @@
<template>
<div class="mpage-header wrap-fix">
<button
v-if="showBack"
type="button"
class="mpage-header__back"
@click="handleBack"
>
<BasicIcon icon="vuesax-linear:arrow-right-1" />
</button>
<div class="mpage-header__title">{{ title }}</div>
<div v-if="$slots.trailing" class="mpage-header__trailing">
<slot name="trailing" />
</div>
</div>
</template>
<script setup lang="ts">
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
import router from '@/router'
withDefaults(
defineProps<{
title: string
showBack?: boolean
}>(),
{
showBack: false,
},
)
function handleBack() {
router.back()
}
</script>
@@ -0,0 +1,125 @@
import { nextTick } from 'vue'
import router from '@/router'
let recoveryTimers: ReturnType<typeof setTimeout>[] = []
function clearRecoveryTimers() {
recoveryTimers.forEach(clearTimeout)
recoveryTimers = []
}
function blurFocusedField() {
const active = document.activeElement
if (active instanceof HTMLElement && active !== document.body) {
active.blur()
}
}
function clearBodyScrollLock() {
document.body.classList.remove('van-overflow-hidden')
document.body.style.removeProperty('position')
document.body.style.removeProperty('top')
document.body.style.removeProperty('left')
document.body.style.removeProperty('right')
document.body.style.removeProperty('width')
document.body.style.removeProperty('height')
document.body.style.removeProperty('min-height')
document.body.style.removeProperty('overflow')
document.body.style.removeProperty('transform')
document.documentElement.style.removeProperty('overflow')
document.documentElement.style.removeProperty('height')
document.documentElement.style.removeProperty('transform')
const appRoot = document.getElementById('app')
if (appRoot) {
appRoot.style.removeProperty('position')
appRoot.style.removeProperty('top')
appRoot.style.removeProperty('height')
appRoot.style.removeProperty('min-height')
appRoot.style.removeProperty('overflow')
appRoot.style.removeProperty('transform')
}
}
function resetAllScrollPositions() {
window.scrollTo(0, 0)
document.documentElement.scrollTop = 0
document.body.scrollTop = 0
document
.querySelectorAll('.main-with-bottom-chrome-inner, .login-page, .login-page-root')
.forEach((node) => {
if (node instanceof HTMLElement) {
node.scrollTop = 0
}
})
}
function kickViewportReflow() {
window.dispatchEvent(new Event('resize'))
if (window.visualViewport) {
window.scrollTo(0, 0)
}
}
function runViewportRecovery() {
clearBodyScrollLock()
resetAllScrollPositions()
kickViewportReflow()
}
function scheduleViewportRecovery() {
clearRecoveryTimers()
runViewportRecovery()
nextTick(() => {
requestAnimationFrame(() => {
runViewportRecovery()
for (const delay of [50, 150, 300, 500]) {
recoveryTimers.push(window.setTimeout(runViewportRecovery, delay))
}
})
})
}
/** Reset scroll offsets after navigation — fixes iOS safe-area drift. */
export function resetMobileAppScroll() {
runViewportRecovery()
nextTick(() => {
requestAnimationFrame(runViewportRecovery)
})
}
export async function dismissMobileKeyboard() {
blurFocusedField()
await new Promise((resolve) => window.setTimeout(resolve, 120))
}
export async function prepareMobileViewportForAppShell() {
blurFocusedField()
resetAllScrollPositions()
await dismissMobileKeyboard()
}
/** Full recovery after auth — runs after home shell is mounted. */
export function recoverMobileViewportAfterAuth() {
scheduleViewportRecovery()
}
export const resetMobileAppScrollAfterLogin = recoverMobileViewportAfterAuth
export async function completeLoginNavigation() {
await prepareMobileViewportForAppShell()
await router.push({ name: 'buyProduct' })
await router.isReady()
recoverMobileViewportAfterAuth()
}
export function initMobileScrollRestoration() {
if (typeof history !== 'undefined' && 'scrollRestoration' in history) {
history.scrollRestoration = 'manual'
}
}
+208
View File
@@ -0,0 +1,208 @@
/* Shared mobile page chrome (inner pages — not home .app-header) */
:root {
--mpage-header-bar: 2.75rem;
--mpage-header-offset: calc(4rem + var(--app-safe-top, env(safe-area-inset-top, 0px)));
--mpage-subheader-offset: calc(var(--mpage-header-bar) + var(--app-safe-top, env(safe-area-inset-top, 0px)));
--mpage-content-with-subheader: calc(6.5rem + var(--app-safe-top, env(safe-area-inset-top, 0px)));
--mpage-scroll-max-height: calc(100dvh - 50px - var(--app-safe-top, env(safe-area-inset-top, 0px)));
--mobile-info-support-block: calc(5rem + var(--app-safe-bottom, env(safe-area-inset-bottom, 0px)));
}
/* Fixed top bar: background fills under status bar; content sits below safe area */
.mobile-top-chrome {
top: 0;
box-sizing: border-box;
padding-top: calc(0.75rem + var(--app-safe-top, env(safe-area-inset-top, 0px)));
}
.mobile-top-chrome.h-12,
.mobile-top-chrome.min-h-12 {
height: auto;
min-height: calc(3rem + var(--app-safe-top, env(safe-area-inset-top, 0px)));
}
.mpage-header {
display: flex;
align-items: center;
gap: 0.5rem;
top: 0;
box-sizing: border-box;
padding: 0.75rem;
padding-top: calc(0.75rem + var(--app-safe-top, env(safe-area-inset-top, 0px)));
background: #fff;
color: @primary-color;
font-size: 1rem;
font-weight: 700;
line-height: 1.5;
box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
z-index: 1999;
&__back {
display: inline-flex;
align-items: center;
justify-content: center;
border: none;
background: transparent;
padding: 0;
color: inherit;
cursor: pointer;
font-family: inherit;
}
&__title {
flex: 1;
min-width: 0;
}
&__trailing {
display: inline-flex;
align-items: center;
flex-shrink: 0;
}
}
.mpage-subheader {
top: var(--mpage-subheader-offset);
z-index: 1999;
padding: 0.75rem;
background: #fff;
color: @primary-color;
font-weight: 700;
}
.mpage-content {
padding-top: var(--mpage-header-offset);
}
.mpage-content--with-subheader {
padding-top: var(--mpage-content-with-subheader);
}
.mpage-scroll {
overflow-y: auto;
max-height: var(--mpage-scroll-max-height);
}
.mobile-page-body--pt10 {
padding-top: calc(2.5rem + var(--app-safe-top, env(safe-area-inset-top, 0px)));
}
.mobile-page-body--pt15 {
padding-top: calc(3.75rem + var(--app-safe-top, env(safe-area-inset-top, 0px)));
}
.mobile-page-body--pt20 {
padding-top: calc(5rem + var(--app-safe-top, env(safe-area-inset-top, 0px)));
}
/* Info pages (about, educate): fixed shell, scroll inside content box only */
.mobile-info-page {
position: relative;
display: flex;
flex-direction: column;
height: 100%;
min-height: 0;
max-height: 100%;
overflow: hidden;
}
.mobile-info-page__header {
z-index: 1999;
}
/* Decorative page background — fixed to viewport, never scrolls on iOS */
.mobile-page-bg,
.mobile-info-page__bg {
pointer-events: none;
position: fixed;
z-index: 0;
top: 0;
left: 0;
right: 0;
bottom: var(--app-bottom-chrome-height, 80px);
overflow: hidden;
max-width: 100vw;
box-sizing: border-box;
img {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: auto;
}
}
.mobile-page-bg--no-nav,
.mobile-info-page__bg {
bottom: var(--app-credit-footer-offset, 0px);
}
.mobile-page-bg--cover {
background-size: cover;
background-position: center;
background-repeat: no-repeat;
}
html:not(.app-layout--desktop) {
@media screen and (min-width: 426px) and (max-width: 767.98px) {
.mobile-page-bg,
.mobile-info-page__bg {
width: 426px;
max-width: 426px;
left: 50%;
right: auto;
transform: translateX(-50%);
}
}
}
.mobile-info-page__main {
position: relative;
z-index: 1;
flex: 1 1 0;
min-height: 0;
display: flex;
flex-direction: column;
overflow: hidden;
padding-top: calc(var(--mpage-header-offset) + 1rem);
padding-right: 2.5rem;
padding-left: 2.5rem;
padding-bottom: calc(
var(--mobile-info-support-block, 5rem) + var(--app-credit-footer-offset, 0px) + 1.25rem
);
pointer-events: none;
> * {
pointer-events: auto;
}
}
.mobile-info-page__support {
bottom: var(--app-credit-footer-offset, 0px);
box-sizing: border-box;
padding: 1rem 2.5rem;
padding-bottom: calc(1rem + var(--app-safe-bottom, env(safe-area-inset-bottom, 0px)));
background: #fff;
box-shadow: 0 -2px 8px rgba(15, 23, 42, 0.06);
z-index: 1998;
}
.mobile-content-box {
display: flex;
flex-direction: column;
flex: 1 1 0;
min-height: 0;
overflow: hidden;
margin-bottom: 0.75rem;
}
.mobile-content-box__scroll {
flex: 1 1 0;
min-height: 0;
overflow-y: auto;
overflow-x: hidden;
-webkit-overflow-scrolling: touch;
overscroll-behavior-y: contain;
}