DashboardPanel.tsx 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /**
  2. * 数据看板面板 - 业务与运营指标(订单 / 活跃 / 付费 / 留存)
  3. * 静态演示数据:核心指标卡 + 12 周 WAU 趋势 + 转化漏斗 + 指标明细表
  4. */
  5. 'use client';
  6. import { Notice, SectionTitle } from '../ui';
  7. /** 核心指标(本周值 + 环比) */
  8. const kpis = [
  9. { label: '注册用户', value: '1,284', delta: '+37', up: true },
  10. { label: '日活 DAU', value: '186', delta: '+4.2%', up: true },
  11. { label: '周活 WAU', value: '412', delta: '+6.8%', up: true },
  12. { label: '月活 MAU', value: '893', delta: '+11.3%', up: true },
  13. { label: '付费用户', value: '305', delta: '+21', up: true },
  14. { label: '付费率', value: '23.8%', delta: '+1.6pp', up: true },
  15. { label: '本周订单', value: '892', delta: '+9.4%', up: true },
  16. { label: '本周 GMV', value: '$1,290', delta: '+12.1%', up: true },
  17. ];
  18. /** 12 周 WAU 趋势(柱状图) */
  19. const wauBars = [
  20. { label: 'W1', height: 42 },
  21. { label: 'W2', height: 46 },
  22. { label: 'W3', height: 45 },
  23. { label: 'W4', height: 52 },
  24. { label: 'W5', height: 50 },
  25. { label: 'W6', height: 58 },
  26. { label: 'W7', height: 55 },
  27. { label: 'W8', height: 63 },
  28. { label: 'W9', height: 61 },
  29. { label: 'W10', height: 70 },
  30. { label: 'W11', height: 68 },
  31. { label: 'W12', height: 78 },
  32. ];
  33. /** 转化漏斗:注册 → 充值 → 首次调用 → 周活跃 */
  34. const funnel = [
  35. { label: '注册用户', value: '1,284', pct: 100, color: 'bg-brand-purple' },
  36. { label: '完成充值', value: '486', pct: 38, color: 'bg-brand-purple' },
  37. { label: '首次调用 API', value: '412', pct: 32, color: 'bg-brand-purple' },
  38. { label: '本周活跃(WAU)', value: '412', pct: 32, color: 'bg-brand-green' },
  39. { label: '复购用户(≥2 次充值)', value: '203', pct: 16, color: 'bg-brand-green' },
  40. ];
  41. /** 指标明细(本周 vs 上周 + 环比) */
  42. const metricRows = [
  43. { name: '新增注册', week: 37, last: 31, delta: '+19.4%', trend: 'up' },
  44. { name: '新增付费用户', week: 21, last: 16, delta: '+31.3%', trend: 'up' },
  45. { name: '客单价(ARPU/付费)', week: '$4.23', last: '$3.98', delta: '+6.3%', trend: 'up' },
  46. { name: '订单数(充值笔数)', week: 892, last: 815, delta: '+9.4%', trend: 'up' },
  47. { name: '退款率', week: '1.2%', last: '1.5%', delta: '-0.3pp', trend: 'down' },
  48. { name: '退订率(账号注销)', week: '0.8%', last: '0.9%', delta: '-0.1pp', trend: 'down' },
  49. { name: '30 日留存率', week: '34.2%', last: '31.8%', delta: '+2.4pp', trend: 'up' },
  50. { name: '平均每日请求/活跃用户', week: '31.2', last: '29.4', delta: '+6.1%', trend: 'up' },
  51. ];
  52. export function DashboardPanel() {
  53. return (
  54. <div>
  55. {/* 核心指标卡 */}
  56. <div className="grid gap-4 [grid-template-columns:repeat(auto-fit,minmax(190px,1fr))]">
  57. {kpis.map((k) => (
  58. <div key={k.label} className="rounded-[14px] border border-white/[0.08] bg-brand-card p-5">
  59. <div className="text-xs text-brand-muted">{k.label}</div>
  60. <div className="mt-1.5 text-[22px] font-extrabold">{k.value}</div>
  61. <div className={`mt-1 text-[11.5px] ${k.up ? 'text-brand-green-l' : 'text-[#FF6B6B]'}`}>
  62. {k.delta} 环比上周
  63. </div>
  64. </div>
  65. ))}
  66. </div>
  67. {/* 12 周 WAU 趋势 */}
  68. <SectionTitle>周活跃用户(WAU)趋势 · 近 12 周</SectionTitle>
  69. <div className="rounded-[14px] border border-white/[0.08] bg-brand-card p-5">
  70. <div className="flex h-[150px] items-end gap-2 px-2">
  71. {wauBars.map((bar) => (
  72. <div key={bar.label} className="flex flex-1 flex-col items-center gap-1.5">
  73. <div
  74. className="min-h-[6px] w-[70%] max-w-[34px] rounded-b-sm rounded-t-md bg-gradient-to-b from-brand-purple to-[rgba(124,92,255,.25)]"
  75. style={{ height: `${bar.height}%` }}
  76. />
  77. <span className="text-[10.5px] text-brand-muted">{bar.label}</span>
  78. </div>
  79. ))}
  80. </div>
  81. </div>
  82. {/* 转化漏斗 */}
  83. <SectionTitle>付费转化漏斗(本月)</SectionTitle>
  84. <div className="rounded-[14px] border border-white/[0.08] bg-brand-card p-5">
  85. <div className="flex flex-col gap-2.5">
  86. {funnel.map((f) => (
  87. <div key={f.label} className="flex items-center gap-3">
  88. <div className="w-32 shrink-0 text-[12.5px] text-brand-muted">{f.label}</div>
  89. <div className="h-7 flex-1 overflow-hidden rounded-md bg-brand-card2">
  90. <div
  91. className={`flex h-full items-center rounded-md px-2 text-[12px] font-semibold text-brand-text ${f.color}`}
  92. style={{ width: `${f.pct}%` }}
  93. >
  94. {f.value}
  95. </div>
  96. </div>
  97. <div className="w-11 shrink-0 text-right text-[11.5px] text-brand-muted">
  98. {f.pct}%
  99. </div>
  100. </div>
  101. ))}
  102. </div>
  103. </div>
  104. {/* 指标明细表 */}
  105. <SectionTitle>运营指标明细 · 本周 vs 上周</SectionTitle>
  106. <div className="overflow-x-auto rounded-[14px] border border-white/[0.08] bg-brand-card">
  107. <table className="w-full min-w-[640px] border-collapse">
  108. <thead>
  109. <tr>
  110. {['指标', '本周', '上周', '环比', '趋势'].map((h) => (
  111. <th
  112. key={h}
  113. className="whitespace-nowrap bg-[rgba(124,92,255,.12)] px-4 py-[13px] text-left text-[12.5px] tracking-[0.4px] text-brand-purple-l"
  114. >
  115. {h}
  116. </th>
  117. ))}
  118. </tr>
  119. </thead>
  120. <tbody>
  121. {metricRows.map((row) => (
  122. <tr key={row.name} className="group">
  123. <td className="border-t border-white/[0.08] px-4 py-[13px] text-sm font-semibold">
  124. {row.name}
  125. </td>
  126. <td className="border-t border-white/[0.08] px-4 py-[13px] font-mono text-[13px]">
  127. {row.week}
  128. </td>
  129. <td className="border-t border-white/[0.08] px-4 py-[13px] font-mono text-[13px] text-brand-muted">
  130. {row.last}
  131. </td>
  132. <td className="border-t border-white/[0.08] px-4 py-[13px] font-mono text-[13px]">
  133. {row.delta}
  134. </td>
  135. <td className="border-t border-white/[0.08] px-4 py-[13px] text-[13px]">
  136. {row.trend === 'up' ? (
  137. <span className="text-brand-green-l">▲ 上升</span>
  138. ) : (
  139. <span className="text-[#5FF5C3]">▼ 下降(向好)</span>
  140. )}
  141. </td>
  142. </tr>
  143. ))}
  144. </tbody>
  145. </table>
  146. </div>
  147. <Notice className="mt-4">
  148. 📌 口径说明:当前为「仅预充值」模式(无订阅),「退订率」按账号注销率计;「退款率」为充值订单退款占比。订阅模式上线后新增退订统计。
  149. </Notice>
  150. </div>
  151. );
  152. }