mirror of
https://github.com/zyycn/codex-proxy-rs.git
synced 2026-11-06 08:06:19 +00:00
Reuse secure UUID generation for plugin frame channels and sessions on HTTP. Consolidate utility modules and shorten the plugin views store name. Declare route roles and default entries in metadata instead of guard mappings. Keep source integration build output under node_modules/.vite. Validated frontend lint, production and source builds, browser plugin flows, and 20 route guard scenarios with simulated sessions and plugin resources. Fixes #288 Co-authored-by: Codex <noreply@openai.com>
27 lines
796 B
TypeScript
27 lines
796 B
TypeScript
import { formatDateTime } from '@/utils/format'
|
|
|
|
export const KEY_USAGE_TIME_ZONE = 'Asia/Shanghai'
|
|
|
|
export function keyUsageTime(value: string | null) {
|
|
return value ? formatDateTime(value, '—', KEY_USAGE_TIME_ZONE) : '—'
|
|
}
|
|
|
|
export function money(value: string | number | null, currency = 'USD') {
|
|
if (value === null)
|
|
return '未定价'
|
|
const amount = Number(value)
|
|
if (!Number.isFinite(amount))
|
|
return '—'
|
|
return new Intl.NumberFormat('en-US', {
|
|
style: 'currency',
|
|
currency,
|
|
minimumFractionDigits: 2,
|
|
maximumFractionDigits: 6,
|
|
}).format(amount)
|
|
}
|
|
|
|
export function freshInput(input: number, cached: number, written: number) {
|
|
// 输入总量已经包含缓存读写,不把缓存再次计入消耗。
|
|
return Math.max(0, input - cached - written)
|
|
}
|