fix(*): 模型与数据同步 - 完善鉴权、供应商模型和本地持久化能力

This commit is contained in:
ddCat
2026-08-20 22:58:31 +08:00
parent 36666a53a2
commit 11ee5aafec
30 changed files with 688 additions and 203 deletions

View File

@@ -3,7 +3,9 @@ import { useEffect } from "react";
import { getWallet } from "@/services/api/wallet";
const WALLET_REFRESH_INTERVAL_MS = 30_000;
// 余额不是页面心跳数据。工作区内多个位置共享同一个 Query,只有首次进入、显式
// wallet:updated 事件或低频后台刷新才需要访问服务端,避免每个窗口 focus 都打一次列表接口。
const WALLET_REFRESH_INTERVAL_MS = 60_000;
const walletBalanceQueryKey = (userId: string) => ["wallet-balance", userId] as const;
export function useWalletBalance(userId?: string, enabled = true) {
@@ -18,9 +20,9 @@ export function useWalletBalance(userId?: string, enabled = true) {
if (wallet.account.userId !== activeUserId) throw new Error("积分账户与当前用户不一致");
return wallet.account.availableMicrocredits;
},
staleTime: 15_000,
staleTime: WALLET_REFRESH_INTERVAL_MS,
refetchInterval: WALLET_REFRESH_INTERVAL_MS,
refetchOnWindowFocus: true,
refetchOnWindowFocus: false,
});
useEffect(() => {