@gm-mobile/mp 3.9.3-beta.23 → 3.9.3-beta.27

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": "@gm-mobile/mp",
3
- "version": "3.9.3-beta.23",
3
+ "version": "3.9.3-beta.27",
4
4
  "description": "",
5
5
  "author": "liyatang <liyatang@qq.com>",
6
6
  "homepage": "https://github.com/gmfe/gm-mobile#readme",
@@ -21,9 +21,9 @@
21
21
  "url": "https://github.com/gmfe/gm-mobile/issues"
22
22
  },
23
23
  "dependencies": {
24
- "@gm-mobile/c-react": "^3.9.3-beta.23",
25
- "@gm-mobile/c-tool": "^3.9.3-beta.23",
26
- "@gm-mobile/locales": "^3.9.3-beta.23"
24
+ "@gm-mobile/c-react": "^3.9.3-beta.27",
25
+ "@gm-mobile/c-tool": "^3.9.3-beta.27",
26
+ "@gm-mobile/locales": "^3.9.3-beta.27"
27
27
  },
28
28
  "peerDependencies": {
29
29
  "@tarojs/components": "3.0.18",
@@ -33,5 +33,5 @@
33
33
  "prop-types": "^15.7.2",
34
34
  "react": "^16.13.1"
35
35
  },
36
- "gitHead": "83384e6c6a64db8d690c0c7381d68e46c20d47b8"
36
+ "gitHead": "08675f24d4de60a633bbae39ae57abdfe89e9d4e"
37
37
  }
@@ -1,12 +1,13 @@
1
1
  import React, { useEffect, useRef, FC, useState, ReactNode } from 'react'
2
- import { Flex, LayoutRoot, LayoutRootV1 } from '@gm-mobile/c-react'
2
+ import { Flex, LayoutRoot, LayoutRootV1, Loading } from '@gm-mobile/c-react'
3
3
  import { ScrollView } from '@tarojs/components'
4
4
  import PageBase, { PageProps } from './base'
5
- import { debounce } from 'lodash'
5
+ import { pxTransform } from '@tarojs/taro'
6
6
 
7
7
  interface PageMPProps extends PageProps {
8
8
  onRefresh?: () => Promise<any>
9
- onLoadMore?: () => Promise<any>
9
+ /** 上滑加载更多事件。如果promise返回一个空数组,表示没有更多了 */
10
+ onLoadMore?: () => Promise<Array<any> | undefined>
10
11
  }
11
12
 
12
13
  const PageMP: FC<PageMPProps> = ({
@@ -19,9 +20,10 @@ const PageMP: FC<PageMPProps> = ({
19
20
  refreshing: false,
20
21
  loadingMore: false,
21
22
  })
23
+
24
+ // Page加载状态
22
25
  const refLoading = useRef<boolean | undefined>(false)
23
26
  useEffect(() => {
24
- // 和之前的不一样
25
27
  if (props.loading !== refLoading.current) {
26
28
  if (props.loading) {
27
29
  wx.showNavigationBarLoading()
@@ -32,49 +34,45 @@ const PageMP: FC<PageMPProps> = ({
32
34
  refLoading.current = props.loading
33
35
  }
34
36
  }, [props.loading])
35
- const methods = {
36
- async refresh() {
37
- setState((state) => {
38
- return {
39
- ...state,
40
- refreshing: true,
41
- }
42
- })
43
- try {
44
- onRefresh && (await onRefresh())
45
- } catch (err) {
46
- console.error(err)
37
+
38
+ const refresh = async () => {
39
+ setState((state) => {
40
+ return {
41
+ ...state,
42
+ refreshing: true,
43
+ }
44
+ })
45
+ try {
46
+ onRefresh && (await onRefresh())
47
+ } catch (err) {
48
+ console.error(err)
49
+ }
50
+ setState((state) => {
51
+ return {
52
+ ...state,
53
+ refreshing: false,
54
+ }
55
+ })
56
+ }
57
+
58
+ const loadMore = async () => {
59
+ setState((state) => {
60
+ return {
61
+ ...state,
62
+ loadingMore: true,
63
+ }
64
+ })
65
+ try {
66
+ onLoadMore && (await onLoadMore())
67
+ } catch (err) {
68
+ console.error(err)
69
+ }
70
+ setState((state) => {
71
+ return {
72
+ ...state,
73
+ loadingMore: false,
47
74
  }
48
- setState((state) => {
49
- return {
50
- ...state,
51
- refreshing: false,
52
- }
53
- })
54
- },
55
- loadMore: debounce(
56
- async () => {
57
- setState((state) => {
58
- return {
59
- ...state,
60
- refreshing: true,
61
- }
62
- })
63
- try {
64
- onLoadMore && (await onLoadMore())
65
- } catch (err) {
66
- console.error(err)
67
- }
68
- setState((state) => {
69
- return {
70
- ...state,
71
- refreshing: false,
72
- }
73
- })
74
- },
75
- 1000,
76
- { leading: true }
77
- ),
75
+ })
78
76
  }
79
77
 
80
78
  return (
@@ -88,20 +86,17 @@ const PageMP: FC<PageMPProps> = ({
88
86
  scrollY
89
87
  refresherEnabled
90
88
  scrollWithAnimation
89
+ scrollAnchoring
91
90
  refresherBackground='transparent'
92
91
  refresherTriggered={state.refreshing}
93
92
  lowerThreshold={50}
94
- onRefresherRefresh={() => methods.refresh()}
95
- onScrollToLower={() => methods.loadMore()}
93
+ onRefresherRefresh={() => refresh()}
94
+ onScrollToLower={() => loadMore()}
96
95
  >
97
96
  {children}
98
97
  {state.loadingMore && (
99
- <Flex
100
- className='loading-more m-margin-tb-20 m-text-placeholder'
101
- alignCenter
102
- justifyCenter
103
- >
104
- 加载中...
98
+ <Flex height={pxTransform(60)} alignCenter justifyCenter>
99
+ <Loading style={{ opacity: 0.5 }} />
105
100
  </Flex>
106
101
  )}
107
102
  </ScrollView>
@@ -5,10 +5,9 @@ import UtilMP from '../../util'
5
5
  export type StatusBarMPProps = HTMLAttributes<HTMLDivElement>
6
6
 
7
7
  const StatusBarMP: FC<StatusBarMPProps> = memo((style, ...rest) => {
8
- const [height, setHeight] = useState(20)
8
+ const [height, setHeight] = useState(wx.getSystemInfoSync().statusBarHeight)
9
9
  useEffect(() => {
10
10
  const rect = UtilMP.getMenuButtonBoundingClientRect()
11
-
12
11
  UtilMP.getSystemInfo().then((res) => {
13
12
  // 不一定能读到胶囊,或者胶囊占据整个宽, 此时不需要设置statusBar
14
13
  return setHeight(rect?.left ? res.statusBarHeight : 0)
@@ -124,6 +124,8 @@ export default class Router {
124
124
  // @ts-ignore
125
125
  data && delete parsed.data
126
126
  this._data[to] = data
127
+ } else {
128
+ this._data[to] = undefined
127
129
  }
128
130
  this._beforeChange(option, () => Taro.navigateTo(parsed))
129
131
  })