@gm-mobile/mp 3.9.3-beta.10 → 3.9.3-beta.14
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.
|
|
3
|
+
"version": "3.9.3-beta.14",
|
|
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.
|
|
25
|
-
"@gm-mobile/c-tool": "^3.9.3-beta.
|
|
26
|
-
"@gm-mobile/locales": "^3.9.3-beta.
|
|
24
|
+
"@gm-mobile/c-react": "^3.9.3-beta.14",
|
|
25
|
+
"@gm-mobile/c-tool": "^3.9.3-beta.14",
|
|
26
|
+
"@gm-mobile/locales": "^3.9.3-beta.14"
|
|
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": "
|
|
36
|
+
"gitHead": "b0fbd70d9632ca882d1954d95153705a3f7663c0"
|
|
37
37
|
}
|
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
import React, { useEffect, useRef, FC, useState, ReactNode } from 'react'
|
|
2
|
-
import { LayoutRoot, LayoutRootV1 } from '@gm-mobile/c-react'
|
|
2
|
+
import { Flex, LayoutRoot, LayoutRootV1 } from '@gm-mobile/c-react'
|
|
3
3
|
import { ScrollView } from '@tarojs/components'
|
|
4
|
-
import PageBase, { PageProps
|
|
4
|
+
import PageBase, { PageProps } from './base'
|
|
5
|
+
import { debounce } from 'lodash'
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
interface PageMPProps extends PageProps {
|
|
8
|
+
onRefresh?: () => Promise<any>
|
|
9
|
+
onLoadMore?: () => Promise<any>
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const PageMP: FC<PageMPProps> = ({
|
|
13
|
+
children,
|
|
14
|
+
onRefresh,
|
|
15
|
+
onLoadMore,
|
|
16
|
+
...props
|
|
17
|
+
}) => {
|
|
11
18
|
const [state, setState] = useState({
|
|
12
19
|
refreshing: false,
|
|
20
|
+
loadingMore: false,
|
|
13
21
|
})
|
|
14
22
|
const refLoading = useRef<boolean | undefined>(false)
|
|
15
23
|
useEffect(() => {
|
|
@@ -44,6 +52,29 @@ const PageMP: FC<
|
|
|
44
52
|
}
|
|
45
53
|
})
|
|
46
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
|
+
),
|
|
47
78
|
}
|
|
48
79
|
|
|
49
80
|
return (
|
|
@@ -53,13 +84,26 @@ const PageMP: FC<
|
|
|
53
84
|
<ScrollView
|
|
54
85
|
className='m-flex'
|
|
55
86
|
style={{ height: '100%' }}
|
|
87
|
+
enableBackToTop
|
|
56
88
|
scrollY
|
|
57
89
|
refresherEnabled
|
|
90
|
+
scrollWithAnimation
|
|
58
91
|
refresherBackground='transparent'
|
|
59
92
|
refresherTriggered={state.refreshing}
|
|
60
|
-
|
|
93
|
+
lowerThreshold={50}
|
|
94
|
+
onRefresherRefresh={() => methods.refresh()}
|
|
95
|
+
onScrollToLower={() => methods.loadMore()}
|
|
61
96
|
>
|
|
62
97
|
{children}
|
|
98
|
+
{state.loadingMore && (
|
|
99
|
+
<Flex
|
|
100
|
+
className='loading-more m-margin-tb-20 m-text-placeholder'
|
|
101
|
+
alignCenter
|
|
102
|
+
justifyCenter
|
|
103
|
+
>
|
|
104
|
+
加载中...
|
|
105
|
+
</Flex>
|
|
106
|
+
)}
|
|
63
107
|
</ScrollView>
|
|
64
108
|
)}
|
|
65
109
|
{!onRefresh && children}
|
|
@@ -12,7 +12,7 @@ const SafeBottomMP: FC<SafeBottomMPProps> = memo(
|
|
|
12
12
|
|
|
13
13
|
return (
|
|
14
14
|
<View className={classNames(className)} {...rest}>
|
|
15
|
-
{React.cloneElement(children as React.ReactElement
|
|
15
|
+
{React.cloneElement((children as React.ReactElement) || <View />, {
|
|
16
16
|
style: {
|
|
17
17
|
paddingBottom:
|
|
18
18
|
paddingBottom > 0 ? `${paddingBottom}px!important` : undefined,
|