@arcblock/ux 2.13.43 → 2.13.44
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/lib/AnimationWaiter/dark-animation.json +1 -0
- package/lib/AnimationWaiter/index.d.ts +1 -1
- package/lib/AnimationWaiter/index.js +39 -5
- package/lib/Footer/index.js +3 -1
- package/lib/SessionUser/components/session-user-item.js +1 -0
- package/package.json +6 -6
- package/src/AnimationWaiter/dark-animation.json +1 -0
- package/src/AnimationWaiter/index.jsx +46 -13
- package/src/Footer/index.tsx +1 -1
- package/src/SessionUser/components/session-user-item.tsx +1 -0
@@ -1,10 +1,11 @@
|
|
1
1
|
import { useState, useEffect, useRef } from 'react';
|
2
|
+
import { Skeleton } from '@mui/material';
|
3
|
+
|
2
4
|
import PropTypes from 'prop-types';
|
3
5
|
import Lottie from 'react-lottie-player';
|
4
6
|
import noop from 'lodash/noop';
|
5
7
|
|
6
|
-
import
|
7
|
-
import { styled } from '../Theme';
|
8
|
+
import { styled, useTheme } from '../Theme';
|
8
9
|
|
9
10
|
/**
|
10
11
|
* 用于长时间等待的用的动画组件
|
@@ -35,9 +36,12 @@ export default function AnimationWaiter({
|
|
35
36
|
increaseSpeed,
|
36
37
|
...rest
|
37
38
|
}) {
|
39
|
+
const theme = useTheme();
|
38
40
|
const [tipsId, setTipsId] = useState(0);
|
39
41
|
const [currentSpeed, setCurrentSpeed] = useState(speed);
|
40
42
|
const [messageId, setMessageId] = useState(0);
|
43
|
+
const [defaultAnimation, setDefaultAnimation] = useState(null);
|
44
|
+
const [isLoading, setIsLoading] = useState(!animationData);
|
41
45
|
// 动画的开始时间
|
42
46
|
const startTime = useRef(new Date().getTime());
|
43
47
|
|
@@ -46,6 +50,29 @@ export default function AnimationWaiter({
|
|
46
50
|
message = [message];
|
47
51
|
}
|
48
52
|
|
53
|
+
// 懒加载默认动画
|
54
|
+
useEffect(() => {
|
55
|
+
if (!animationData) {
|
56
|
+
setIsLoading(true);
|
57
|
+
const loadAnimation = async () => {
|
58
|
+
try {
|
59
|
+
const module = await (theme.palette.mode === 'dark'
|
60
|
+
? import('./dark-animation.json')
|
61
|
+
: import('./default-animation.json'));
|
62
|
+
|
63
|
+
setDefaultAnimation(module.default || module);
|
64
|
+
|
65
|
+
setIsLoading(false);
|
66
|
+
} catch (error) {
|
67
|
+
console.error('Failed to load animation:', error);
|
68
|
+
setIsLoading(false);
|
69
|
+
}
|
70
|
+
};
|
71
|
+
|
72
|
+
loadAnimation();
|
73
|
+
}
|
74
|
+
}, [animationData, theme.palette.mode]);
|
75
|
+
|
49
76
|
useEffect(() => {
|
50
77
|
if (!message) {
|
51
78
|
return;
|
@@ -122,16 +149,22 @@ export default function AnimationWaiter({
|
|
122
149
|
|
123
150
|
return (
|
124
151
|
<Container {...rest}>
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
152
|
+
{isLoading ? (
|
153
|
+
<div style={{ width: size, height: size, display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
|
154
|
+
<Skeleton variant="rounded" width={size * 0.4} height={size * 0.4} />
|
155
|
+
</div>
|
156
|
+
) : (
|
157
|
+
<Lottie
|
158
|
+
loop
|
159
|
+
animationData={animationData || defaultAnimation}
|
160
|
+
play
|
161
|
+
speed={currentSpeed}
|
162
|
+
style={{
|
163
|
+
width: size,
|
164
|
+
height: size,
|
165
|
+
}}
|
166
|
+
/>
|
167
|
+
)}
|
135
168
|
{message && (
|
136
169
|
<div className="waiter-message">
|
137
170
|
{message.map((text, index) => {
|
@@ -183,7 +216,7 @@ AnimationWaiter.propTypes = {
|
|
183
216
|
|
184
217
|
AnimationWaiter.defaultProps = {
|
185
218
|
animationData: null,
|
186
|
-
size:
|
219
|
+
size: 256,
|
187
220
|
message: '',
|
188
221
|
messageDuration: 5000,
|
189
222
|
messageLoop: true,
|
package/src/Footer/index.tsx
CHANGED
@@ -75,7 +75,7 @@ const Container = styled('div', {
|
|
75
75
|
shouldForwardProp: (prop) => prop !== 'dark',
|
76
76
|
})<ContainerProps>`
|
77
77
|
position: relative;
|
78
|
-
margin-top:
|
78
|
+
margin-top: ${({ theme }) => theme.spacing(2)};
|
79
79
|
padding: 24px 0 32px;
|
80
80
|
border-top: 1px solid ${(props) => props.theme.palette.divider};
|
81
81
|
box-sizing: border-box;
|
@@ -47,6 +47,7 @@ const SessionUserItem = forwardRef<HTMLDivElement, SessionUserItemProps>(
|
|
47
47
|
<Avatar did={sessionItem.userDid} size={36} />
|
48
48
|
</Box>
|
49
49
|
<WalletOSIcon
|
50
|
+
color={palette.text.secondary}
|
50
51
|
loading={sessionItem.__isDefault}
|
51
52
|
provider={sessionItem?.extra?.provider}
|
52
53
|
walletOS={sessionItem?.extra?.walletOS}
|