修复(斗鱼领取): 提交按钮适配苹果浏览器滚动与安全区
This commit is contained in:
+20
-15
@@ -163,6 +163,7 @@ export default function App() {
|
||||
|
||||
function DouyuFulfillmentApplication() {
|
||||
useClearStrayHash()
|
||||
useCustomerMobileViewport()
|
||||
return (
|
||||
<BrowserRouter>
|
||||
<Suspense fallback={<RouteLoading />}>
|
||||
@@ -192,21 +193,7 @@ function OrderServiceApplication() {
|
||||
|
||||
function CustomerFulfillmentApplication() {
|
||||
useClearStrayHash()
|
||||
/**
|
||||
* 客户履约页固定移动端:
|
||||
* 全局 base.css 给 body 设了 min-width:320px,worker.css 又用 overflow-x:hidden
|
||||
* 裁掉横向溢出。应用内浏览器/分屏/系统显示放大时,实际视口可能小于 320px,
|
||||
* 页面右侧(输入框、商品值、提示文案)会被直接裁掉。
|
||||
* 这里只给客户履约路由挂移动端根类,覆盖最小宽度,不影响后台与打手端。
|
||||
*/
|
||||
useLayoutEffect(() => {
|
||||
document.documentElement.classList.add('customer-mobile-html')
|
||||
document.body.classList.add('customer-mobile-body')
|
||||
return () => {
|
||||
document.documentElement.classList.remove('customer-mobile-html')
|
||||
document.body.classList.remove('customer-mobile-body')
|
||||
}
|
||||
}, [])
|
||||
useCustomerMobileViewport()
|
||||
// 非标准子路径也按首段路径绑定平台,避免 /c/.../extra 这类地址绕过严格绑定。
|
||||
const prefix = window.location.pathname.split('/').filter(Boolean)[0]
|
||||
const wildcardPlatform = prefix === 'c' ? 'huya' : prefix === 'd' ? 'weibo' : undefined
|
||||
@@ -387,6 +374,24 @@ function useClearStrayHash() {
|
||||
}, [])
|
||||
}
|
||||
|
||||
/**
|
||||
* 客户领取/履约页固定按移动端处理:
|
||||
* 全局 base.css 给 body 设了 min-width:320px,worker.css 又用 overflow-x:hidden
|
||||
* 裁掉横向溢出。应用内浏览器/分屏/系统显示放大时,实际视口可能小于 320px,
|
||||
* 页面右侧(输入框、商品值、提示文案)会被直接裁掉。
|
||||
* 这里只给客户页面路由挂移动端根类,覆盖最小宽度,不影响后台与打手端。
|
||||
*/
|
||||
function useCustomerMobileViewport() {
|
||||
useLayoutEffect(() => {
|
||||
document.documentElement.classList.add('customer-mobile-html')
|
||||
document.body.classList.add('customer-mobile-body')
|
||||
return () => {
|
||||
document.documentElement.classList.remove('customer-mobile-html')
|
||||
document.body.classList.remove('customer-mobile-body')
|
||||
}
|
||||
}, [])
|
||||
}
|
||||
|
||||
function WorkerApplication() {
|
||||
return (
|
||||
<BrowserRouter>
|
||||
|
||||
@@ -413,15 +413,17 @@ export default function DouyuFulfillmentPage() {
|
||||
{roleNameIssue ? <ExclamationCircleOutlined aria-hidden="true" /> : null}
|
||||
<span>{roleNameIssue || DOUYU_ROLE_NAME_FORMAT_HINT}</span>
|
||||
</p>
|
||||
<Button
|
||||
block
|
||||
size="large"
|
||||
className="customer-collect-submit"
|
||||
loading={saving}
|
||||
onClick={() => void submitProfile()}
|
||||
>
|
||||
提交资料并继续
|
||||
</Button>
|
||||
<div className="customer-douyu-submit-bar">
|
||||
<Button
|
||||
block
|
||||
size="large"
|
||||
className="customer-collect-submit"
|
||||
loading={saving}
|
||||
onClick={() => void submitProfile()}
|
||||
>
|
||||
提交资料并继续
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
) : waitingForSupport ? (
|
||||
|
||||
@@ -13,6 +13,8 @@ body.customer-mobile-body {
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
overflow-x: hidden;
|
||||
scroll-padding-bottom: calc(96px + env(safe-area-inset-bottom));
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
|
||||
body.customer-mobile-body #root {
|
||||
|
||||
@@ -555,6 +555,15 @@
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.customer-douyu-submit-bar {
|
||||
min-width: 0;
|
||||
margin-top: 14px;
|
||||
}
|
||||
|
||||
.customer-douyu-submit-bar .customer-collect-submit.ant-btn {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.customer-auth-page.is-douyu .customer-douyu-role-name-help {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
@@ -589,3 +598,47 @@
|
||||
border-color: #4a83ff !important;
|
||||
background: #4a83ff !important;
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
/*
|
||||
* Safari 的地址栏和底部工具栏会动态压缩可视区域。资料阶段必须由页面滚动承载,
|
||||
* 不能把内容锁在 100vh 容器里;同时保留 dvh 和底部安全区,适配刘海屏与短屏。
|
||||
*/
|
||||
.customer-auth-page.is-douyu:not(.is-compact) {
|
||||
height: auto;
|
||||
min-height: 100vh;
|
||||
min-height: 100dvh;
|
||||
overflow-x: hidden;
|
||||
overflow-y: visible;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
|
||||
.customer-auth-page.is-douyu:not(.is-compact) .customer-auth-shell {
|
||||
height: auto;
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
.customer-auth-page.is-douyu:not(.is-compact) .customer-auth-main {
|
||||
padding-bottom: calc(40px + env(safe-area-inset-bottom));
|
||||
}
|
||||
|
||||
.customer-auth-page.is-douyu:not(.is-compact) .customer-collect-body {
|
||||
padding-bottom: calc(20px + env(safe-area-inset-bottom));
|
||||
}
|
||||
|
||||
.customer-auth-page.is-douyu:not(.is-compact) .customer-douyu-submit-bar {
|
||||
position: sticky;
|
||||
bottom: 0;
|
||||
z-index: 5;
|
||||
margin-inline: -16px;
|
||||
margin-top: 4px;
|
||||
padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
|
||||
background: linear-gradient(180deg, rgba(35, 41, 54, 0) 0%, #232936 28%, #232936 100%);
|
||||
}
|
||||
|
||||
.customer-auth-page.is-douyu.is-compact .customer-binding-stage {
|
||||
overflow-y: auto;
|
||||
overscroll-behavior-y: contain;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import { readFile } from 'node:fs/promises'
|
||||
import test from 'node:test'
|
||||
|
||||
function source(relativePath: string) {
|
||||
return new URL(`../src/${relativePath}`, import.meta.url)
|
||||
}
|
||||
|
||||
test('斗鱼客户页复用客户移动端根类,避免 iOS Safari 动态视口裁切', async () => {
|
||||
const [app, css] = await Promise.all([
|
||||
readFile(source('App.tsx'), 'utf8'),
|
||||
readFile(source('styles/customer/mobile.css'), 'utf8'),
|
||||
])
|
||||
|
||||
assert.match(
|
||||
app,
|
||||
/function DouyuFulfillmentApplication\(\)\s*\{[^}]*useCustomerMobileViewport\(\)/s,
|
||||
)
|
||||
assert.match(
|
||||
css,
|
||||
/html\.customer-mobile-html,\s*body\.customer-mobile-body\s*\{[^}]*scroll-padding-bottom:/s,
|
||||
)
|
||||
})
|
||||
|
||||
test('斗鱼资料提交按钮在手机端保持可见且页面可滚动', async () => {
|
||||
const [page, css] = await Promise.all([
|
||||
readFile(source('pages/douyu-fulfillment/DouyuFulfillmentPage.tsx'), 'utf8'),
|
||||
readFile(source('styles/customer/platform/douyu.css'), 'utf8'),
|
||||
])
|
||||
|
||||
assert.ok(page.includes('customer-douyu-submit-bar'))
|
||||
assert.match(
|
||||
css,
|
||||
/\.customer-auth-page\.is-douyu:not\(\.is-compact\)\s*\{[^}]*min-height:\s*100dvh;[^}]*overflow-y:\s*visible/s,
|
||||
)
|
||||
assert.match(
|
||||
css,
|
||||
/\.customer-auth-page\.is-douyu:not\(\.is-compact\) \.customer-douyu-submit-bar\s*\{[^}]*position:\s*sticky;[^}]*bottom:\s*0;[^}]*env\(safe-area-inset-bottom\)/s,
|
||||
)
|
||||
assert.match(
|
||||
css,
|
||||
/\.customer-auth-page\.is-douyu\.is-compact \.customer-binding-stage\s*\{[^}]*overflow-y:\s*auto/s,
|
||||
)
|
||||
})
|
||||
Reference in New Issue
Block a user