mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-24 12:44:18 +08:00
refactor(codex-oauth): stable async loading placeholder for account usage
The account header (login + badges + actions) already renders independently of the usage query — the quota is fetched async via Tauri invoke + React Query, so the account never waits on it. Make that visually obvious and jump-free: while the usage loads, show a spinner inside a placeholder shaped like the final quota card (same rounded-xl / border / bg-card), so the card morphs smoothly into the data instead of popping in from an empty gap.
This commit is contained in:
@@ -29,12 +29,14 @@ const CodexOauthAccountQuota: React.FC<CodexOauthAccountQuotaProps> = ({
|
||||
autoQuery: false,
|
||||
});
|
||||
|
||||
// 首次加载占位:SubscriptionQuotaView 在 quota 未就绪时返回 null,
|
||||
// 这里给一个语言无关的 spinner,避免开面板后出现空白跳变。
|
||||
// 首次加载占位:账号头部由父组件独立渲染,这里只负责用量区。
|
||||
// 用量请求是异步的(Tauri invoke + React Query),加载期间给一个
|
||||
// 与最终额度卡片同形状(rounded-xl / border / bg-card)的转圈占位,
|
||||
// 这样账号会立刻显示、用量数据到达后原地平滑替换,不产生跳版。
|
||||
if (loading && !quota) {
|
||||
return (
|
||||
<div className="mt-3 flex items-center justify-center py-2 text-muted-foreground">
|
||||
<Loader2 className="h-4 w-4 animate-spin" />
|
||||
<div className="mt-3 flex items-center justify-center rounded-xl border border-border-default bg-card py-5 shadow-sm">
|
||||
<Loader2 className="h-4 w-4 animate-spin text-muted-foreground" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user