refactor: 引入 SWR 统一钱包余额查询与轮询逻辑

This commit is contained in:
2026-06-10 13:58:26 +08:00
parent 4707101da4
commit 20d2befa55
12 changed files with 255 additions and 268 deletions

View File

@@ -66,11 +66,13 @@ export function WalletScreen() {
setLogsLoading(true);
}
try {
const b = await getWalletBalance({ currency });
// 并行请求余额和日志,避免瀑布式串行等待
const [b, nextLogs] = await Promise.all([
getWalletBalance({ currency }),
loadLogs(1, false),
]);
if (cancelled) return;
setBalance(b);
const nextLogs = await loadLogs(1, false);
if (cancelled) return;
setLogs(nextLogs);
} catch (e) {
if (!cancelled) {
@@ -93,9 +95,12 @@ export function WalletScreen() {
setError(null);
setLogsLoading(true);
try {
const b = await getWalletBalance({ currency });
// 并行请求余额和日志
const [b] = await Promise.all([
getWalletBalance({ currency }),
loadLogs(1, false),
]);
setBalance(b);
await loadLogs(1, false);
} catch (e) {
setError(formatWalletClientError(e, t));
} finally {