UsagePanel.tsx 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /**
  2. * 用量面板 - 3 统计卡(今日/7 天/30 天)+ 分模型用量表 + 用量说明
  3. */
  4. import { useTranslations } from 'next-intl';
  5. import { modelUsage } from './data';
  6. import { cls, StatCard } from './ui';
  7. export function UsagePanel() {
  8. const t = useTranslations();
  9. return (
  10. <div>
  11. {/* 统计卡:今日 / 7 天 / 30 天请求量 */}
  12. <div className="grid gap-4 [grid-template-columns:repeat(auto-fit,minmax(210px,1fr))]">
  13. <StatCard
  14. label={t('c_today_req')}
  15. value={
  16. <>
  17. 1,284 <span className="text-[14px]">{t('c_req_unit')}</span>
  18. </>
  19. }
  20. tone="purple"
  21. sub={`${t('c_tokens')}: 4.2M`}
  22. />
  23. <StatCard
  24. label={t('c_7days')}
  25. value={
  26. <>
  27. 7,940 <span className="text-[14px]">{t('c_req_unit')}</span>
  28. </>
  29. }
  30. sub="31.5M tokens"
  31. />
  32. <StatCard
  33. label={t('c_30days')}
  34. value={
  35. <>
  36. 32,118 <span className="text-[14px]">{t('c_req_unit')}</span>
  37. </>
  38. }
  39. tone="green"
  40. sub="128M tokens"
  41. />
  42. </div>
  43. {/* 分模型用量表 */}
  44. <div className={cls.secTitle}>{t('c_by_model')}</div>
  45. <div className="overflow-x-auto rounded-[14px] border border-white/[0.08] bg-brand-card">
  46. <table className="w-full min-w-[680px] border-collapse">
  47. <thead>
  48. <tr>
  49. <th className={cls.th}>{t('pt_model')}</th>
  50. <th className={cls.th}>{t('c_requests')}</th>
  51. <th className={cls.th}>Token in</th>
  52. <th className={cls.th}>Token out</th>
  53. <th className={cls.th}>{t('c_cost')}</th>
  54. </tr>
  55. </thead>
  56. <tbody>
  57. {modelUsage.map((row) => (
  58. <tr key={row.model} className="group">
  59. <td className={cls.td}>
  60. <b>{row.model}</b>
  61. </td>
  62. <td className={cls.td}>{row.requests}</td>
  63. <td className={`${cls.td} ${cls.mono}`}>{row.tokensIn}</td>
  64. <td className={`${cls.td} ${cls.mono}`}>{row.tokensOut}</td>
  65. <td className={`${cls.td} ${cls.mono}`}>{row.cost}</td>
  66. </tr>
  67. ))}
  68. </tbody>
  69. </table>
  70. </div>
  71. {/* 用量说明 */}
  72. <div className={cls.notice}>{t('c_usage_note')}</div>
  73. </div>
  74. );
  75. }