diff --git a/packages/api-proxy/src/platform/api/create-intersection-observer/rnIntersectionObserver.js b/packages/api-proxy/src/platform/api/create-intersection-observer/rnIntersectionObserver.js
index be4dcba705..6d80669f14 100644
--- a/packages/api-proxy/src/platform/api/create-intersection-observer/rnIntersectionObserver.js
+++ b/packages/api-proxy/src/platform/api/create-intersection-observer/rnIntersectionObserver.js
@@ -95,22 +95,25 @@ class RNIntersectionObserver {
const navigationLayout = navigation.layout || {
x: 0,
y: 0,
+ top: 0,
+ left: 0,
width: screen.width,
height: screen.height
}
const windowRect = {
- top: navigationLayout.y - this.margins.top,
+ top: navigationLayout.top - this.margins.top,
left: 0 - this.margins.left,
right: navigationLayout.width + this.margins.right,
- bottom: navigationLayout.y + navigationLayout.height + this.margins.bottom
+ bottom: navigationLayout.top + navigationLayout.height + this.margins.bottom
}
-
this.windowRect = windowRect
return this.windowRect
}
_getReferenceRect (targetRef) {
+ const navigation = getFocusedNavigation() || {}
+ const layout = navigation.layout || {}
const targetRefs = isArray(targetRef) ? targetRef : [targetRef]
const targetPromiseQueue = []
targetRefs.forEach((targetRefItem) => {
@@ -128,11 +131,12 @@ class RNIntersectionObserver {
targetPromiseQueue.push(new Promise((resolve) => {
target.measureInWindow(
(x, y, width, height) => {
+ // 安卓measureInWindow的参考值在android下为statubar的左下角,因此top需要调整一下
const boundingClientRect = {
left: x,
- top: y,
+ top: y + layout.statusBarHeight || 0,
right: x + width,
- bottom: y + height,
+ bottom: y + height + layout.statusBarHeight || 0,
width: width,
height: height
}
@@ -153,19 +157,16 @@ class RNIntersectionObserver {
return Math.min(Math.max(start, value), end)
}
- _isInsectedFn (intersectionRatio, previousIntersectionRatio, thresholds) {
- // console.log('nowintersectionRatio, previousIntersectionRatio', [intersectionRatio, previousIntersectionRatio])
- let nowIndex = -1
- let previousIndex = -1
+ _getRatioIndex (ratio, thresholds = []) {
+ if (ratio === 0 && thresholds.includes(0)) return -1
+ if (ratio === 1 && thresholds.includes(1)) return thresholds.length
+ let returnIndex = -1
thresholds.forEach((item, index) => {
- if (intersectionRatio >= item) {
- nowIndex = index
- }
- if (previousIntersectionRatio >= item) {
- previousIndex = index
+ if (ratio >= item) {
+ returnIndex = index
}
})
- return !(nowIndex === previousIndex)
+ return returnIndex
}
// 计算相交区域
@@ -180,10 +181,8 @@ class RNIntersectionObserver {
const targetArea = (observeRect.bottom - observeRect.top) * (observeRect.right - observeRect.left)
const visibleArea = (visibleRect.bottom - visibleRect.top) * (visibleRect.right - visibleRect.left)
const intersectionRatio = targetArea ? visibleArea / targetArea : 0
-
- const isInsected = isInit ? intersectionRatio > this.initialRatio : this._isInsectedFn(intersectionRatio, this.previousIntersectionRatio[observeIndex], this.thresholds)
+ const isInsected = isInit ? intersectionRatio > this.initialRatio : !(this._getRatioIndex(intersectionRatio, this.thresholds) === this._getRatioIndex(this.previousIntersectionRatio[observeIndex], this.thresholds))
this.previousIntersectionRatio[observeIndex] = intersectionRatio
-
return {
intersectionRatio,
intersectionRect: {
@@ -217,7 +216,6 @@ class RNIntersectionObserver {
relativeRect,
isInit
})
- // 初次调用的
if (isInsected) {
this.callback({
// index: index,
diff --git a/packages/api-proxy/src/platform/api/set-navigation-bar/index.ios.js b/packages/api-proxy/src/platform/api/set-navigation-bar/index.ios.js
index 927e2a3108..013aa1dae4 100644
--- a/packages/api-proxy/src/platform/api/set-navigation-bar/index.ios.js
+++ b/packages/api-proxy/src/platform/api/set-navigation-bar/index.ios.js
@@ -7,7 +7,9 @@ function setNavigationBarTitle (options = {}) {
failHandle({ errMsg: 'setNavigationBarTitle:fail' }, fail, complete)
} else {
nextTick(() => {
- navigation.setOptions({ title: title.trim() })
+ navigation.setPageConfig({
+ navigationBarTitleText: title.trim()
+ })
successHandle({ errMsg: 'setNavigationBarTitle:ok' }, success, complete)
})
}
@@ -20,11 +22,9 @@ function setNavigationBarColor (options = {}) {
failHandle({ errMsg: 'setNavigationBarColor:fail' }, fail, complete)
} else {
nextTick(() => {
- navigation.setOptions({
- headerStyle: {
- backgroundColor: backgroundColor
- },
- headerTintColor: frontColor
+ navigation.setPageConfig({
+ navigationBarBackgroundColor: backgroundColor,
+ navigationBarTextStyle: frontColor
})
successHandle({ errMsg: 'setNavigationBarColor:ok' }, success, complete)
})
diff --git a/packages/api-proxy/src/platform/api/system/rnSystem.js b/packages/api-proxy/src/platform/api/system/rnSystem.js
index f77ad76ef1..844a27d629 100644
--- a/packages/api-proxy/src/platform/api/system/rnSystem.js
+++ b/packages/api-proxy/src/platform/api/system/rnSystem.js
@@ -7,10 +7,9 @@ const getWindowInfo = function () {
const navigation = getFocusedNavigation() || {}
const initialWindowMetricsInset = initialWindowMetrics?.insets || {}
const navigationInsets = navigation.insets || {}
- const insets = Object.assign(initialWindowMetricsInset, navigationInsets)
+ const insets = Object.assign({}, initialWindowMetricsInset, navigationInsets)
let safeArea = {}
const { top = 0, bottom = 0, left = 0, right = 0 } = insets
-
const screenHeight = __mpx_mode__ === 'ios' ? dimensionsScreen.height : dimensionsScreen.height - bottom // 解决安卓开启屏幕内三建导航安卓把安全区计算进去后产生的影响
const screenWidth = __mpx_mode__ === 'ios' ? dimensionsScreen.width : dimensionsScreen.width - right
const layout = navigation.layout || {}
diff --git a/packages/core/package.json b/packages/core/package.json
index e835575e7a..a32402157c 100644
--- a/packages/core/package.json
+++ b/packages/core/package.json
@@ -1,6 +1,6 @@
{
"name": "@mpxjs/core",
- "version": "2.10.4",
+ "version": "2.10.4-beta.1",
"description": "mpx runtime core",
"keywords": [
"miniprogram",
diff --git a/packages/core/src/platform/createApp.ios.js b/packages/core/src/platform/createApp.ios.js
index e395571458..50f8d5fb46 100644
--- a/packages/core/src/platform/createApp.ios.js
+++ b/packages/core/src/platform/createApp.ios.js
@@ -7,7 +7,7 @@ import Mpx from '../index'
import { createElement, memo, useRef, useEffect } from 'react'
import * as ReactNative from 'react-native'
import { initAppProvides } from './export/inject'
-import { NavigationContainer, createStackNavigator, SafeAreaProvider } from './env/navigationHelper'
+import { NavigationContainer, createNativeStackNavigator, SafeAreaProvider } from './env/navigationHelper'
const appHooksMap = makeMap(mergeLifecycle(LIFECYCLE).app)
@@ -52,25 +52,25 @@ export default function createApp (options) {
const pages = currentInject.getPages() || {}
const firstPage = currentInject.firstPage
- const Stack = createStackNavigator()
+ const Stack = createNativeStackNavigator()
const getPageScreens = (initialRouteName, initialParams) => {
return Object.entries(pages).map(([key, item]) => {
- const options = {
- // __mpxPageStatusMap 为编译注入的全局变量
- headerShown: !(Object.assign({}, global.__mpxPageConfig, global.__mpxPageConfigsMap[key]).navigationStyle === 'custom')
- }
+ // const options = {
+ // // __mpxPageStatusMap 为编译注入的全局变量
+ // headerShown: !(Object.assign({}, global.__mpxPageConfig, global.__mpxPageConfigsMap[key]).navigationStyle === 'custom')
+ // }
if (key === initialRouteName) {
return createElement(Stack.Screen, {
name: key,
component: item,
- initialParams,
- options
+ initialParams
+ // options
})
}
return createElement(Stack.Screen, {
name: key,
- component: item,
- options
+ component: item
+ // options
})
})
}
@@ -195,32 +195,10 @@ export default function createApp (options) {
const { initialRouteName, initialParams } = initialRouteRef.current
const navScreenOpts = {
- // 7.x替换headerBackTitleVisible
- // headerBackButtonDisplayMode: 'minimal',
- headerBackTitleVisible: false,
- headerShadowVisible: false
- // 整体切换native-stack时进行修改如下
- // statusBarTranslucent: true,
- // statusBarBackgroundColor: 'transparent'
- }
- if (__mpx_mode__ === 'ios') {
- // ios使用native-stack
- const headerBackImageSource = Mpx.config.rnConfig.headerBackImageSource || null
- if (headerBackImageSource) {
- navScreenOpts.headerBackImageSource = headerBackImageSource
- }
- } else {
- // 安卓上会出现导航条闪现的问题所以默认加headerShown false(stack版本, native-stack版本可以干掉)
- // iOS加上默认headerShown false的话会因为iOS根高度是screenHeight - useHeaderHeight()会导致出现渲染两次情况,因此iOS不加此默认值
- navScreenOpts.headerShown = false
- // 安卓和鸿蒙先用stack
- const headerBackImageProps = Mpx.config.rnConfig.headerBackImageProps || null
- if (headerBackImageProps) {
- navScreenOpts.headerBackImage = () => {
- return createElement(ReactNative.Image, headerBackImageProps)
- }
- }
- }
+ headerShown: false,
+ statusBarTranslucent: true,
+ statusBarBackgroundColor: 'transparent'
+ }
return createElement(SafeAreaProvider,
null,
diff --git a/packages/core/src/platform/env/nav.js b/packages/core/src/platform/env/nav.js
new file mode 100644
index 0000000000..ab06766efa
--- /dev/null
+++ b/packages/core/src/platform/env/nav.js
@@ -0,0 +1,108 @@
+import { createElement, useState, useMemo } from 'react'
+import { useSafeAreaInsets } from 'react-native-safe-area-context'
+import * as ReactNative from 'react-native'
+import Mpx from '../../index'
+
+export function useInnerHeaderHeight (pageconfig) {
+ if (pageconfig.navigationStyle === 'custom') {
+ return 0
+ } else {
+ const safeAreaTop = useSafeAreaInsets()?.top || 0
+ const headerHeight = safeAreaTop + getTitleHeight()
+ return headerHeight
+ }
+}
+
+// 固定写死高度
+function getTitleHeight () {
+ return 44
+}
+
+// 计算颜色亮度
+const getColorBrightness = (color) => {
+ const processedColor = ReactNative.processColor(color)
+ if (typeof processedColor === 'number') {
+ const r = (processedColor >> 16) & 255
+ const g = (processedColor >> 8) & 255
+ const b = processedColor & 255
+ return (r * 299 + g * 587 + b * 114) / 1000
+ }
+ return 0
+}
+
+const styles = ReactNative.StyleSheet.create({
+ header: {
+ elevation: 3
+ },
+ headerContent: {
+ flexDirection: 'row',
+ alignItems: 'center',
+ justifyContent: 'center'
+ },
+ backButton: {
+ position: 'absolute',
+ height: '100%',
+ width: 40,
+ left: 0,
+ top: 0,
+ alignItems: 'center',
+ justifyContent: 'center'
+ },
+ backButtonImage: {
+ width: 22,
+ height: 22
+ },
+ title: {
+ fontSize: 17,
+ fontWeight: 600
+ }
+})
+
+export function innerNav ({ props, navigation }) {
+ const { pageConfig } = props
+ const [innerPageConfig, setPageConfig] = useState(pageConfig || {})
+ navigation.setPageConfig = (config) => {
+ const newConfig = Object.assign({}, innerPageConfig, config)
+ setPageConfig(newConfig)
+ }
+
+ const isCustom = innerPageConfig.navigationStyle === 'custom'
+ if (isCustom) return null
+ const safeAreaTop = useSafeAreaInsets()?.top || 0
+
+ // 回退按钮的颜色,根据背景色的亮度来进行调节
+ const backButtonColor = useMemo(() => {
+ return getColorBrightness(innerPageConfig.navigationBarBackgroundColor) > 128 ? '#000000' : '#ffffff'
+ }, [innerPageConfig.navigationBarBackgroundColor])
+
+ // 假设是栈导航,获取栈的长度
+ const stackLength = navigation.getState()?.routes?.length
+ // 用于外部注册打开RN容器之前的栈长度
+ const beforeStackLength = Mpx.config?.rnConfig?.beforeStackLength || 0
+
+ // 回退按钮与图标
+ const backElement = stackLength + beforeStackLength > 1
+ ? createElement(ReactNative.TouchableOpacity, {
+ style: [styles.backButton],
+ onPress: () => { navigation.goBack() }
+ }, createElement(ReactNative.Image, {
+ source: { uri: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAABICAYAAACqT5alAAAA2UlEQVR4nO3bMQrCUBRE0Yla6AYEN2nnBrTL+izcitW3MRDkEUWSvPzJvfCqgMwhZbAppWhNbbIHzB1g9wATERFRVyvpkj1irlpJ5X326D7WHh1hbdFD2CLpLmmftm7kfsEe09aNHFiBrT+wAlt/YAW2/sAKbP2BFdj6Ayuwy+ufz6XPL893krZ//O6iu2n4LT8kndLWTRTo4EC7BDo40C6BDg60S6CDA+0S6OBAuwQ6uNWiD2nrJmoIfU7cNWkR2hbb1UfbY7uuWhGWiIg+a/iHuHmA3QPs3gu4JW9Gan+OJAAAAABJRU5ErkJggg==' },
+ style: [styles.backButtonImage, { tintColor: backButtonColor }]
+ }))
+ : null
+
+ return createElement(ReactNative.View, {
+ style: [styles.header, {
+ paddingTop: safeAreaTop,
+ backgroundColor: innerPageConfig.navigationBarBackgroundColor || '#000000'
+ }]
+ },
+ createElement(ReactNative.View, {
+ style: styles.headerContent,
+ height: getTitleHeight()
+ }, backElement,
+ createElement(ReactNative.Text, {
+ style: [styles.title, { color: innerPageConfig.navigationBarTextStyle || 'white' }]
+ }, innerPageConfig.navigationBarTitleText?.trim() || ''))
+ )
+}
diff --git a/packages/core/src/platform/env/navigationHelper.android.js b/packages/core/src/platform/env/navigationHelper.android.js
index 67ca763894..1c0df7099e 100644
--- a/packages/core/src/platform/env/navigationHelper.android.js
+++ b/packages/core/src/platform/env/navigationHelper.android.js
@@ -1,4 +1,4 @@
-import { createStackNavigator } from '@react-navigation/stack'
+import { createNativeStackNavigator } from '@react-navigation/native-stack'
import { NavigationContainer, StackActions } from '@react-navigation/native'
import PortalHost from '@mpxjs/webpack-plugin/lib/runtime/components/react/dist/mpx-portal/portal-host'
import { useHeaderHeight } from '@react-navigation/elements'
@@ -6,7 +6,7 @@ import { SafeAreaProvider, useSafeAreaInsets } from 'react-native-safe-area-cont
import { GestureHandlerRootView } from 'react-native-gesture-handler'
export {
- createStackNavigator,
+ createNativeStackNavigator,
NavigationContainer,
useHeaderHeight,
StackActions,
diff --git a/packages/core/src/platform/env/navigationHelper.ios.js b/packages/core/src/platform/env/navigationHelper.ios.js
index 4acf8c5b54..1c0df7099e 100644
--- a/packages/core/src/platform/env/navigationHelper.ios.js
+++ b/packages/core/src/platform/env/navigationHelper.ios.js
@@ -1,4 +1,4 @@
-import { createNativeStackNavigator as createStackNavigator } from '@react-navigation/native-stack'
+import { createNativeStackNavigator } from '@react-navigation/native-stack'
import { NavigationContainer, StackActions } from '@react-navigation/native'
import PortalHost from '@mpxjs/webpack-plugin/lib/runtime/components/react/dist/mpx-portal/portal-host'
import { useHeaderHeight } from '@react-navigation/elements'
@@ -6,7 +6,7 @@ import { SafeAreaProvider, useSafeAreaInsets } from 'react-native-safe-area-cont
import { GestureHandlerRootView } from 'react-native-gesture-handler'
export {
- createStackNavigator,
+ createNativeStackNavigator,
NavigationContainer,
useHeaderHeight,
StackActions,
diff --git a/packages/core/src/platform/patch/getDefaultOptions.ios.js b/packages/core/src/platform/patch/getDefaultOptions.ios.js
index b1f5682482..103e8ebf81 100644
--- a/packages/core/src/platform/patch/getDefaultOptions.ios.js
+++ b/packages/core/src/platform/patch/getDefaultOptions.ios.js
@@ -1,4 +1,4 @@
-import { useEffect, useLayoutEffect, useSyncExternalStore, useRef, useMemo, createElement, memo, forwardRef, useImperativeHandle, useContext, Fragment, cloneElement, createContext } from 'react'
+import { useEffect, useSyncExternalStore, useRef, useMemo, createElement, memo, forwardRef, useImperativeHandle, useContext, Fragment, cloneElement, createContext } from 'react'
import * as ReactNative from 'react-native'
import { ReactiveEffect } from '../../observer/effect'
import { watch } from '../../observer/watch'
@@ -15,7 +15,8 @@ import {
KeyboardAvoidContext,
RouteContext
} from '@mpxjs/webpack-plugin/lib/runtime/components/react/dist/context'
-import { PortalHost, useSafeAreaInsets, GestureHandlerRootView, useHeaderHeight } from '../env/navigationHelper'
+import { PortalHost, useSafeAreaInsets, GestureHandlerRootView } from '../env/navigationHelper'
+import { innerNav, useInnerHeaderHeight } from '../env/nav'
const ProviderContext = createContext(null)
function getSystemInfo () {
@@ -445,9 +446,28 @@ const checkRelation = (options) => {
hasAncestorRelation
}
}
+function getLayoutData (headerHeight) {
+ const screenDimensions = ReactNative.Dimensions.get('screen')
+ const windowDimensions = ReactNative.Dimensions.get('window')
+ // 在横屏状态下 screen.height = window.height + bottomVirtualHeight
+ // 在正常状态 screen.height = window.height + bottomVirtualHeight + statusBarHeight
+ const isLandscape = screenDimensions.height < screenDimensions.width
+ const bottomVirtualHeight = isLandscape ? screenDimensions.height - windowDimensions.height : ((screenDimensions.height - windowDimensions.height - ReactNative.StatusBar.currentHeight) || 0)
+ return {
+ x: 0,
+ y: headerHeight,
+ left: 0,
+ top: headerHeight,
+ // 此处必须为windowDimensions.width,在横屏状态下windowDimensions.width才符合预期
+ width: windowDimensions.width,
+ height: screenDimensions.height - headerHeight - bottomVirtualHeight,
+ // ios为0 android为实际statusbar高度
+ statusBarHeight: ReactNative.StatusBar.currentHeight || 0,
+ bottomVirtualHeight: bottomVirtualHeight,
+ isLandscape: isLandscape
+ }
+}
-// 临时用来存储安卓底部(iOS没有这个)的高度(虚拟按键等高度)根据第一次进入推算
-let bottomVirtualHeight = null
export function PageWrapperHOC (WrappedComponent) {
return function PageWrapperCom ({ navigation, route, pageConfig = {}, ...props }) {
const rootRef = useRef(null)
@@ -464,59 +484,15 @@ export function PageWrapperHOC (WrappedComponent) {
error('Using pageWrapper requires passing navigation and route')
return null
}
- usePageStatus(navigation, currentPageId)
- useLayoutEffect(() => {
- navigation.setOptions({
- title: pageConfig.navigationBarTitleText?.trim() || '',
- headerStyle: {
- backgroundColor: pageConfig.navigationBarBackgroundColor || '#000000'
- },
- headerTintColor: pageConfig.navigationBarTextStyle || 'white'
- })
-
- // TODO 此部分内容在native-stack可删除,用setOptions设置
- if (__mpx_mode__ !== 'ios') {
- ReactNative.StatusBar.setBarStyle(pageConfig.barStyle || 'dark-content')
- ReactNative.StatusBar.setTranslucent(true) // 控制statusbar是否占位
- ReactNative.StatusBar.setBackgroundColor('transparent')
- }
- }, [])
-
- const headerHeight = useHeaderHeight()
+ const headerHeight = useInnerHeaderHeight(currentPageConfig)
+ navigation.layout = getLayoutData(headerHeight)
const onLayout = () => {
- const screenDimensions = ReactNative.Dimensions.get('screen')
- if (__mpx_mode__ === 'ios') {
- navigation.layout = {
- x: 0,
- y: headerHeight,
- width: screenDimensions.width,
- height: screenDimensions.height - headerHeight
- }
- } else {
- if (bottomVirtualHeight === null) {
- rootRef.current?.measureInWindow((x, y, width, height) => {
- // 沉浸模式的计算方式
- bottomVirtualHeight = screenDimensions.height - height - headerHeight
- // 非沉浸模式(translucent=true)计算方式, 现在默认是全用沉浸模式,所以先不算这个
- // bottomVirtualHeight = windowDimensions.height - height - headerHeight
- navigation.layout = {
- x: 0,
- y: headerHeight,
- width: screenDimensions.width,
- height: height
- }
- })
- } else {
- navigation.layout = {
- x: 0,
- y: headerHeight, // 这个y值
- width: screenDimensions.width,
- // 后续页面的layout是通过第一次路由进入时候推算出来的底部区域来推算出来的
- height: screenDimensions.height - bottomVirtualHeight - headerHeight
- }
- }
- }
+ // 当用户处于横屏或者竖屏状态的时候,需要进行layout修正
+ navigation.layout = getLayoutData(headerHeight)
}
+
+ usePageStatus(navigation, currentPageId)
+
const withKeyboardAvoidingView = (element) => {
return createElement(KeyboardAvoidContext.Provider,
{
@@ -535,26 +511,26 @@ export function PageWrapperHOC (WrappedComponent) {
)
)
}
-
+ // android存在第一次打开insets都返回为0情况,后续会触发第二次渲染后正确
navigation.insets = useSafeAreaInsets()
-
return createElement(GestureHandlerRootView,
{
- // https://github.com/software-mansion/react-native-reanimated/issues/6639 因存在此问题,iOS在页面上进行定宽来暂时规避
- style: __mpx_mode__ === 'ios' && currentPageConfig?.navigationStyle !== 'custom'
- ? {
- height: ReactNative.Dimensions.get('screen').height - useHeaderHeight()
- }
- : {
- flex: 1
- }
+ style: {
+ flex: 1
+ }
},
+ createElement(innerNav, {
+ props: { pageConfig: currentPageConfig },
+ navigation
+ }),
withKeyboardAvoidingView(
createElement(ReactNative.View,
{
style: {
flex: 1,
- backgroundColor: currentPageConfig?.backgroundColor || '#fff'
+ backgroundColor: currentPageConfig?.backgroundColor || '#fff',
+ // 解决页面内有元素定位relative left为负值的时候,回退的时候还能看到对应元素问题
+ overflow: 'hidden'
},
ref: rootRef,
onLayout
@@ -582,7 +558,6 @@ export function PageWrapperHOC (WrappedComponent) {
))
}
}
-
export function getDefaultOptions ({ type, rawOptions = {}, currentInject }) {
rawOptions = mergeOptions(rawOptions, type, false)
const components = Object.assign({}, rawOptions.components, currentInject.getComponents())
diff --git a/packages/webpack-plugin/lib/react/processJSON.js b/packages/webpack-plugin/lib/react/processJSON.js
index 87777df670..4d33fb795f 100644
--- a/packages/webpack-plugin/lib/react/processJSON.js
+++ b/packages/webpack-plugin/lib/react/processJSON.js
@@ -113,13 +113,14 @@ module.exports = function (jsonContent, {
}
if (ctorType === 'page') {
- const keysToExtract = ['navigationStyle']
+ // const keysToExtract = ['navigationStyle']
const configObj = {}
- keysToExtract.forEach(key => {
- if (jsonObj[key]) {
- configObj[key] = jsonObj[key]
- }
- })
+ // 暂时先不注入数据,后续如需要使用再用
+ // keysToExtract.forEach(key => {
+ // if (jsonObj[key]) {
+ // configObj[key] = jsonObj[key]
+ // }
+ // })
loaderContext._module.addPresentationalDependency(new RecordPageConfigsMapDependency(parseRequest(loaderContext.resource).resourcePath, configObj))
}
diff --git a/packages/webpack-plugin/lib/runtime/components/react/mpx-keyboard-avoiding-view.tsx b/packages/webpack-plugin/lib/runtime/components/react/mpx-keyboard-avoiding-view.tsx
index 08d0303954..5513dc3217 100644
--- a/packages/webpack-plugin/lib/runtime/components/react/mpx-keyboard-avoiding-view.tsx
+++ b/packages/webpack-plugin/lib/runtime/components/react/mpx-keyboard-avoiding-view.tsx
@@ -102,18 +102,18 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }: Keyboa
}, [keyboardAvoid])
return (
-
-
-
- {children}
-
-
-
+ //
+
+
+ {children}
+
+
+ //
)
}
diff --git a/packages/webpack-plugin/lib/runtime/components/react/mpx-web-view.tsx b/packages/webpack-plugin/lib/runtime/components/react/mpx-web-view.tsx
index 3ab50b12e2..6f1a406c08 100644
--- a/packages/webpack-plugin/lib/runtime/components/react/mpx-web-view.tsx
+++ b/packages/webpack-plugin/lib/runtime/components/react/mpx-web-view.tsx
@@ -122,17 +122,17 @@ const _WebView = forwardRef, WebViewProps>((pr
const navigation = useNavigation()
- useEffect(() => {
- let beforeRemoveSubscription:any
- if (__mpx_mode__ !== 'ios') {
- beforeRemoveSubscription = navigation?.addListener?.('beforeRemove', beforeRemoveHandle)
- }
- return () => {
- if (isFunction(beforeRemoveSubscription)) {
- beforeRemoveSubscription()
- }
- }
- }, [])
+ // useEffect(() => {
+ // let beforeRemoveSubscription:any
+ // if (__mpx_mode__ !== 'ios') {
+ // beforeRemoveSubscription = navigation?.addListener?.('beforeRemove', beforeRemoveHandle)
+ // }
+ // return () => {
+ // if (isFunction(beforeRemoveSubscription)) {
+ // beforeRemoveSubscription()
+ // }
+ // }
+ // }, [])
useNodesRef(props, ref, webViewRef, {
style: defaultWebViewStyle
@@ -212,7 +212,7 @@ const _WebView = forwardRef, WebViewProps>((pr
{ // case下不允许直接声明,包个块解决该问题
const title = postData._documentTitle?.trim()
if (title !== undefined) {
- navigation && navigation.setOptions({ title })
+ navigation && navigation.setPageConfig({ navigationBarTitleText: title })
}
}
break