'use client'; // Overview.tsx — 概览(套餐横幅 + 用量指标 + 近 7 日柱状图 + 快速操作)。承袭 UCOverview。 import React from 'react'; import { Icon } from './icons'; import { card } from './shared'; import type { TFn, Lang } from '../lib/i18n'; import type { Me } from '../lib/api/types'; export default function Overview({ t, lang, me, mobile, goSub, goRedeem, }: { t: TFn; lang: Lang; me: Me; mobile: boolean; goSub: () => void; goRedeem: () => void; }) { const free = me.plan === 'free'; const vals = me.weeklyGB; const max = Math.max(...vals, 0.1); const labels = lang === 'zh' ? ['一', '二', '三', '四', '五', '六', '日'] : ['M', 'T', 'W', 'T', 'F', 'S', 'S']; const stats: [string, string, string, string][] = [ ['clock', t('quotaToday'), free ? String(me.quotaTodayMin ?? 0) : '∞', free ? 'min' : ''], ['arrow-down', t('dataToday'), me.dataTodayGB.toFixed(1), 'GB'], ['smartphone', t('devices'), `${me.devicesUsed} / ${me.devicesMax}`, ''], ]; return (
{t('greeting')}
{me.email}
{/* plan banner */}
{t('curPlan')}
{free ? t('freePlan') : t('proMember')}
{free ? t('quotaFree') : `${t('expires')} ${me.expiresAt ?? '—'}`}
{/* stats */}
{stats.map(([ic, l, v, u]) => (
{l}
{v} {u && {u}}
))}
{/* usage chart + quick actions */}
{t('usageTitle')}
{vals.map((v, i) => (
{v}
{labels[i]}
))}
{t('quickSub')}
{([['link', t('qaSub'), goSub], ['ticket', t('qaRedeem'), goRedeem], ['download', t('qaApp'), null]] as [string, string, (() => void) | null][]).map(([ic, l, fn]) => ( ))}
); }