mirror of
https://github.com/router-for-me/Cli-Proxy-API-Management-Center.git
synced 2026-02-19 19:20:49 +08:00
fix(quota): use i18n params for additional limits and keep primary/secondary mapping
This commit is contained in:
@@ -220,6 +220,7 @@ const buildCodexQuotaWindows = (payload: CodexUsagePayload, t: TFunction): Codex
|
|||||||
id: string,
|
id: string,
|
||||||
label: string,
|
label: string,
|
||||||
labelKey: string | undefined,
|
labelKey: string | undefined,
|
||||||
|
labelParams: Record<string, string | number> | undefined,
|
||||||
window?: CodexUsageWindow | null,
|
window?: CodexUsageWindow | null,
|
||||||
limitReached?: boolean,
|
limitReached?: boolean,
|
||||||
allowed?: boolean
|
allowed?: boolean
|
||||||
@@ -233,6 +234,7 @@ const buildCodexQuotaWindows = (payload: CodexUsagePayload, t: TFunction): Codex
|
|||||||
id,
|
id,
|
||||||
label,
|
label,
|
||||||
labelKey,
|
labelKey,
|
||||||
|
labelParams,
|
||||||
usedPercent,
|
usedPercent,
|
||||||
resetLabel,
|
resetLabel,
|
||||||
});
|
});
|
||||||
@@ -286,6 +288,7 @@ const buildCodexQuotaWindows = (payload: CodexUsagePayload, t: TFunction): Codex
|
|||||||
WINDOW_META.codeFiveHour.id,
|
WINDOW_META.codeFiveHour.id,
|
||||||
t(WINDOW_META.codeFiveHour.labelKey),
|
t(WINDOW_META.codeFiveHour.labelKey),
|
||||||
WINDOW_META.codeFiveHour.labelKey,
|
WINDOW_META.codeFiveHour.labelKey,
|
||||||
|
undefined,
|
||||||
rateWindows.fiveHourWindow,
|
rateWindows.fiveHourWindow,
|
||||||
rawLimitReached,
|
rawLimitReached,
|
||||||
rawAllowed
|
rawAllowed
|
||||||
@@ -294,6 +297,7 @@ const buildCodexQuotaWindows = (payload: CodexUsagePayload, t: TFunction): Codex
|
|||||||
WINDOW_META.codeWeekly.id,
|
WINDOW_META.codeWeekly.id,
|
||||||
t(WINDOW_META.codeWeekly.labelKey),
|
t(WINDOW_META.codeWeekly.labelKey),
|
||||||
WINDOW_META.codeWeekly.labelKey,
|
WINDOW_META.codeWeekly.labelKey,
|
||||||
|
undefined,
|
||||||
rateWindows.weeklyWindow,
|
rateWindows.weeklyWindow,
|
||||||
rawLimitReached,
|
rawLimitReached,
|
||||||
rawAllowed
|
rawAllowed
|
||||||
@@ -306,6 +310,7 @@ const buildCodexQuotaWindows = (payload: CodexUsagePayload, t: TFunction): Codex
|
|||||||
WINDOW_META.codeReviewFiveHour.id,
|
WINDOW_META.codeReviewFiveHour.id,
|
||||||
t(WINDOW_META.codeReviewFiveHour.labelKey),
|
t(WINDOW_META.codeReviewFiveHour.labelKey),
|
||||||
WINDOW_META.codeReviewFiveHour.labelKey,
|
WINDOW_META.codeReviewFiveHour.labelKey,
|
||||||
|
undefined,
|
||||||
codeReviewWindows.fiveHourWindow,
|
codeReviewWindows.fiveHourWindow,
|
||||||
codeReviewLimitReached,
|
codeReviewLimitReached,
|
||||||
codeReviewAllowed
|
codeReviewAllowed
|
||||||
@@ -314,6 +319,7 @@ const buildCodexQuotaWindows = (payload: CodexUsagePayload, t: TFunction): Codex
|
|||||||
WINDOW_META.codeReviewWeekly.id,
|
WINDOW_META.codeReviewWeekly.id,
|
||||||
t(WINDOW_META.codeReviewWeekly.labelKey),
|
t(WINDOW_META.codeReviewWeekly.labelKey),
|
||||||
WINDOW_META.codeReviewWeekly.labelKey,
|
WINDOW_META.codeReviewWeekly.labelKey,
|
||||||
|
undefined,
|
||||||
codeReviewWindows.weeklyWindow,
|
codeReviewWindows.weeklyWindow,
|
||||||
codeReviewLimitReached,
|
codeReviewLimitReached,
|
||||||
codeReviewAllowed
|
codeReviewAllowed
|
||||||
@@ -337,23 +343,26 @@ const buildCodexQuotaWindows = (payload: CodexUsagePayload, t: TFunction): Codex
|
|||||||
`additional-${index + 1}`;
|
`additional-${index + 1}`;
|
||||||
|
|
||||||
const idPrefix = normalizeWindowId(limitName) || `additional-${index + 1}`;
|
const idPrefix = normalizeWindowId(limitName) || `additional-${index + 1}`;
|
||||||
const additionalWindows = pickClassifiedWindows(rateInfo, { allowOrderFallback: false });
|
const additionalPrimaryWindow = rateInfo.primary_window ?? rateInfo.primaryWindow ?? null;
|
||||||
|
const additionalSecondaryWindow = rateInfo.secondary_window ?? rateInfo.secondaryWindow ?? null;
|
||||||
const additionalLimitReached = rateInfo.limit_reached ?? rateInfo.limitReached;
|
const additionalLimitReached = rateInfo.limit_reached ?? rateInfo.limitReached;
|
||||||
const additionalAllowed = rateInfo.allowed;
|
const additionalAllowed = rateInfo.allowed;
|
||||||
|
|
||||||
addWindow(
|
addWindow(
|
||||||
`${idPrefix}-five-hour-${index}`,
|
`${idPrefix}-five-hour-${index}`,
|
||||||
t('codex_quota.additional_primary_window', { name: limitName }),
|
t('codex_quota.additional_primary_window', { name: limitName }),
|
||||||
undefined,
|
'codex_quota.additional_primary_window',
|
||||||
additionalWindows.fiveHourWindow,
|
{ name: limitName },
|
||||||
|
additionalPrimaryWindow,
|
||||||
additionalLimitReached,
|
additionalLimitReached,
|
||||||
additionalAllowed
|
additionalAllowed
|
||||||
);
|
);
|
||||||
addWindow(
|
addWindow(
|
||||||
`${idPrefix}-weekly-${index}`,
|
`${idPrefix}-weekly-${index}`,
|
||||||
t('codex_quota.additional_secondary_window', { name: limitName }),
|
t('codex_quota.additional_secondary_window', { name: limitName }),
|
||||||
undefined,
|
'codex_quota.additional_secondary_window',
|
||||||
additionalWindows.weeklyWindow,
|
{ name: limitName },
|
||||||
|
additionalSecondaryWindow,
|
||||||
additionalLimitReached,
|
additionalLimitReached,
|
||||||
additionalAllowed
|
additionalAllowed
|
||||||
);
|
);
|
||||||
@@ -551,7 +560,9 @@ const renderCodexItems = (
|
|||||||
const clampedUsed = used === null ? null : Math.max(0, Math.min(100, used));
|
const clampedUsed = used === null ? null : Math.max(0, Math.min(100, used));
|
||||||
const remaining = clampedUsed === null ? null : Math.max(0, Math.min(100, 100 - clampedUsed));
|
const remaining = clampedUsed === null ? null : Math.max(0, Math.min(100, 100 - clampedUsed));
|
||||||
const percentLabel = remaining === null ? '--' : `${Math.round(remaining)}%`;
|
const percentLabel = remaining === null ? '--' : `${Math.round(remaining)}%`;
|
||||||
const windowLabel = window.labelKey ? t(window.labelKey) : window.label;
|
const windowLabel = window.labelKey
|
||||||
|
? t(window.labelKey, window.labelParams as Record<string, string | number>)
|
||||||
|
: window.label;
|
||||||
|
|
||||||
return h(
|
return h(
|
||||||
'div',
|
'div',
|
||||||
|
|||||||
@@ -185,6 +185,7 @@ export interface CodexQuotaWindow {
|
|||||||
id: string;
|
id: string;
|
||||||
label: string;
|
label: string;
|
||||||
labelKey?: string;
|
labelKey?: string;
|
||||||
|
labelParams?: Record<string, string | number>;
|
||||||
usedPercent: number | null;
|
usedPercent: number | null;
|
||||||
resetLabel: string;
|
resetLabel: string;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user