best-unit 1.2.19 → 1.2.21
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/BEST_UNIT_USAGE.md +402 -0
- package/dist/best-unit.cjs +13 -13
- package/dist/best-unit.js +1352 -1328
- package/index.html +13 -0
- package/package.json +1 -4
- package/src/api/axiosInstance.ts +111 -0
- package/src/api/index.ts +136 -0
- package/src/api/proxy.ts +11 -0
- package/src/components/business/recharge-sdk/components/offline-transfer-form/index.tsx +158 -0
- package/src/components/business/recharge-sdk/components/offline-transfer-form/theme.tsx +238 -0
- package/src/components/business/recharge-sdk/components/online-recharge-form/index.tsx +199 -0
- package/src/components/business/recharge-sdk/components/online-recharge-form/theme.tsx +159 -0
- package/src/components/business/recharge-sdk/components/recharge/index.tsx +152 -0
- package/src/components/business/recharge-sdk/components/recharge/theme.tsx +68 -0
- package/src/components/business/recharge-sdk/index.tsx +37 -0
- package/src/components/business/refresh-button/index.tsx +99 -0
- package/src/components/business/refresh-button/theme.tsx +58 -0
- package/src/components/business/statistical-balance/index.tsx +190 -0
- package/src/components/business/statistical-balance/theme.tsx +117 -0
- package/src/components/common/button/index.tsx +17 -0
- package/src/components/common/button/theme.tsx +56 -0
- package/src/components/common/hover-popover/index.tsx +182 -0
- package/src/components/common/hover-popover/theme.tsx +39 -0
- package/src/components/common/message/index.tsx +321 -0
- package/src/components/common/message/theme.tsx +25 -0
- package/src/components/common/modal/index.tsx +99 -0
- package/src/components/common/modal/theme.tsx +99 -0
- package/src/components/common/select/index.tsx +229 -0
- package/src/components/common/select/theme.tsx +104 -0
- package/src/components/common/upload/index.tsx +140 -0
- package/src/components/common/upload/theme.tsx +95 -0
- package/src/demo/App.tsx +685 -0
- package/src/demo/index.tsx +4 -0
- package/src/demo/testBalanceData.tsx +79 -0
- package/src/demo/theme-config-example.tsx +1 -0
- package/src/local/en.ts +64 -0
- package/src/local/index.ts +36 -0
- package/src/local/zh.ts +63 -0
- package/src/main.ts +26 -0
- package/src/types/global.d.ts +146 -0
- package/src/types/index.ts +31 -0
- package/src/types/preact-custom-element.d.ts +1 -0
- package/src/utils/business/index.ts +132 -0
- package/src/utils/common/index.ts +8 -0
- package/src/vite-env.d.ts +8 -0
- package/tsconfig.app.json +33 -0
- package/tsconfig.json +15 -0
- package/tsconfig.node.json +24 -0
- package/vite.config.ts +24 -0
package/src/demo/App.tsx
ADDED
|
@@ -0,0 +1,685 @@
|
|
|
1
|
+
import { useState } from "preact/hooks";
|
|
2
|
+
import { npmTest, printCurrentTime } from "@/main";
|
|
3
|
+
import { BestUnit } from "@/components/business/recharge-sdk";
|
|
4
|
+
import { initFundUnit, refreshBalance } from "@/main";
|
|
5
|
+
import StatisticalBalance from "@/components/business/statistical-balance";
|
|
6
|
+
import RefreshButton from "@/components/business/refresh-button";
|
|
7
|
+
import { t } from "@/local";
|
|
8
|
+
import { Env, Locale, Size, Theme } from "@/types";
|
|
9
|
+
import TestBalanceData from "./testBalanceData";
|
|
10
|
+
|
|
11
|
+
export default function DemoApp() {
|
|
12
|
+
const [currentLocale, setCurrentLocale] = useState<Locale>(Locale.ZH);
|
|
13
|
+
const [currentTheme, setCurrentTheme] = useState<Theme>(Theme.WHITE);
|
|
14
|
+
const [currentEnv, setCurrentEnv] = useState<Env>(Env.DEV);
|
|
15
|
+
|
|
16
|
+
const initApp = ({
|
|
17
|
+
locale,
|
|
18
|
+
theme,
|
|
19
|
+
env,
|
|
20
|
+
}: {
|
|
21
|
+
locale?: Locale;
|
|
22
|
+
theme?: Theme;
|
|
23
|
+
env?: Env;
|
|
24
|
+
}) => {
|
|
25
|
+
// 测试代码:每次刷新页面时生成不同的 token
|
|
26
|
+
const generateTestToken = () => {
|
|
27
|
+
const timestamp = Date.now();
|
|
28
|
+
const randomId = Math.floor(Math.random() * 1000);
|
|
29
|
+
return `eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3NTM0MTM1MjksIm1lcmNoYW50X2lkIjoxMTI4LCJ0aW1lc3RhbXAiOjE3NTMxNTQzMjl9.${timestamp}_${randomId}_TEST_TOKEN`;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const testToken = generateTestToken();
|
|
33
|
+
console.log("=== 测试 Token 生成 ===");
|
|
34
|
+
console.log("当前时间戳:", Date.now());
|
|
35
|
+
console.log("生成的测试 Token:", testToken);
|
|
36
|
+
console.log("========================");
|
|
37
|
+
|
|
38
|
+
initFundUnit({
|
|
39
|
+
token:
|
|
40
|
+
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJtZXJjaGFudF9pZCI6MTAwMiwidGltZXN0YW1wIjoxNzUzNDMwNjkyLCJleHAiOjE3NTM0MzQyOTJ9.OPYKUxLQ3C36rKiAmCnUwxTkvM9eKgtsnoxrB9Ntrag",
|
|
41
|
+
fund_balance_id: "FB1FNZ5Q55M7QP2C",
|
|
42
|
+
user_id: "19b8a77c-d3fc-45da-9520-4a07463123df",
|
|
43
|
+
locale: locale as Locale,
|
|
44
|
+
theme: theme ?? Theme.WHITE,
|
|
45
|
+
env: env ?? currentEnv,
|
|
46
|
+
size: Size.SMALL,
|
|
47
|
+
// themeConfig: {
|
|
48
|
+
// white: {
|
|
49
|
+
// color: "red",
|
|
50
|
+
// },
|
|
51
|
+
// dark: {
|
|
52
|
+
// color: "pink",
|
|
53
|
+
// },
|
|
54
|
+
// },
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
// 初始化应用
|
|
59
|
+
initApp({ locale: currentLocale, theme: currentTheme, env: currentEnv });
|
|
60
|
+
|
|
61
|
+
const handleLocaleChange = (locale: Locale) => {
|
|
62
|
+
setCurrentLocale(locale);
|
|
63
|
+
// 重新初始化以更新语言设置
|
|
64
|
+
initApp({ locale, theme: currentTheme, env: currentEnv });
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const handleThemeChange = (theme: Theme) => {
|
|
68
|
+
setCurrentTheme(theme);
|
|
69
|
+
initApp({ locale: currentLocale, theme, env: currentEnv });
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const handleEnvChange = (env: Env) => {
|
|
73
|
+
setCurrentEnv(env);
|
|
74
|
+
initApp({ locale: currentLocale, theme: currentTheme, env });
|
|
75
|
+
window.location.reload();
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const isDark = currentTheme === Theme.DARK;
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<div
|
|
82
|
+
style={{
|
|
83
|
+
background: isDark ? "#181A20" : "#fff",
|
|
84
|
+
minHeight: "100vh",
|
|
85
|
+
transition: "background 0.3s",
|
|
86
|
+
color: isDark ? "#F5F6FA" : "#111827",
|
|
87
|
+
}}
|
|
88
|
+
>
|
|
89
|
+
<h2
|
|
90
|
+
style={{
|
|
91
|
+
color: isDark ? "#F5F6FA" : undefined,
|
|
92
|
+
background: isDark ? "#23262F" : undefined,
|
|
93
|
+
padding: isDark ? 8 : undefined,
|
|
94
|
+
borderRadius: isDark ? 8 : undefined,
|
|
95
|
+
}}
|
|
96
|
+
>
|
|
97
|
+
组件库可视化测试 (Token 测试版本)
|
|
98
|
+
</h2>
|
|
99
|
+
|
|
100
|
+
{/* Token 测试信息显示 */}
|
|
101
|
+
<div
|
|
102
|
+
style={{
|
|
103
|
+
marginBottom: 20,
|
|
104
|
+
padding: 16,
|
|
105
|
+
border: "2px solid #1890ff",
|
|
106
|
+
borderRadius: 8,
|
|
107
|
+
backgroundColor: "#e6f7ff",
|
|
108
|
+
}}
|
|
109
|
+
>
|
|
110
|
+
<h3 style={{ marginTop: 0, marginBottom: 12, color: "#1890ff" }}>
|
|
111
|
+
🧪 Token 测试信息:
|
|
112
|
+
</h3>
|
|
113
|
+
<p style={{ margin: 0, color: "#1890ff" }}>
|
|
114
|
+
每次刷新页面都会生成新的测试 Token,请查看控制台输出。
|
|
115
|
+
</p>
|
|
116
|
+
<p style={{ margin: "8px 0 0 0", color: "#1890ff", fontSize: "12px" }}>
|
|
117
|
+
当前时间戳: {Date.now()}
|
|
118
|
+
</p>
|
|
119
|
+
</div>
|
|
120
|
+
|
|
121
|
+
{/* getBalanceData 测试区域 */}
|
|
122
|
+
<TestBalanceData isDark={isDark} />
|
|
123
|
+
|
|
124
|
+
{/* 国际化切换区域 */}
|
|
125
|
+
<div
|
|
126
|
+
style={{
|
|
127
|
+
marginBottom: 20,
|
|
128
|
+
padding: 16,
|
|
129
|
+
border: isDark ? "1px solid #23262F" : "1px solid #e5e7eb",
|
|
130
|
+
borderRadius: 8,
|
|
131
|
+
backgroundColor: isDark ? "#23262F" : "#f9fafb",
|
|
132
|
+
}}
|
|
133
|
+
>
|
|
134
|
+
<h3
|
|
135
|
+
style={{
|
|
136
|
+
marginTop: 0,
|
|
137
|
+
marginBottom: 12,
|
|
138
|
+
color: isDark ? "#F5F6FA" : undefined,
|
|
139
|
+
}}
|
|
140
|
+
>
|
|
141
|
+
国际化测试:
|
|
142
|
+
</h3>
|
|
143
|
+
<div style={{ display: "flex", gap: 12, alignItems: "center" }}>
|
|
144
|
+
<span>当前语言:</span>
|
|
145
|
+
<button
|
|
146
|
+
onClick={() => handleLocaleChange("zh" as Locale)}
|
|
147
|
+
style={{
|
|
148
|
+
padding: "8px 16px",
|
|
149
|
+
backgroundColor:
|
|
150
|
+
currentLocale === "zh"
|
|
151
|
+
? "#1890ff"
|
|
152
|
+
: isDark
|
|
153
|
+
? "#23262F"
|
|
154
|
+
: "#fff",
|
|
155
|
+
color:
|
|
156
|
+
currentLocale === "zh" ? "#fff" : isDark ? "#F5F6FA" : "#333",
|
|
157
|
+
border: "1px solid #1890ff",
|
|
158
|
+
borderRadius: 6,
|
|
159
|
+
cursor: "pointer",
|
|
160
|
+
fontWeight: currentLocale === "zh" ? "bold" : "normal",
|
|
161
|
+
}}
|
|
162
|
+
>
|
|
163
|
+
中文
|
|
164
|
+
</button>
|
|
165
|
+
<button
|
|
166
|
+
onClick={() => handleLocaleChange("en" as Locale)}
|
|
167
|
+
style={{
|
|
168
|
+
padding: "8px 16px",
|
|
169
|
+
backgroundColor:
|
|
170
|
+
currentLocale === "en"
|
|
171
|
+
? "#1890ff"
|
|
172
|
+
: isDark
|
|
173
|
+
? "#23262F"
|
|
174
|
+
: "#fff",
|
|
175
|
+
color:
|
|
176
|
+
currentLocale === "en" ? "#fff" : isDark ? "#F5F6FA" : "#333",
|
|
177
|
+
border: "1px solid #1890ff",
|
|
178
|
+
borderRadius: 6,
|
|
179
|
+
cursor: "pointer",
|
|
180
|
+
fontWeight: currentLocale === "en" ? "bold" : "normal",
|
|
181
|
+
}}
|
|
182
|
+
>
|
|
183
|
+
English
|
|
184
|
+
</button>
|
|
185
|
+
<span
|
|
186
|
+
style={{
|
|
187
|
+
marginLeft: 12,
|
|
188
|
+
fontSize: 14,
|
|
189
|
+
color: isDark ? "#B5B8BE" : "#666",
|
|
190
|
+
}}
|
|
191
|
+
>
|
|
192
|
+
{currentLocale === "zh"
|
|
193
|
+
? "当前显示中文"
|
|
194
|
+
: "Currently showing English"}
|
|
195
|
+
</span>
|
|
196
|
+
</div>
|
|
197
|
+
</div>
|
|
198
|
+
|
|
199
|
+
<div>
|
|
200
|
+
<h3 style={{ color: isDark ? "#F5F6FA" : undefined }}>
|
|
201
|
+
BestUnit 主题切换:
|
|
202
|
+
</h3>
|
|
203
|
+
<button
|
|
204
|
+
onClick={() => handleThemeChange(Theme.WHITE)}
|
|
205
|
+
style={{
|
|
206
|
+
padding: "8px 16px",
|
|
207
|
+
backgroundColor:
|
|
208
|
+
currentTheme === Theme.WHITE
|
|
209
|
+
? "#1890ff"
|
|
210
|
+
: isDark
|
|
211
|
+
? "#23262F"
|
|
212
|
+
: "#fff",
|
|
213
|
+
color:
|
|
214
|
+
currentTheme === Theme.WHITE
|
|
215
|
+
? "#fff"
|
|
216
|
+
: isDark
|
|
217
|
+
? "#F5F6FA"
|
|
218
|
+
: "#333",
|
|
219
|
+
border: "1px solid #1890ff",
|
|
220
|
+
borderRadius: 6,
|
|
221
|
+
cursor: "pointer",
|
|
222
|
+
fontWeight: currentTheme === Theme.WHITE ? "bold" : "normal",
|
|
223
|
+
marginRight: 8,
|
|
224
|
+
}}
|
|
225
|
+
>
|
|
226
|
+
白色主题
|
|
227
|
+
</button>
|
|
228
|
+
<button
|
|
229
|
+
onClick={() => handleThemeChange(Theme.DARK)}
|
|
230
|
+
style={{
|
|
231
|
+
padding: "8px 16px",
|
|
232
|
+
backgroundColor:
|
|
233
|
+
currentTheme === Theme.DARK
|
|
234
|
+
? "#1890ff"
|
|
235
|
+
: isDark
|
|
236
|
+
? "#23262F"
|
|
237
|
+
: "#fff",
|
|
238
|
+
color:
|
|
239
|
+
currentTheme === Theme.DARK
|
|
240
|
+
? "#fff"
|
|
241
|
+
: isDark
|
|
242
|
+
? "#F5F6FA"
|
|
243
|
+
: "#333",
|
|
244
|
+
border: "1px solid #1890ff",
|
|
245
|
+
borderRadius: 6,
|
|
246
|
+
cursor: "pointer",
|
|
247
|
+
fontWeight: currentTheme === Theme.DARK ? "bold" : "normal",
|
|
248
|
+
}}
|
|
249
|
+
>
|
|
250
|
+
暗黑主题
|
|
251
|
+
</button>
|
|
252
|
+
</div>
|
|
253
|
+
|
|
254
|
+
<div>
|
|
255
|
+
<h3 style={{ color: isDark ? "#F5F6FA" : undefined }}>
|
|
256
|
+
BestUnit 环境切换:
|
|
257
|
+
</h3>
|
|
258
|
+
<button
|
|
259
|
+
onClick={() => handleEnvChange(Env.DEV)}
|
|
260
|
+
style={{
|
|
261
|
+
padding: "8px 16px",
|
|
262
|
+
backgroundColor:
|
|
263
|
+
currentEnv === "dev" ? "#52c41a" : isDark ? "#23262F" : "#fff",
|
|
264
|
+
color: currentEnv === "dev" ? "#fff" : isDark ? "#F5F6FA" : "#333",
|
|
265
|
+
border: "1px solid #52c41a",
|
|
266
|
+
borderRadius: 6,
|
|
267
|
+
cursor: "pointer",
|
|
268
|
+
fontWeight: currentEnv === "dev" ? "bold" : "normal",
|
|
269
|
+
marginRight: 8,
|
|
270
|
+
}}
|
|
271
|
+
>
|
|
272
|
+
开发环境 (dev)
|
|
273
|
+
</button>
|
|
274
|
+
<button
|
|
275
|
+
onClick={() => handleEnvChange(Env.TEST)}
|
|
276
|
+
style={{
|
|
277
|
+
padding: "8px 16px",
|
|
278
|
+
backgroundColor:
|
|
279
|
+
currentEnv === "test" ? "#faad14" : isDark ? "#23262F" : "#fff",
|
|
280
|
+
color: currentEnv === "test" ? "#fff" : isDark ? "#F5F6FA" : "#333",
|
|
281
|
+
border: "1px solid #faad14",
|
|
282
|
+
borderRadius: 6,
|
|
283
|
+
cursor: "pointer",
|
|
284
|
+
fontWeight: currentEnv === "test" ? "bold" : "normal",
|
|
285
|
+
marginRight: 8,
|
|
286
|
+
}}
|
|
287
|
+
>
|
|
288
|
+
测试环境 (test)
|
|
289
|
+
</button>
|
|
290
|
+
<button
|
|
291
|
+
onClick={() => handleEnvChange(Env.PROD)}
|
|
292
|
+
style={{
|
|
293
|
+
padding: "8px 16px",
|
|
294
|
+
backgroundColor:
|
|
295
|
+
currentEnv === "prod" ? "#ff4d4f" : isDark ? "#23262F" : "#fff",
|
|
296
|
+
color: currentEnv === "prod" ? "#fff" : isDark ? "#F5F6FA" : "#333",
|
|
297
|
+
border: "1px solid #ff4d4f",
|
|
298
|
+
borderRadius: 6,
|
|
299
|
+
cursor: "pointer",
|
|
300
|
+
fontWeight: currentEnv === "prod" ? "bold" : "normal",
|
|
301
|
+
}}
|
|
302
|
+
>
|
|
303
|
+
生产环境 (prod)
|
|
304
|
+
</button>
|
|
305
|
+
<div
|
|
306
|
+
style={{
|
|
307
|
+
marginTop: 8,
|
|
308
|
+
fontSize: 14,
|
|
309
|
+
color: isDark ? "#B5B8BE" : "#666",
|
|
310
|
+
}}
|
|
311
|
+
>
|
|
312
|
+
当前环境:{" "}
|
|
313
|
+
{currentEnv === "dev"
|
|
314
|
+
? "开发环境"
|
|
315
|
+
: currentEnv === "test"
|
|
316
|
+
? "测试环境"
|
|
317
|
+
: "生产环境"}
|
|
318
|
+
</div>
|
|
319
|
+
</div>
|
|
320
|
+
|
|
321
|
+
<div>
|
|
322
|
+
<h3 style={{ color: isDark ? "#F5F6FA" : undefined }}>
|
|
323
|
+
BestUnit 组件演示:
|
|
324
|
+
</h3>
|
|
325
|
+
<BestUnit />
|
|
326
|
+
</div>
|
|
327
|
+
|
|
328
|
+
<div>
|
|
329
|
+
<h3 style={{ color: isDark ? "#F5F6FA" : undefined }}>方法演示:</h3>
|
|
330
|
+
<button
|
|
331
|
+
onClick={npmTest}
|
|
332
|
+
style={{
|
|
333
|
+
marginRight: 10,
|
|
334
|
+
background: isDark ? "#23262F" : undefined,
|
|
335
|
+
color: isDark ? "#F5F6FA" : undefined,
|
|
336
|
+
border: isDark ? "1px solid #444C5C" : undefined,
|
|
337
|
+
}}
|
|
338
|
+
>
|
|
339
|
+
调用 npmTest()
|
|
340
|
+
</button>
|
|
341
|
+
<button
|
|
342
|
+
onClick={printCurrentTime}
|
|
343
|
+
style={{
|
|
344
|
+
background: isDark ? "#23262F" : undefined,
|
|
345
|
+
color: isDark ? "#F5F6FA" : undefined,
|
|
346
|
+
border: isDark ? "1px solid #444C5C" : undefined,
|
|
347
|
+
}}
|
|
348
|
+
>
|
|
349
|
+
调用 printCurrentTime()
|
|
350
|
+
</button>
|
|
351
|
+
</div>
|
|
352
|
+
<div style={{ textAlign: "center" }}>
|
|
353
|
+
<h3 style={{ color: isDark ? "#F5F6FA" : undefined }}>
|
|
354
|
+
余额卡片组件演示:
|
|
355
|
+
</h3>
|
|
356
|
+
<StatisticalBalance />
|
|
357
|
+
</div>
|
|
358
|
+
|
|
359
|
+
{/* Refresh Button 测试区域 */}
|
|
360
|
+
<div
|
|
361
|
+
style={{
|
|
362
|
+
marginTop: 20,
|
|
363
|
+
padding: 16,
|
|
364
|
+
border: "2px solid #722ed1",
|
|
365
|
+
borderRadius: 8,
|
|
366
|
+
backgroundColor: "#f9f0ff",
|
|
367
|
+
}}
|
|
368
|
+
>
|
|
369
|
+
<h3 style={{ marginTop: 0, marginBottom: 12, color: "#722ed1" }}>
|
|
370
|
+
🧪 Refresh Button 组件测试:
|
|
371
|
+
</h3>
|
|
372
|
+
|
|
373
|
+
<div style={{ marginBottom: 16 }}>
|
|
374
|
+
<h4 style={{ color: isDark ? "#F5F6FA" : "#333", marginBottom: 8 }}>
|
|
375
|
+
基本用法:
|
|
376
|
+
</h4>
|
|
377
|
+
<div
|
|
378
|
+
style={{
|
|
379
|
+
display: "flex",
|
|
380
|
+
gap: 8,
|
|
381
|
+
alignItems: "center",
|
|
382
|
+
flexWrap: "wrap",
|
|
383
|
+
}}
|
|
384
|
+
>
|
|
385
|
+
<RefreshButton>{t("刷新")}</RefreshButton>
|
|
386
|
+
<RefreshButton></RefreshButton>
|
|
387
|
+
<RefreshButton color="#ff6b6b"></RefreshButton>
|
|
388
|
+
<RefreshButton color="#52c41a"></RefreshButton>
|
|
389
|
+
</div>
|
|
390
|
+
</div>
|
|
391
|
+
|
|
392
|
+
<div style={{ marginBottom: 16 }}>
|
|
393
|
+
<h4 style={{ color: isDark ? "#F5F6FA" : "#333", marginBottom: 8 }}>
|
|
394
|
+
不同尺寸:
|
|
395
|
+
</h4>
|
|
396
|
+
<div
|
|
397
|
+
style={{
|
|
398
|
+
display: "flex",
|
|
399
|
+
gap: 8,
|
|
400
|
+
alignItems: "center",
|
|
401
|
+
flexWrap: "wrap",
|
|
402
|
+
}}
|
|
403
|
+
>
|
|
404
|
+
<RefreshButton size="small"></RefreshButton>
|
|
405
|
+
<RefreshButton size="medium"></RefreshButton>
|
|
406
|
+
<RefreshButton size="large"></RefreshButton>
|
|
407
|
+
</div>
|
|
408
|
+
</div>
|
|
409
|
+
|
|
410
|
+
<div style={{ marginBottom: 16 }}>
|
|
411
|
+
<h4 style={{ color: isDark ? "#F5F6FA" : "#333", marginBottom: 8 }}>
|
|
412
|
+
与余额组件配合使用:
|
|
413
|
+
</h4>
|
|
414
|
+
<div
|
|
415
|
+
style={{
|
|
416
|
+
display: "flex",
|
|
417
|
+
gap: 16,
|
|
418
|
+
alignItems: "center",
|
|
419
|
+
justifyContent: "center",
|
|
420
|
+
flexWrap: "wrap",
|
|
421
|
+
}}
|
|
422
|
+
>
|
|
423
|
+
<RefreshButton>{t("刷新")}</RefreshButton>
|
|
424
|
+
</div>
|
|
425
|
+
<p
|
|
426
|
+
style={{
|
|
427
|
+
marginTop: 8,
|
|
428
|
+
fontSize: "12px",
|
|
429
|
+
color: "#666",
|
|
430
|
+
textAlign: "center",
|
|
431
|
+
}}
|
|
432
|
+
>
|
|
433
|
+
点击刷新按钮可以重新获取余额数据
|
|
434
|
+
</p>
|
|
435
|
+
</div>
|
|
436
|
+
|
|
437
|
+
<div style={{ marginBottom: 16 }}>
|
|
438
|
+
<h4 style={{ color: isDark ? "#F5F6FA" : "#333", marginBottom: 8 }}>
|
|
439
|
+
自定义样式:
|
|
440
|
+
</h4>
|
|
441
|
+
<div
|
|
442
|
+
style={{
|
|
443
|
+
display: "flex",
|
|
444
|
+
gap: 8,
|
|
445
|
+
alignItems: "center",
|
|
446
|
+
flexWrap: "wrap",
|
|
447
|
+
}}
|
|
448
|
+
>
|
|
449
|
+
<RefreshButton color="#1890ff" size="medium">
|
|
450
|
+
{t("刷新")}
|
|
451
|
+
</RefreshButton>
|
|
452
|
+
<RefreshButton color="#52c41a" size="small"></RefreshButton>
|
|
453
|
+
<RefreshButton color="#faad14" size="large">
|
|
454
|
+
{t("刷新")}
|
|
455
|
+
</RefreshButton>
|
|
456
|
+
<RefreshButton color="#ff4d4f" size="medium"></RefreshButton>
|
|
457
|
+
</div>
|
|
458
|
+
</div>
|
|
459
|
+
|
|
460
|
+
<div style={{ marginBottom: 16 }}>
|
|
461
|
+
<h4 style={{ color: isDark ? "#F5F6FA" : "#333", marginBottom: 8 }}>
|
|
462
|
+
自定义文案:
|
|
463
|
+
</h4>
|
|
464
|
+
<div
|
|
465
|
+
style={{
|
|
466
|
+
display: "flex",
|
|
467
|
+
gap: 8,
|
|
468
|
+
alignItems: "center",
|
|
469
|
+
flexWrap: "wrap",
|
|
470
|
+
}}
|
|
471
|
+
>
|
|
472
|
+
<RefreshButton>重新加载</RefreshButton>
|
|
473
|
+
<RefreshButton>更新</RefreshButton>
|
|
474
|
+
<RefreshButton>同步</RefreshButton>
|
|
475
|
+
<RefreshButton>刷新余额</RefreshButton>
|
|
476
|
+
</div>
|
|
477
|
+
</div>
|
|
478
|
+
|
|
479
|
+
<div
|
|
480
|
+
style={{
|
|
481
|
+
marginTop: 16,
|
|
482
|
+
padding: 12,
|
|
483
|
+
backgroundColor: isDark ? "#23262F" : "#fff",
|
|
484
|
+
border: "1px solid #d9d9d9",
|
|
485
|
+
borderRadius: 6,
|
|
486
|
+
fontSize: "12px",
|
|
487
|
+
}}
|
|
488
|
+
>
|
|
489
|
+
<strong>测试说明:</strong>
|
|
490
|
+
<ul style={{ margin: "8px 0", paddingLeft: "20px" }}>
|
|
491
|
+
<li>点击任意刷新按钮都会触发余额组件重新获取数据</li>
|
|
492
|
+
<li>鼠标悬停在按钮上会有缩放和透明度变化效果</li>
|
|
493
|
+
<li>鼠标悬停在刷新图标上会有旋转动画</li>
|
|
494
|
+
<li>支持不同尺寸和颜色自定义</li>
|
|
495
|
+
<li>可以通过 slot 传入自定义文案,不传则只显示图标</li>
|
|
496
|
+
<li>支持任意内容作为 slot,包括文本、图标等</li>
|
|
497
|
+
</ul>
|
|
498
|
+
</div>
|
|
499
|
+
</div>
|
|
500
|
+
|
|
501
|
+
{/* 国际化文本测试区域 */}
|
|
502
|
+
<div
|
|
503
|
+
style={{
|
|
504
|
+
marginTop: 20,
|
|
505
|
+
padding: 16,
|
|
506
|
+
border: isDark ? "1px solid #23262F" : "1px solid #e5e7eb",
|
|
507
|
+
borderRadius: 8,
|
|
508
|
+
backgroundColor: isDark ? "#23262F" : "#f9fafb",
|
|
509
|
+
}}
|
|
510
|
+
>
|
|
511
|
+
<h3
|
|
512
|
+
style={{
|
|
513
|
+
marginTop: 0,
|
|
514
|
+
marginBottom: 12,
|
|
515
|
+
color: isDark ? "#F5F6FA" : undefined,
|
|
516
|
+
}}
|
|
517
|
+
>
|
|
518
|
+
国际化文本测试:
|
|
519
|
+
</h3>
|
|
520
|
+
<div
|
|
521
|
+
style={{
|
|
522
|
+
display: "grid",
|
|
523
|
+
gridTemplateColumns: "repeat(auto-fit, minmax(200px, 1fr))",
|
|
524
|
+
gap: 12,
|
|
525
|
+
}}
|
|
526
|
+
>
|
|
527
|
+
<div
|
|
528
|
+
style={{
|
|
529
|
+
padding: 8,
|
|
530
|
+
backgroundColor: isDark ? "#181A20" : "#fff",
|
|
531
|
+
borderRadius: 4,
|
|
532
|
+
color: isDark ? "#F5F6FA" : undefined,
|
|
533
|
+
}}
|
|
534
|
+
>
|
|
535
|
+
<strong>余额相关:</strong>
|
|
536
|
+
<br />
|
|
537
|
+
{t("余额详情")}
|
|
538
|
+
<br />
|
|
539
|
+
{t("真实金额")}
|
|
540
|
+
<br />
|
|
541
|
+
{t("冻结金额")}
|
|
542
|
+
<br />
|
|
543
|
+
{t("总可用")}
|
|
544
|
+
</div>
|
|
545
|
+
<div
|
|
546
|
+
style={{
|
|
547
|
+
padding: 8,
|
|
548
|
+
backgroundColor: isDark ? "#181A20" : "#fff",
|
|
549
|
+
borderRadius: 4,
|
|
550
|
+
color: isDark ? "#F5F6FA" : undefined,
|
|
551
|
+
}}
|
|
552
|
+
>
|
|
553
|
+
<strong>充值相关:</strong>
|
|
554
|
+
<br />
|
|
555
|
+
{t("充值 / 转账")}
|
|
556
|
+
<br />
|
|
557
|
+
{t("在线充值")}
|
|
558
|
+
<br />
|
|
559
|
+
{t("线下转账")}
|
|
560
|
+
<br />
|
|
561
|
+
{t("去支付")}
|
|
562
|
+
</div>
|
|
563
|
+
<div
|
|
564
|
+
style={{
|
|
565
|
+
padding: 8,
|
|
566
|
+
backgroundColor: isDark ? "#181A20" : "#fff",
|
|
567
|
+
borderRadius: 4,
|
|
568
|
+
color: isDark ? "#F5F6FA" : undefined,
|
|
569
|
+
}}
|
|
570
|
+
>
|
|
571
|
+
<strong>按钮文本:</strong>
|
|
572
|
+
<br />
|
|
573
|
+
{t("充值/转账")}
|
|
574
|
+
<br />
|
|
575
|
+
{t("取消")}
|
|
576
|
+
<br />
|
|
577
|
+
{t("提交中...")}
|
|
578
|
+
<br />
|
|
579
|
+
{t("关闭")}
|
|
580
|
+
</div>
|
|
581
|
+
</div>
|
|
582
|
+
</div>
|
|
583
|
+
|
|
584
|
+
{/* Business Utils 测试区域 */}
|
|
585
|
+
<div
|
|
586
|
+
style={{
|
|
587
|
+
marginTop: 20,
|
|
588
|
+
padding: 16,
|
|
589
|
+
border: "2px solid #13c2c2",
|
|
590
|
+
borderRadius: 8,
|
|
591
|
+
backgroundColor: "#e6fffb",
|
|
592
|
+
}}
|
|
593
|
+
>
|
|
594
|
+
<h3 style={{ marginTop: 0, marginBottom: 12, color: "#13c2c2" }}>
|
|
595
|
+
🧪 Business Utils 方法测试:
|
|
596
|
+
</h3>
|
|
597
|
+
|
|
598
|
+
<div style={{ marginBottom: 16 }}>
|
|
599
|
+
<h4 style={{ color: isDark ? "#F5F6FA" : "#333", marginBottom: 8 }}>
|
|
600
|
+
refreshBalanceEvent 方法测试:
|
|
601
|
+
</h4>
|
|
602
|
+
<div
|
|
603
|
+
style={{
|
|
604
|
+
display: "flex",
|
|
605
|
+
gap: 8,
|
|
606
|
+
alignItems: "center",
|
|
607
|
+
flexWrap: "wrap",
|
|
608
|
+
}}
|
|
609
|
+
>
|
|
610
|
+
<button
|
|
611
|
+
onClick={() => refreshBalance()}
|
|
612
|
+
style={{
|
|
613
|
+
padding: "8px 16px",
|
|
614
|
+
backgroundColor: "#13c2c2",
|
|
615
|
+
color: "#fff",
|
|
616
|
+
border: "none",
|
|
617
|
+
borderRadius: 6,
|
|
618
|
+
cursor: "pointer",
|
|
619
|
+
fontSize: "14px",
|
|
620
|
+
}}
|
|
621
|
+
>
|
|
622
|
+
调用 refreshBalanceEvent()
|
|
623
|
+
</button>
|
|
624
|
+
<button
|
|
625
|
+
onClick={() => refreshBalance()}
|
|
626
|
+
style={{
|
|
627
|
+
padding: "8px 16px",
|
|
628
|
+
backgroundColor: "#722ed1",
|
|
629
|
+
color: "#fff",
|
|
630
|
+
border: "none",
|
|
631
|
+
borderRadius: 6,
|
|
632
|
+
cursor: "pointer",
|
|
633
|
+
fontSize: "14px",
|
|
634
|
+
}}
|
|
635
|
+
>
|
|
636
|
+
静默刷新余额
|
|
637
|
+
</button>
|
|
638
|
+
<button
|
|
639
|
+
onClick={() => refreshBalance()}
|
|
640
|
+
style={{
|
|
641
|
+
padding: "8px 16px",
|
|
642
|
+
backgroundColor: "#52c41a",
|
|
643
|
+
color: "#fff",
|
|
644
|
+
border: "none",
|
|
645
|
+
borderRadius: 6,
|
|
646
|
+
cursor: "pointer",
|
|
647
|
+
fontSize: "14px",
|
|
648
|
+
}}
|
|
649
|
+
>
|
|
650
|
+
自定义来源刷新
|
|
651
|
+
</button>
|
|
652
|
+
</div>
|
|
653
|
+
</div>
|
|
654
|
+
|
|
655
|
+
<div
|
|
656
|
+
style={{
|
|
657
|
+
marginTop: 16,
|
|
658
|
+
padding: 12,
|
|
659
|
+
backgroundColor: isDark ? "#23262F" : "#fff",
|
|
660
|
+
border: "1px solid #d9d9d9",
|
|
661
|
+
borderRadius: 6,
|
|
662
|
+
fontSize: "12px",
|
|
663
|
+
}}
|
|
664
|
+
>
|
|
665
|
+
<strong>Business Utils 方法说明:</strong>
|
|
666
|
+
<ul style={{ margin: "8px 0", paddingLeft: "20px" }}>
|
|
667
|
+
<li>
|
|
668
|
+
<code>refreshBalanceEvent()</code> -
|
|
669
|
+
基础刷新方法,触发所有余额组件刷新
|
|
670
|
+
</li>
|
|
671
|
+
<li>
|
|
672
|
+
<code>refreshBalanceEvent({ silent: true })</code> -
|
|
673
|
+
静默刷新,不显示控制台日志
|
|
674
|
+
</li>
|
|
675
|
+
<li>
|
|
676
|
+
<code>refreshBalanceEvent({ source: "custom" })</code> -
|
|
677
|
+
自定义来源标识的刷新
|
|
678
|
+
</li>
|
|
679
|
+
<li>现在refresh-button组件内部也使用这个函数,实现了代码复用</li>
|
|
680
|
+
</ul>
|
|
681
|
+
</div>
|
|
682
|
+
</div>
|
|
683
|
+
</div>
|
|
684
|
+
);
|
|
685
|
+
}
|