// QuotaMeter — visual remaining-quota indicator + "Request more" CTA. // Renders only for authenticated users; anonymous callers see no meter. const QuotaMeter = ({ user, lang, onApply }) => { if (!user) return null; const t = lang === 'zh'; const initial = user.quota_initial || 0; const remaining = user.quota_remaining || 0; const used = Math.max(0, initial - remaining); const ratio = initial > 0 ? Math.min(1, used / initial) : 0; const lowQuota = remaining <= 5; return (
🪙 {t ? 'AI 額度' : 'AI quota'}
{used} / {initial} {t ? '已用' : 'used'} {t ? '申請更多額度 →' : 'Request more →'}
); }; Object.assign(window, { QuotaMeter });