mirror of
https://github.com/zyycn/codex-proxy-rs.git
synced 2026-11-18 16:06:47 +00:00
fix: align official quota windows
Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
@@ -20,10 +20,18 @@ export interface Account {
|
||||
}
|
||||
|
||||
export interface AccountQuota {
|
||||
refreshedAtDisplay: string
|
||||
windows: AccountQuotaWindow[]
|
||||
}
|
||||
|
||||
export interface AccountQuotaWindow {
|
||||
key: string
|
||||
group: 'monthly' | 'shortTerm' | 'other'
|
||||
windowSeconds?: number | null
|
||||
labelDisplay: string
|
||||
usedPercent?: number | null
|
||||
usedPercentDisplay: string
|
||||
resetAtDisplay: string
|
||||
refreshedAtDisplay: string
|
||||
windowUsedDisplay: string
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import BaseModal from '@/components/base/BaseModal.vue'
|
||||
import BaseTable from '@/components/base/BaseTable.vue'
|
||||
import { withMinimumDuration } from '@/utils/async'
|
||||
|
||||
import type { Account } from '@/api'
|
||||
import type { Account, AccountQuotaWindow } from '@/api'
|
||||
import {
|
||||
batchDeleteAccounts,
|
||||
createAccount,
|
||||
@@ -46,7 +46,22 @@ const createForm = ref({
|
||||
})
|
||||
|
||||
const accountColumns = [
|
||||
{ key: 'selection', label: '', width: '56px', align: 'left' as const },
|
||||
{
|
||||
key: 'expander',
|
||||
label: '',
|
||||
width: '40px',
|
||||
align: 'center' as const,
|
||||
headerClass: '!px-2',
|
||||
cellClass: '!px-2',
|
||||
},
|
||||
{
|
||||
key: 'selection',
|
||||
label: '',
|
||||
width: '40px',
|
||||
align: 'center' as const,
|
||||
headerClass: '!px-2',
|
||||
cellClass: '!px-2',
|
||||
},
|
||||
{ key: 'identity', label: '邮箱', flex: 2.6, minWidth: '260px' },
|
||||
{ key: 'status', label: '状态', flex: 0.8 },
|
||||
{ key: 'planType', label: '套餐', flex: 0.8 },
|
||||
@@ -260,8 +275,16 @@ function handlePageSizeChange(nextPageSize: number) {
|
||||
void loadAccounts()
|
||||
}
|
||||
|
||||
function quotaBarWidth(account: Account) {
|
||||
return `${Math.max(0, Math.min(account.quota.usedPercent ?? 0, 100))}%`
|
||||
function quotaWindows(account: Account) {
|
||||
return account.quota.windows
|
||||
}
|
||||
|
||||
function quotaWindowsByGroup(account: Account, group: AccountQuotaWindow['group']) {
|
||||
return quotaWindows(account).filter((window) => window.group === group)
|
||||
}
|
||||
|
||||
function quotaWindowBarWidth(window: AccountQuotaWindow) {
|
||||
return `${Math.max(0, Math.min(window.usedPercent ?? 0, 100))}%`
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
@@ -355,6 +378,20 @@ onBeforeUnmount(() => {
|
||||
@page-change="handlePageChange"
|
||||
@page-size-change="handlePageSizeChange"
|
||||
>
|
||||
<template #expander="{ row }">
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex size-6 cursor-pointer items-center justify-center rounded-md border-0 bg-transparent text-(--cp-text-secondary) transition hover:bg-(--cp-default-bg-hover) hover:text-(--cp-text-primary)"
|
||||
:title="expandedAccountIds.has(row.id) ? '收起统计' : '展开统计'"
|
||||
@click.stop="toggleExpanded(row.id)"
|
||||
>
|
||||
<ChevronDown
|
||||
class="size-3.5 transition-transform"
|
||||
:class="expandedAccountIds.has(row.id) ? '' : '-rotate-90'"
|
||||
/>
|
||||
</button>
|
||||
</template>
|
||||
|
||||
<template #header-selection>
|
||||
<BaseCheckbox
|
||||
:model-value="allSelected"
|
||||
@@ -365,24 +402,11 @@ onBeforeUnmount(() => {
|
||||
</template>
|
||||
|
||||
<template #selection="{ row }">
|
||||
<div class="flex items-center gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex size-6 cursor-pointer items-center justify-center rounded-md border-0 bg-transparent text-(--cp-text-secondary) transition hover:bg-(--cp-default-bg-hover) hover:text-(--cp-text-primary)"
|
||||
:title="expandedAccountIds.has(row.id) ? '收起统计' : '展开统计'"
|
||||
@click.stop="toggleExpanded(row.id)"
|
||||
>
|
||||
<ChevronDown
|
||||
class="size-3.5 transition-transform"
|
||||
:class="expandedAccountIds.has(row.id) ? 'rotate-180' : '-rotate-90'"
|
||||
/>
|
||||
</button>
|
||||
<BaseCheckbox
|
||||
:model-value="selectedIds.has(row.id)"
|
||||
label="选择账号"
|
||||
@update:model-value="toggleSelection(row.id)"
|
||||
/>
|
||||
</div>
|
||||
<BaseCheckbox
|
||||
:model-value="selectedIds.has(row.id)"
|
||||
label="选择账号"
|
||||
@update:model-value="toggleSelection(row.id)"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<template #identity="{ row }">
|
||||
@@ -481,21 +505,80 @@ onBeforeUnmount(() => {
|
||||
</BaseIconButton>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center justify-between text-[12px] font-[720]">
|
||||
<span class="text-(--cp-text-secondary)">周限额</span>
|
||||
<span class="text-(--cp-text-primary)">{{ row.quota.usedPercentDisplay }}</span>
|
||||
</div>
|
||||
<div class="mt-2 h-2 overflow-hidden rounded-full bg-(--cp-bg-tertiary)">
|
||||
<div class="grid gap-3">
|
||||
<div
|
||||
class="h-full rounded-full bg-(--cp-info)"
|
||||
:style="{ width: quotaBarWidth(row) }"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
class="mt-3 flex justify-between text-[12px] font-[620] text-(--cp-text-secondary)"
|
||||
>
|
||||
<span>重置时间: {{ row.quota.resetAtDisplay }}</span>
|
||||
<span>窗口已用: {{ row.quota.windowUsedDisplay }}</span>
|
||||
v-for="window in quotaWindowsByGroup(row, 'monthly')"
|
||||
:key="window.key"
|
||||
class="rounded-lg bg-(--cp-bg-secondary) py-2"
|
||||
>
|
||||
<div class="flex items-center justify-between gap-3 text-[12px] font-[720]">
|
||||
<span class="text-(--cp-text-secondary)">{{ window.labelDisplay }}</span>
|
||||
<span class="text-(--cp-text-primary)">{{ window.usedPercentDisplay }}</span>
|
||||
</div>
|
||||
<div class="mt-2 h-2 overflow-hidden rounded-full bg-(--cp-bg-tertiary)">
|
||||
<div
|
||||
class="h-full rounded-full bg-(--cp-info)"
|
||||
:style="{ width: quotaWindowBarWidth(window) }"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
class="mt-3 flex flex-wrap justify-between gap-x-3 gap-y-1 text-[12px] font-[620] text-(--cp-text-secondary)"
|
||||
>
|
||||
<span>重置时间: {{ window.resetAtDisplay }}</span>
|
||||
<span>窗口已用: {{ window.windowUsedDisplay }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="quotaWindowsByGroup(row, 'shortTerm').length > 0"
|
||||
class="grid gap-2 sm:grid-cols-2"
|
||||
>
|
||||
<div
|
||||
v-for="window in quotaWindowsByGroup(row, 'shortTerm')"
|
||||
:key="window.key"
|
||||
class="rounded-lg bg-(--cp-bg-secondary) py-2"
|
||||
>
|
||||
<div class="flex items-center justify-between gap-3 text-[12px] font-[720]">
|
||||
<span class="text-(--cp-text-secondary)">{{ window.labelDisplay }}</span>
|
||||
<span class="text-(--cp-text-primary)">{{ window.usedPercentDisplay }}</span>
|
||||
</div>
|
||||
<div class="mt-2 h-2 overflow-hidden rounded-full bg-(--cp-bg-tertiary)">
|
||||
<div
|
||||
class="h-full rounded-full bg-(--cp-info)"
|
||||
:style="{ width: quotaWindowBarWidth(window) }"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
class="mt-3 flex flex-col gap-1 text-[12px] font-[620] text-(--cp-text-secondary)"
|
||||
>
|
||||
<span>重置时间: {{ window.resetAtDisplay }}</span>
|
||||
<span>窗口已用: {{ window.windowUsedDisplay }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-for="window in quotaWindowsByGroup(row, 'other')"
|
||||
:key="window.key"
|
||||
class="rounded-lg bg-(--cp-bg-secondary) py-2"
|
||||
>
|
||||
<div class="flex items-center justify-between gap-3 text-[12px] font-[720]">
|
||||
<span class="text-(--cp-text-secondary)">{{ window.labelDisplay }}</span>
|
||||
<span class="text-(--cp-text-primary)">{{ window.usedPercentDisplay }}</span>
|
||||
</div>
|
||||
<div class="mt-2 h-2 overflow-hidden rounded-full bg-(--cp-bg-tertiary)">
|
||||
<div
|
||||
class="h-full rounded-full bg-(--cp-info)"
|
||||
:style="{ width: quotaWindowBarWidth(window) }"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
class="mt-3 flex flex-wrap justify-between gap-x-3 gap-y-1 text-[12px] font-[620] text-(--cp-text-secondary)"
|
||||
>
|
||||
<span>重置时间: {{ window.resetAtDisplay }}</span>
|
||||
<span>窗口已用: {{ window.windowUsedDisplay }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
||||
@@ -143,10 +143,10 @@ const quotaToneClasses: Record<SemanticTone, string> = {
|
||||
<template>
|
||||
<BaseCard as="article" :padded="false" class="w-full xl:h-112.5">
|
||||
<div
|
||||
class="grid px-4 pt-5 pb-6 lg:px-7 lg:pt-6 xl:grid-cols-[minmax(360px,360fr)_minmax(612px,612fr)_minmax(500px,500fr)] xl:gap-7 xl:pb-0"
|
||||
class="grid px-4 pt-5 pb-6 lg:px-7 lg:pt-6 xl:grid-cols-[minmax(0,0.9fr)_minmax(0,1.28fr)_minmax(280px,0.9fr)] xl:gap-7 xl:pb-0"
|
||||
>
|
||||
<section
|
||||
class="w-full pb-6 shadow-[inset_0_-1px_0_rgba(15,23,42,0.08)] xl:h-100.5 xl:pb-0 xl:shadow-none"
|
||||
class="min-w-0 w-full pb-6 shadow-[inset_0_-1px_0_rgba(15,23,42,0.08)] xl:h-100.5 xl:pb-0 xl:shadow-none"
|
||||
>
|
||||
<h2 class="m-0 text-xl leading-[1.15] font-[760] text-(--cp-text-primary)">账号调度</h2>
|
||||
<p class="mt-1.75 mb-0 text-[13px] leading-[1.15] font-semibold text-(--cp-text-secondary)">
|
||||
@@ -198,7 +198,7 @@ const quotaToneClasses: Record<SemanticTone, string> = {
|
||||
</section>
|
||||
|
||||
<section
|
||||
class="w-full py-6 shadow-[inset_0_-1px_0_rgba(15,23,42,0.08)] xl:py-0 xl:shadow-none"
|
||||
class="min-w-0 w-full py-6 shadow-[inset_0_-1px_0_rgba(15,23,42,0.08)] xl:py-0 xl:shadow-none"
|
||||
>
|
||||
<h2 class="m-0 text-xl leading-[1.15] font-[760] text-(--cp-text-primary)">活跃账号用量</h2>
|
||||
<p class="mt-1.75 mb-0 text-[13px] leading-[1.15] font-semibold text-(--cp-text-secondary)">
|
||||
@@ -217,7 +217,7 @@ const quotaToneClasses: Record<SemanticTone, string> = {
|
||||
<article
|
||||
v-for="(account, index) in accounts"
|
||||
:key="account.name"
|
||||
class="grid w-full grid-cols-[34px_minmax(0,1fr)] gap-x-3 rounded-[14px] px-3.5 py-3.5 hover:bg-(--cp-bg-subtle) xl:h-19.5 xl:grid-cols-[34px_minmax(150px,1fr)_76px_84px_84px] xl:items-center xl:gap-x-3 xl:py-0"
|
||||
class="grid w-full grid-cols-[34px_minmax(0,1fr)] gap-x-3 rounded-[14px] px-3.5 py-3.5 hover:bg-(--cp-bg-subtle) xl:h-19.5 xl:grid-cols-[34px_minmax(0,1.28fr)_minmax(132px,0.86fr)] xl:items-center xl:gap-x-3 xl:py-0"
|
||||
:class="['bg-(--cp-bg-subtle)', 'bg-white'][index % 2]"
|
||||
>
|
||||
<span
|
||||
@@ -226,39 +226,43 @@ const quotaToneClasses: Record<SemanticTone, string> = {
|
||||
>
|
||||
{{ account.name[0] }}
|
||||
</span>
|
||||
<span class="grid min-w-0 gap-1.5 xl:gap-4.25">
|
||||
<span class="flex min-w-0 items-start">
|
||||
<strong class="text-sm leading-[1.15] font-[650] text-(--cp-text-primary)">{{
|
||||
account.name
|
||||
}}</strong>
|
||||
<span class="flex min-w-0 max-w-full flex-col gap-1.5 xl:gap-4.25">
|
||||
<span class="flex min-w-0 max-w-full items-start gap-1.5">
|
||||
<strong
|
||||
class="min-w-0 truncate text-sm leading-[1.15] font-[650] text-(--cp-text-primary)"
|
||||
:title="account.name"
|
||||
>{{ account.name }}</strong
|
||||
>
|
||||
<small
|
||||
class="ml-1.5 mt-0.75 text-[11px] leading-[1.15] font-[650] text-(--cp-text-muted)"
|
||||
class="mt-0.75 shrink-0 text-[11px] leading-[1.15] font-[650] text-(--cp-text-muted)"
|
||||
>{{ account.plan }}</small
|
||||
>
|
||||
</span>
|
||||
<span
|
||||
class="min-w-0 truncate text-xs leading-[1.15] font-semibold text-(--cp-text-secondary)"
|
||||
class="block min-w-0 max-w-full truncate text-xs leading-[1.15] font-semibold text-(--cp-text-secondary)"
|
||||
:title="account.email"
|
||||
>{{ account.email }}</span
|
||||
>
|
||||
</span>
|
||||
<span
|
||||
class="col-span-2 mt-3 grid grid-cols-3 gap-3 pl-11 xl:col-span-3 xl:mt-0 xl:grid-cols-[76px_84px_84px] xl:pl-0"
|
||||
class="col-span-2 mt-3 grid grid-cols-3 gap-3 pl-11 xl:col-span-1 xl:mt-0 xl:grid-cols-[minmax(0,56px)_minmax(72px,1fr)] xl:gap-6 xl:pl-0"
|
||||
>
|
||||
<span class="grid min-w-0 gap-1.5">
|
||||
<span class="grid min-w-0 gap-1.5 xl:gap-1">
|
||||
<span
|
||||
class="text-[11px] leading-[1.15] font-[650] text-(--cp-text-muted) xl:hidden"
|
||||
>请求</span
|
||||
>最近</span
|
||||
>
|
||||
<strong
|
||||
class="w-full font-mono text-sm leading-[1.15] font-bold tabular-nums text-(--cp-text-primary)"
|
||||
>{{ account.requests }}</strong
|
||||
class="hidden shrink-0 font-mono text-sm leading-[1.15] font-bold tabular-nums text-(--cp-text-primary) xl:block"
|
||||
>{{ account.tokens }}</strong
|
||||
>
|
||||
<span
|
||||
class="w-full truncate text-xs leading-[1.15] font-semibold text-(--cp-text-secondary) xl:w-20 xl:whitespace-nowrap"
|
||||
>{{ account.lastUsed }}</span
|
||||
class="min-w-0 truncate text-xs leading-[1.15] font-semibold text-(--cp-text-secondary) xl:whitespace-nowrap"
|
||||
>
|
||||
{{ account.lastUsed }}
|
||||
</span>
|
||||
</span>
|
||||
<span class="grid min-w-0 gap-1.5">
|
||||
<span class="grid min-w-0 gap-1.5 xl:hidden">
|
||||
<span
|
||||
class="text-[11px] leading-[1.15] font-[650] text-(--cp-text-muted) xl:hidden"
|
||||
>Token</span
|
||||
@@ -292,7 +296,7 @@ const quotaToneClasses: Record<SemanticTone, string> = {
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="w-full pt-6 xl:h-100.5 xl:pt-0">
|
||||
<section class="min-w-0 w-full pt-6 xl:h-100.5 xl:pt-0">
|
||||
<header class="flex h-12.5 items-start justify-between">
|
||||
<div>
|
||||
<h2 class="m-0 text-xl leading-[1.15] font-[760] text-(--cp-text-primary)">账号状态</h2>
|
||||
|
||||
Reference in New Issue
Block a user