diff --git a/src/App.tsx b/src/App.tsx index 687d6c8..47e3bfc 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -157,16 +157,18 @@ export function App() { if (mindSpacePreview) { return ( - { - window.location.href = '/'; - }} - onLogout={() => { - window.location.href = '/'; - }} - /> + + { + window.location.href = '/'; + }} + onLogout={() => { + window.location.href = '/'; + }} + /> + ); } diff --git a/src/components/BalanceRing.tsx b/src/components/BalanceRing.tsx index fb153f7..7a1d4b6 100644 --- a/src/components/BalanceRing.tsx +++ b/src/components/BalanceRing.tsx @@ -1,12 +1,11 @@ import { useEffect, useRef, useState, type CSSProperties } from 'react'; -import { getMyBillingLedger, getMyUsage } from '../api/client'; -import type { LedgerEntry, UsageRecord } from '../types'; +import { getMyUsage } from '../api/client'; +import type { UsageRecord } from '../types'; const RING_R = 16; const CIRC = 2 * Math.PI * RING_R; const POPOVER_WIDTH = 260; const RECENT_USAGE_LIMIT = 5; -const RECENT_LEDGER_LIMIT = 8; function formatYuan(cents: number) { return `¥${(cents / 100).toFixed(2)}`; @@ -49,16 +48,6 @@ function formatUsageTime(ts: number) { }); } -function formatLedgerLabel(entry: LedgerEntry) { - if (entry.note === '新用户赠送') return '新用户赠送'; - if (entry.note?.startsWith('order:')) return '微信支付充值'; - if (entry.note === '用户自助充值') return '微信支付充值'; - if (entry.note === '管理员充值') return '管理员充值'; - if (entry.type === 'refund') return '退款'; - if (entry.type === 'adjust') return entry.note?.trim() || '账户调整'; - return entry.note?.trim() || '账户充值'; -} - type BalanceRingProps = { balanceCents: number; totalCreditCents?: number; @@ -77,9 +66,6 @@ export function BalanceRing({ const [usageRecords, setUsageRecords] = useState(null); const [usageLoading, setUsageLoading] = useState(false); const [usageError, setUsageError] = useState(null); - const [ledgerEntries, setLedgerEntries] = useState(null); - const [ledgerLoading, setLedgerLoading] = useState(false); - const [ledgerError, setLedgerError] = useState(null); const wrapRef = useRef(null); const total = Math.max(totalCreditCents ?? balanceCents, balanceCents, 0); @@ -137,8 +123,6 @@ export function BalanceRing({ let cancelled = false; setUsageLoading(true); setUsageError(null); - setLedgerLoading(true); - setLedgerError(null); void getMyUsage() .then((records) => { if (!cancelled) setUsageRecords(records); @@ -151,18 +135,6 @@ export function BalanceRing({ .finally(() => { if (!cancelled) setUsageLoading(false); }); - void getMyBillingLedger(RECENT_LEDGER_LIMIT) - .then((entries) => { - if (!cancelled) setLedgerEntries(entries); - }) - .catch((err) => { - if (!cancelled) { - setLedgerError(err instanceof Error ? err.message : '加载失败'); - } - }) - .finally(() => { - if (!cancelled) setLedgerLoading(false); - }); return () => { cancelled = true; }; @@ -173,13 +145,9 @@ export function BalanceRing({ setUsageRecords(null); setUsageError(null); setUsageLoading(false); - setLedgerEntries(null); - setLedgerError(null); - setLedgerLoading(false); }, [open]); const recentUsage = (usageRecords ?? []).slice(0, RECENT_USAGE_LIMIT); - const recentLedger = (ledgerEntries ?? []).slice(0, RECENT_LEDGER_LIMIT); const centerLabel = total <= 0 ? '—' : empty ? '0%' : `${pct}%`; const ariaLabel = total > 0 ? `账户额度,剩余 ${pct}%` : '账户额度'; @@ -251,29 +219,6 @@ export function BalanceRing({

按人民币结算,每次对话按实际用量扣费

-
-
充值明细
- {ledgerLoading ? ( -

加载中…

- ) : ledgerError ? ( -

{ledgerError}

- ) : recentLedger.length === 0 ? ( -

暂无充值记录

- ) : ( -
    - {recentLedger.map((row) => ( -
  • - {formatUsageTime(row.createdAt)} - {formatLedgerLabel(row)} - - +{formatYuan(Math.abs(row.amountCents))} - -
  • - ))} -
- )} -
-