- 高峰倍率信息透传至可用渠道、支付计划、结算信息等 API,前端 GroupBadge / GroupOptionItem / SubscriptionPlanCard / PaymentView / SubscriptionsView 统一展示高峰时段与倍率标签 - 修正计费术语:"文本倍率" → "token 倍率",明确高峰倍率同时作用于 token 计费的图片 token,图片按次计费不受高峰影响 - 允许高峰倍率 multiplier=0,支持高峰时段免费策略 - 切换分组类型为 standard 时自动清除高峰倍率配置 - 长上下文计费与标准计费路径改用内部实现,移除冗余中间调用 - 前端高峰倍率相关控件文案改为 i18n - 新增多组高峰倍率相关单元测试
81 lines
2.4 KiB
TypeScript
81 lines
2.4 KiB
TypeScript
/**
|
|
* User Channels API endpoints (non-admin)
|
|
* 用户侧「可用渠道」聚合查询:渠道 + 用户可访问的分组 + 支持模型(含定价)。
|
|
*/
|
|
|
|
import { apiClient } from './client'
|
|
import type { BillingMode } from '@/constants/channel'
|
|
|
|
export interface UserAvailableGroup {
|
|
id: number
|
|
name: string
|
|
platform: string
|
|
/** 'standard' | 'subscription' — 订阅分组视觉加深,和 API 密钥页保持一致。 */
|
|
subscription_type: string
|
|
/** 分组默认倍率。用户专属倍率(若有)通过 /groups/rates 获取后在前端 join。 */
|
|
rate_multiplier: number
|
|
peak_rate_enabled: boolean
|
|
peak_start: string
|
|
peak_end: string
|
|
peak_rate_multiplier: number
|
|
/** true = 专属分组(小范围授权);false = 公开分组。 */
|
|
is_exclusive: boolean
|
|
}
|
|
|
|
export interface UserPricingInterval {
|
|
min_tokens: number
|
|
max_tokens: number | null
|
|
tier_label?: string
|
|
input_price: number | null
|
|
output_price: number | null
|
|
cache_write_price: number | null
|
|
cache_read_price: number | null
|
|
per_request_price: number | null
|
|
}
|
|
|
|
export interface UserSupportedModelPricing {
|
|
billing_mode: BillingMode
|
|
input_price: number | null
|
|
output_price: number | null
|
|
cache_write_price: number | null
|
|
cache_read_price: number | null
|
|
image_output_price: number | null
|
|
per_request_price: number | null
|
|
intervals: UserPricingInterval[]
|
|
}
|
|
|
|
export interface UserSupportedModel {
|
|
name: string
|
|
platform: string
|
|
pricing: UserSupportedModelPricing | null
|
|
}
|
|
|
|
/**
|
|
* 渠道下单个平台的子视图:用户可访问的分组 + 该平台支持的模型。
|
|
* 后端把一个渠道按平台聚合成 sections,前端可以把渠道名作为 row-group
|
|
* 一次渲染,后面按 sections 顺序用 rowspan 铺开。
|
|
*/
|
|
export interface UserChannelPlatformSection {
|
|
platform: string
|
|
groups: UserAvailableGroup[]
|
|
supported_models: UserSupportedModel[]
|
|
}
|
|
|
|
export interface UserAvailableChannel {
|
|
name: string
|
|
description: string
|
|
platforms: UserChannelPlatformSection[]
|
|
}
|
|
|
|
/** 列出当前用户可见的「可用渠道」(与 /groups/available 保持一致,返回平数组)。 */
|
|
export async function getAvailable(options?: { signal?: AbortSignal }): Promise<UserAvailableChannel[]> {
|
|
const { data } = await apiClient.get<UserAvailableChannel[]>('/channels/available', {
|
|
signal: options?.signal
|
|
})
|
|
return data
|
|
}
|
|
|
|
export const userChannelsAPI = { getAvailable }
|
|
|
|
export default userChannelsAPI
|