feat(monitor-ui): 配额模式表单、用量快照视图与 8 平台支持

管理端:
- MonitorFormDialog:新增检查方式三态分段控件(探活/配额/探活+配额),
  provider 网格扩展至 8 平台(+antigravity/kimi/zhipu/deepseek),
  国产平台默认 endpoint 预填、antigravity 强制 quota-only;配额模式
  显示关联账号选择器(复用 adminAPI.accounts.list 按平台过滤),
  隐藏 endpoint/api_key/模型等探活专属字段
- 新建共用 MonitorQuotaView:用量窗口进度条(阈值/样式对齐账号页
  CNProviderQuotaCell)、多币种余额、plan_level 徽章与错误态;
  window/label 机器 token 走 i18n,未知 token 原样透出(前向兼容)
- 列表主模型单元格内联 latest_quota;运行结果弹窗逐行展示配额;
  筛选栏/模板管理/格式化 composable 同步 8 平台(配色对齐
  utils/platformColors.ts);ProviderIcon 搬运 4 家官方 SVG

用户端:
- MonitorCard 支持 latest_quota,渲染受 channel_monitor_show_quota
  系统开关(isChannelMonitorQuotaVisible)控制,服务端剥离为第一道防线

设置与 i18n:
- 管理设置页新增「向用户展示渠道用量/余额」开关(默认关闭);
  zh/en 全量补充 providers/checkMode/quota 文案
This commit is contained in:
Randark committed 2026-08-18 05:09:58 +00:00
1 parent c51fd7d0b3
commit a20e1c00cc
22 files changed
+700 -37

No files matched your search

+64 -1
View File
@@ -5,10 +5,57 @@
import { apiClient } from '../client'
export type Provider = 'openai' | 'anthropic' | 'gemini' | 'grok'
export type Provider =
| 'openai'
| 'anthropic'
| 'gemini'
| 'grok'
| 'antigravity'
| 'kimi'
| 'zhipu'
| 'deepseek'
export type MonitorStatus = 'operational' | 'degraded' | 'failed' | 'error'
export type BodyOverrideMode = 'off' | 'merge' | 'replace'
export type APIMode = 'chat_completions' | 'responses'
/**
* probe = LLM 探活(默认);quota = 仅查关联账号用量(零 LLM 成本);
* quota_probe = 探活 + 配额快照挂主模型行。
*/
export type CheckMode = 'probe' | 'quota' | 'quota_probe'
/** 配额快照中的单个用量窗口(与后端 domain.MonitorQuotaTier 一致)。 */
export interface MonitorQuotaTier {
/** 5h | 7d | 7d-sonnet | 7d-fable | 30d | daily | weekly | total */
window: string
/** 同窗口多档时的机器标识(gemini shared/pro/flash、grok requests/tokens、antigravity 模型名) */
label?: string
used_percent: number
used?: number
limit?: number
/** RFC3339;空表示无重置时间 */
reset_at?: string
}
export interface MonitorBalance {
currency: string
balance: number
}
/** 归一化配额快照(与后端 domain.MonitorQuotaSnapshot 一致)。 */
export interface MonitorQuotaSnapshot {
/** usage | cn_quota | cn_balance */
source: string
success: boolean
tiers?: MonitorQuotaTier[]
balance?: number | null
balances?: MonitorBalance[]
currency?: string
plan_level?: string
/** 401/403 鉴权失败标记(推导为 failed 状态) */
credential_invalid?: boolean
error?: string
fetched_at: string
}
export interface ChannelMonitor {
id: number
@@ -47,6 +94,12 @@ export interface ChannelMonitor {
extra_headers: Record<string, string>
body_override_mode: BodyOverrideMode
body_override: Record<string, unknown> | null
/** 检测模式:probe(默认)/ quota / quota_probe */
check_mode: CheckMode
/** 配额模式关联的账号 ID;探活模式为 null */
account_id: number | null
/** 主模型最近一次配额快照(配额模式;无历史时为 null) */
latest_quota?: MonitorQuotaSnapshot | null
}
export interface ExtraModelStatus {
@@ -75,8 +128,14 @@ export interface CreateParams {
name: string
provider: Provider
api_mode?: APIMode
/** 探活模式必填(base origin);quota 模式可留空 */
endpoint: string
/** 探活模式必填;quota 模式可留空 */
api_key: string
/** 缺省 probe;antigravity 仅支持 quota */
check_mode?: CheckMode
/** 配额模式必填:数据源账号(provider 需与账号平台一致) */
account_id?: number | null
primary_model: string
extra_models?: string[]
group_name?: string
@@ -101,6 +160,8 @@ export interface CheckResult {
ping_latency_ms: number | null
message: string
checked_at: string
/** 配额模式(quota / quota_probe 主模型行)附带的配额快照 */
quota?: MonitorQuotaSnapshot | null
}
export interface RunNowResponse {
@@ -115,6 +176,8 @@ export interface HistoryItem {
ping_latency_ms: number | null
message: string
checked_at: string
/** 配额快照(配额模式行;探活行为空) */
quota?: MonitorQuotaSnapshot | null
}
export interface HistoryParams {
+2
View File
@@ -718,6 +718,7 @@ export interface SystemSettings {
channel_monitor_mode?: 'v1' | 'v2';
channel_monitor_default_interval_seconds: number;
channel_monitor_hide_throughput?: boolean;
channel_monitor_show_quota?: boolean;
// Available Channels feature switch
available_channels_enabled: boolean;
@@ -1016,6 +1017,7 @@ export interface UpdateSettingsRequest {
channel_monitor_mode?: 'v1' | 'v2';
channel_monitor_default_interval_seconds?: number;
channel_monitor_hide_throughput?: boolean;
channel_monitor_show_quota?: boolean;
// Available Channels feature switch
available_channels_enabled?: boolean;
+6 -1
View File
@@ -4,7 +4,7 @@
*/
import { apiClient } from './client'
import type { Provider, MonitorStatus } from './admin/channelMonitor'
import type { MonitorQuotaSnapshot, Provider, MonitorStatus } from './admin/channelMonitor'
export type { Provider, MonitorStatus } from './admin/channelMonitor'
@@ -33,6 +33,11 @@ export interface UserMonitorView {
availability_7d: number
extra_models: UserMonitorExtraModel[]
timeline: MonitorTimelinePoint[]
/**
* 主模型最近配额快照。仅当系统开启 channel_monitor_show_quota 时
* 服务端才会下发(关闭时服务端已剥离,前端 flag 仅作纵深防御)。
*/
latest_quota?: MonitorQuotaSnapshot | null
}
export interface UserMonitorListResponse {