feat(admin): 计费 & 用量合成一页 —— 顶部配规则、下方看结果(闭环)

按"配置和观测放一个页面"收口:删掉重复的「计价 & 预算」页(其预算区块是 mock),
把真·计价配置并入「计费 & 用量」,形成 规则→扣费→观测 一页闭环。
- 新组件 BillingRules:全局 token→积分汇率 + 每模型 单价/币种/积分权重(读写
  /admin/pricing + /admin/billing-config),改完对后续任务实时生效。
- UsagePage:顶部「计费规则」(配置端) + 下方「用量观测」(按规则折算后的实际消耗)。
- 删 PricingPage + /pricing 路由;api 加 credit_weight / getBillingConfig / saveBillingConfig。

live 验证(preview):改汇率保存→持久化→新任务按新汇率扣→用量观测反映;
tsc + 41 vitest 全过;无 PricingPage 残引。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Blizzard
2026-07-07 13:26:33 +08:00
parent e2fc2d366c
commit 11d321f218
5 changed files with 228 additions and 291 deletions
+1 -9
View File
@@ -9,7 +9,6 @@ const DashboardPage = lazy(() => import("./pages/DashboardPage").then((m) => ({
const UsagePage = lazy(() => import("./pages/UsagePage").then((m) => ({ default: m.UsagePage })));
const ModelsPage = lazy(() => import("./pages/ModelsPage").then((m) => ({ default: m.ModelsPage })));
const DatasourcesPage = lazy(() => import("./pages/DatasourcesPage").then((m) => ({ default: m.DatasourcesPage })));
const PricingPage = lazy(() => import("./pages/PricingPage").then((m) => ({ default: m.PricingPage })));
const StatusPage = lazy(() => import("./pages/StatusPage").then((m) => ({ default: m.StatusPage })));
const EvalsPage = lazy(() => import("./pages/EvalsPage").then((m) => ({ default: m.EvalsPage })));
const TenantsPage = lazy(() => import("./pages/TenantsPage").then((m) => ({ default: m.TenantsPage })));
@@ -35,7 +34,7 @@ export const routes: RouteDef[] = [
},
{
path: "/usage",
label: "用量 & 计费",
label: "计费 & 用量",
group: "分析",
ready: true,
element: <UsagePage />,
@@ -54,13 +53,6 @@ export const routes: RouteDef[] = [
ready: true,
element: <DatasourcesPage />,
},
{
path: "/pricing",
label: "计价 & 预算",
group: "配置",
ready: true,
element: <PricingPage />,
},
{
path: "/prompts",
label: "提示词",