@mpxjs/core 2.10.7-beta.7 → 2.10.7-beta.8
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/@types/index.d.ts +31 -3
- package/package.json +1 -1
- package/src/index.js +6 -0
- package/src/platform/env/nav.js +8 -4
package/@types/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
/// <reference path="./global.d.ts" />
|
|
8
8
|
/// <reference path="./node.d.ts" />
|
|
9
9
|
|
|
10
|
-
import { GetComputedType } from '@mpxjs/store'
|
|
10
|
+
import type { GetComputedType } from '@mpxjs/store'
|
|
11
11
|
|
|
12
12
|
export * from '@mpxjs/store'
|
|
13
13
|
|
|
@@ -255,11 +255,27 @@ interface AnyConstructor {
|
|
|
255
255
|
prototype: any
|
|
256
256
|
}
|
|
257
257
|
|
|
258
|
-
interface WebviewConfig {
|
|
258
|
+
export interface WebviewConfig {
|
|
259
259
|
hostWhitelists?: Array<string>
|
|
260
260
|
apiImplementations?: object
|
|
261
261
|
}
|
|
262
262
|
|
|
263
|
+
export interface RnConfig {
|
|
264
|
+
onStateChange?: (state: any) => void
|
|
265
|
+
parseAppProps?: (props: any) => ({ initialRouteName?: string, initialParams?: any } | undefined | null | void)
|
|
266
|
+
/**
|
|
267
|
+
* 外层可能会异常设置此配置,因此加载监听函数内部
|
|
268
|
+
*/
|
|
269
|
+
disableAppStateListener?: boolean
|
|
270
|
+
/** 进入页面是否控制回推按钮的展示以及监听回推按钮的点击 */
|
|
271
|
+
stackTopConfig?: {
|
|
272
|
+
/** 是否展示回退按钮 */
|
|
273
|
+
show?: boolean,
|
|
274
|
+
/** 监听回退按钮点击 */
|
|
275
|
+
listener?: Function
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
263
279
|
interface MpxConfig {
|
|
264
280
|
useStrictDiff: boolean
|
|
265
281
|
ignoreWarning: boolean | string | RegExp | ((msg: string, location: string, e: Error) => boolean)
|
|
@@ -272,8 +288,14 @@ interface MpxConfig {
|
|
|
272
288
|
forceFlushSync: boolean,
|
|
273
289
|
webRouteConfig: object,
|
|
274
290
|
webConfig: object,
|
|
291
|
+
/*
|
|
292
|
+
* 支持两个属性
|
|
293
|
+
* hostWhitelists Array 类型 支持h5域名白名单安全校验
|
|
294
|
+
* apiImplementations webview JSSDK接口 例如getlocation
|
|
295
|
+
*/
|
|
275
296
|
webviewConfig: WebviewConfig,
|
|
276
|
-
|
|
297
|
+
/** react-native 相关配置,用于挂载事件等,如 onShareAppMessage */
|
|
298
|
+
rnConfig?: RnConfig,
|
|
277
299
|
}
|
|
278
300
|
|
|
279
301
|
type SupportedMode = 'wx' | 'ali' | 'qq' | 'swan' | 'tt' | 'web' | 'qa'
|
|
@@ -664,9 +686,15 @@ export const SERVERPREFETCH: string
|
|
|
664
686
|
export const REACTHOOKSEXEC: string
|
|
665
687
|
|
|
666
688
|
declare global {
|
|
689
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
690
|
+
// @ts-expect-error
|
|
667
691
|
const defineProps: (<T extends Properties = {}>(props: T) => Readonly<GetPropsType<T>>) & (<T>() => Readonly<T>)
|
|
668
692
|
const defineOptions: <D extends Data = {}, P extends Properties = {}, C = {}, M extends Methods = {}, Mi extends Array<any> = [], S extends AnyObject = {}, O extends AnyObject = {}> (opt: ThisTypedComponentOpt<D, P, C, M, Mi, S, O>) => void
|
|
693
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
694
|
+
// @ts-expect-error
|
|
669
695
|
const defineExpose: <E extends AnyObject = AnyObject>(exposed?: E) => void
|
|
670
696
|
const useContext: () => Context
|
|
697
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
698
|
+
// @ts-expect-error
|
|
671
699
|
const withDefaults: <Props, Defaults extends InferDefaults<Props>>(props: Props, defaults: Defaults) => PropsWithDefaults<Props, Defaults>
|
|
672
700
|
}
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -115,6 +115,9 @@ function use (plugin, options = {}) {
|
|
|
115
115
|
|
|
116
116
|
APIs.use = use
|
|
117
117
|
|
|
118
|
+
/**
|
|
119
|
+
* @returns {import('@mpxjs/core').Mpx}
|
|
120
|
+
*/
|
|
118
121
|
function factory () {
|
|
119
122
|
// 作为原型挂载属性的中间层
|
|
120
123
|
function Mpx () {
|
|
@@ -125,6 +128,9 @@ function factory () {
|
|
|
125
128
|
return Mpx
|
|
126
129
|
}
|
|
127
130
|
|
|
131
|
+
/**
|
|
132
|
+
* @type {import('@mpxjs/core').Mpx}
|
|
133
|
+
*/
|
|
128
134
|
const Mpx = factory()
|
|
129
135
|
|
|
130
136
|
Mpx.config = {
|
package/src/platform/env/nav.js
CHANGED
|
@@ -95,14 +95,18 @@ export function innerNav ({ pageConfig, navigation }) {
|
|
|
95
95
|
const safeAreaTop = useSafeAreaInsets()?.top || 0
|
|
96
96
|
// 假设是栈导航,获取栈的长度
|
|
97
97
|
const stackLength = navigation.getState()?.routes?.length
|
|
98
|
-
|
|
99
|
-
const beforeStackLength = Mpx.config?.rnConfig?.beforeStackLength || 0
|
|
98
|
+
const stackTopConfig = Mpx.config?.rnConfig?.stackTopConfig || {}
|
|
100
99
|
|
|
101
100
|
// 回退按钮与图标
|
|
102
|
-
const backElement = stackLength
|
|
101
|
+
const backElement = stackLength > 1 || stackTopConfig.show
|
|
103
102
|
? createElement(TouchableOpacity, {
|
|
104
103
|
style: [styles.backButton],
|
|
105
|
-
onPress: () => {
|
|
104
|
+
onPress: () => {
|
|
105
|
+
navigation.goBack()
|
|
106
|
+
if (stackLength <= 1 && stackTopConfig.show && typeof stackTopConfig.listener === 'function') {
|
|
107
|
+
stackTopConfig.listener?.()
|
|
108
|
+
}
|
|
109
|
+
}
|
|
106
110
|
}, createElement(Image, {
|
|
107
111
|
source: { uri: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAABICAYAAACqT5alAAAA2UlEQVR4nO3bMQrCUBRE0Yla6AYEN2nnBrTL+izcitW3MRDkEUWSvPzJvfCqgMwhZbAppWhNbbIHzB1g9wATERFRVyvpkj1irlpJ5X326D7WHh1hbdFD2CLpLmmftm7kfsEe09aNHFiBrT+wAlt/YAW2/sAKbP2BFdj6Ayuwy+ufz6XPL893krZ//O6iu2n4LT8kndLWTRTo4EC7BDo40C6BDg60S6CDA+0S6OBAuwQ6uNWiD2nrJmoIfU7cNWkR2hbb1UfbY7uuWhGWiIg+a/iHuHmA3QPs3gu4JW9Gan+OJAAAAABJRU5ErkJggg==' },
|
|
108
112
|
// 回退按钮的颜色与设置的title文案颜色一致
|