mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-12-06 08:06:50 +00:00
管理端: - 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 文案
89 lines
2.2 KiB
TypeScript
89 lines
2.2 KiB
TypeScript
/**
|
|
* User-facing Channel Monitor API endpoints
|
|
* Read-only views for end users to inspect channel availability/status.
|
|
*/
|
|
|
|
import { apiClient } from './client'
|
|
import type { MonitorQuotaSnapshot, Provider, MonitorStatus } from './admin/channelMonitor'
|
|
|
|
export type { Provider, MonitorStatus } from './admin/channelMonitor'
|
|
|
|
export interface UserMonitorExtraModel {
|
|
model: string
|
|
status: MonitorStatus
|
|
latency_ms: number | null
|
|
}
|
|
|
|
export interface MonitorTimelinePoint {
|
|
status: MonitorStatus
|
|
latency_ms: number | null
|
|
ping_latency_ms: number | null
|
|
checked_at: string
|
|
}
|
|
|
|
export interface UserMonitorView {
|
|
id: number
|
|
name: string
|
|
provider: Provider
|
|
group_name: string
|
|
primary_model: string
|
|
primary_status: MonitorStatus
|
|
primary_latency_ms: number | null
|
|
primary_ping_latency_ms: number | null
|
|
availability_7d: number
|
|
extra_models: UserMonitorExtraModel[]
|
|
timeline: MonitorTimelinePoint[]
|
|
/**
|
|
* 主模型最近配额快照。仅当系统开启 channel_monitor_show_quota 时
|
|
* 服务端才会下发(关闭时服务端已剥离,前端 flag 仅作纵深防御)。
|
|
*/
|
|
latest_quota?: MonitorQuotaSnapshot | null
|
|
}
|
|
|
|
export interface UserMonitorListResponse {
|
|
items: UserMonitorView[]
|
|
}
|
|
|
|
export interface UserMonitorModelDetail {
|
|
model: string
|
|
latest_status: MonitorStatus
|
|
latest_latency_ms: number | null
|
|
availability_7d: number
|
|
availability_15d: number
|
|
availability_30d: number
|
|
avg_latency_7d_ms: number | null
|
|
}
|
|
|
|
export interface UserMonitorDetail {
|
|
id: number
|
|
name: string
|
|
provider: Provider
|
|
group_name: string
|
|
models: UserMonitorModelDetail[]
|
|
}
|
|
|
|
/**
|
|
* List all monitor views available to the current user.
|
|
*/
|
|
export async function list(options?: { signal?: AbortSignal }): Promise<UserMonitorListResponse> {
|
|
const { data } = await apiClient.get<UserMonitorListResponse>('/channel-monitors', {
|
|
signal: options?.signal,
|
|
})
|
|
return data
|
|
}
|
|
|
|
/**
|
|
* Get detailed status (multi-window availability + latency) for a single monitor.
|
|
*/
|
|
export async function status(id: number): Promise<UserMonitorDetail> {
|
|
const { data } = await apiClient.get<UserMonitorDetail>(`/channel-monitors/${id}/status`)
|
|
return data
|
|
}
|
|
|
|
export const channelMonitorUserAPI = {
|
|
list,
|
|
status,
|
|
}
|
|
|
|
export default channelMonitorUserAPI
|