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

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.12",
3
+ "version": "2.10.18-beta.15",
4
4
  "description": "mpx runtime core",
5
5
  "keywords": [
6
6
  "miniprogram",
@@ -215,9 +215,9 @@ export default function createApp (options) {
215
215
  global.__mpxInitialRunParams = initialParams
216
216
  }
217
217
  const navScreenOpts = {
218
- headerShown: false,
219
- statusBarTranslucent: Mpx.config.rnConfig.statusBarTranslucent ?? true,
220
- statusBarBackgroundColor: 'transparent'
218
+ headerShown: false
219
+ // statusBarTranslucent: Mpx.config.rnConfig.statusBarTranslucent ?? true,
220
+ // statusBarBackgroundColor: 'transparent'
221
221
  }
222
222
 
223
223
  return createElement(SafeAreaProvider,
@@ -535,6 +535,24 @@ function getLayoutData (headerHeight) {
535
535
  }
536
536
  }
537
537
 
538
+ let hasRenderedSafeAreaInsets = false
539
+
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
+ }
551
+ }
552
+ }
553
+ return safeAreaInsets
554
+ }
555
+
538
556
  export function PageWrapperHOC (WrappedComponent, pageConfig = {}) {
539
557
  return function PageWrapperCom ({ navigation, route, ...props }) {
540
558
  const keyboardAvoidRef = useRef(null)
@@ -583,8 +601,8 @@ export function PageWrapperHOC (WrappedComponent, pageConfig = {}) {
583
601
  )
584
602
  )
585
603
  }
586
- // android存在第一次打开insets都返回为0情况,后续会触发第二次渲染后正确
587
- navigation.insets = useSafeAreaInsets()
604
+ // Android 全局首次渲染时对 safe area top 做兜底,避免 navigation.insets.top 短暂写入 0
605
+ navigation.insets = getSafeAreaInsetsWithInitialTop(useSafeAreaInsets())
588
606
  return withKeyboardAvoidingView(
589
607
  createElement(ReactNative.View,
590
608
  {