feat: 替换 OpenBridge 组件并实现航海规范主题系统
- 使用 shadcn/ui 重新实现 TopBar、ThemeSidebar、AlertBadge 组件 - 解决 @oicl/openbridge-webcomponents ESM 模块解析问题 - 添加 OpenBridge 四种主题 CSS 变量 (day/bright/dusk/night) - Night 主题使用暗黄色文字保护夜视能力 - 更新 API 端点适配新的按模型分组数据结构
This commit is contained in:
@@ -8,17 +8,24 @@ import { env } from '@/env'
|
||||
import { dbProvider } from '@/orpc/middlewares'
|
||||
import { os } from '@/orpc/server'
|
||||
|
||||
/** 远程 API 响应中的模型数据结构 */
|
||||
interface RemoteModelData {
|
||||
model: string
|
||||
displayName?: string
|
||||
/** 远程 API 响应中的账户数据结构 */
|
||||
interface RemoteAccountData {
|
||||
accountName: string
|
||||
remainingFraction: number
|
||||
resetTime?: string
|
||||
status?: string
|
||||
}
|
||||
|
||||
/** 远程 API 响应中的模型数据结构 (按模型分组) */
|
||||
interface RemoteModelData {
|
||||
modelId: string
|
||||
displayName?: string
|
||||
accounts: RemoteAccountData[]
|
||||
}
|
||||
|
||||
/** 远程 API 响应结构 */
|
||||
interface RemoteResponse {
|
||||
result: Record<string, RemoteModelData[]>
|
||||
data: RemoteModelData[]
|
||||
}
|
||||
|
||||
export const getUsage = os.usage.getUsage
|
||||
@@ -31,7 +38,7 @@ export const getUsage = os.usage.getUsage
|
||||
}
|
||||
const data = (await response.json()) as RemoteResponse
|
||||
|
||||
// 2. 解析并筛选每个账户的 claude-opus-4-5-thinking 模型
|
||||
// 2. 找到 claude-opus-4-5-thinking 模型,然后从其 accounts 中提取数据
|
||||
const opusModels: Array<{
|
||||
account: string
|
||||
model: string
|
||||
@@ -40,21 +47,22 @@ export const getUsage = os.usage.getUsage
|
||||
resetTime?: string
|
||||
}> = []
|
||||
|
||||
for (const [accountFile, models] of Object.entries(data.result)) {
|
||||
const account = accountFile.replace('.json', '')
|
||||
// 新 API 按模型分组,找到目标模型
|
||||
const opusModelData = data.data.find(
|
||||
(m) => m.modelId === 'claude-opus-4-5-thinking',
|
||||
)
|
||||
|
||||
// 只找 claude-opus-4-5-thinking 模型
|
||||
const opusModel = models.find(
|
||||
(m) => m.model === 'claude-opus-4-5-thinking',
|
||||
)
|
||||
if (opusModelData) {
|
||||
// 遍历该模型下的所有账户
|
||||
for (const accountData of opusModelData.accounts) {
|
||||
const account = accountData.accountName.replace('.json', '')
|
||||
|
||||
if (opusModel) {
|
||||
opusModels.push({
|
||||
account,
|
||||
model: opusModel.model,
|
||||
displayName: opusModel.displayName,
|
||||
remainingFraction: opusModel.remainingFraction,
|
||||
resetTime: opusModel.resetTime,
|
||||
model: opusModelData.modelId,
|
||||
displayName: opusModelData.displayName,
|
||||
remainingFraction: accountData.remainingFraction,
|
||||
resetTime: accountData.resetTime,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user