@mpxjs/core 2.10.18-beta.15 → 2.10.18-beta.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/core",
3
- "version": "2.10.18-beta.15",
3
+ "version": "2.10.18-beta.16",
4
4
  "description": "mpx runtime core",
5
5
  "keywords": [
6
6
  "miniprogram",
@@ -535,21 +535,25 @@ function getLayoutData (headerHeight) {
535
535
  }
536
536
  }
537
537
 
538
- let hasRenderedSafeAreaInsets = false
538
+ let hasResolvedSafeAreaTop = false
539
539
 
540
540
  function getSafeAreaInsetsWithInitialTop (safeAreaInsets) {
541
- if (ReactNative.Platform.OS === 'android' && !hasRenderedSafeAreaInsets) {
542
- hasRenderedSafeAreaInsets = true
543
- const initialTop = initialWindowMetrics?.insets?.top || 0
544
- if (safeAreaInsets?.top === 0 && initialTop) {
545
- // Android 首次渲染时 top 可能暂时为 0,仅全局兜底一次,后续使用 useSafeAreaInsets 的真实更新。
546
- // 返回新对象,避免修改 useSafeAreaInsets/context 产出的 insets 引用。
547
- return {
548
- ...safeAreaInsets,
549
- top: initialTop
550
- }
541
+ if (ReactNative.Platform.OS !== 'android' || hasResolvedSafeAreaTop) {
542
+ return safeAreaInsets
543
+ }
544
+ const initialTop = initialWindowMetrics?.insets?.top || 0
545
+ if (safeAreaInsets?.top === 0 && initialTop) {
546
+ // Android 初始化时 top 可能连续为 0(如红米 10 的 bottom 已更新但 top 仍为 0),此时持续兜底并保留其他 insets 的最新值。
547
+ // 返回新对象,避免修改 useSafeAreaInsets/context 返回的引用。
548
+ return {
549
+ ...safeAreaInsets,
550
+ top: initialTop
551
551
  }
552
552
  }
553
+ if (safeAreaInsets?.top > 0 || !initialTop) {
554
+ // 拿到真实 top 或没有可用初始值后,后续完全使用 useSafeAreaInsets 的更新。
555
+ hasResolvedSafeAreaTop = true
556
+ }
553
557
  return safeAreaInsets
554
558
  }
555
559
 
@@ -601,7 +605,7 @@ export function PageWrapperHOC (WrappedComponent, pageConfig = {}) {
601
605
  )
602
606
  )
603
607
  }
604
- // Android 全局首次渲染时对 safe area top 做兜底,避免 navigation.insets.top 短暂写入 0。
608
+ // Android 初始化期间持续兜底 safe area top,直到 useSafeAreaInsets 返回真实值。
605
609
  navigation.insets = getSafeAreaInsetsWithInitialTop(useSafeAreaInsets())
606
610
  return withKeyboardAvoidingView(
607
611
  createElement(ReactNative.View,