From eff51857d031e33e6a98e49f2e33036e27c51162 Mon Sep 17 00:00:00 2001 From: Seefs Date: Fri, 20 Mar 2026 16:00:36 +0800 Subject: [PATCH 1/3] refactor: show codex account info tag and highlight plan type in usage modal --- .../table/channels/ChannelsColumnDefs.jsx | 19 +- .../table/channels/modals/CodexUsageModal.jsx | 192 +++++++++++++++--- 2 files changed, 173 insertions(+), 38 deletions(-) diff --git a/web/src/components/table/channels/ChannelsColumnDefs.jsx b/web/src/components/table/channels/ChannelsColumnDefs.jsx index 7fdd71b0..5d748c0f 100644 --- a/web/src/components/table/channels/ChannelsColumnDefs.jsx +++ b/web/src/components/table/channels/ChannelsColumnDefs.jsx @@ -538,19 +538,24 @@ export const getChannelsColumns = ({ updateChannelBalance(record)} > - {renderQuotaWithAmount(record.balance)} + {record.type === 57 + ? t('帐号信息') + : renderQuotaWithAmount(record.balance)} diff --git a/web/src/components/table/channels/modals/CodexUsageModal.jsx b/web/src/components/table/channels/modals/CodexUsageModal.jsx index 76c84b90..2e36474a 100644 --- a/web/src/components/table/channels/modals/CodexUsageModal.jsx +++ b/web/src/components/table/channels/modals/CodexUsageModal.jsx @@ -22,9 +22,9 @@ import { Modal, Button, Progress, - Tag, Typography, Spin, + Tag, } from '@douyinfe/semi-ui'; import { API, showError } from '../../../../helpers'; @@ -128,6 +128,91 @@ const formatUnixSeconds = (unixSeconds) => { } }; +const getDisplayText = (value) => { + if (value == null) return ''; + return String(value).trim(); +}; + +const formatAccountTypeLabel = (value, t) => { + const tt = typeof t === 'function' ? t : (v) => v; + const normalized = normalizePlanType(value); + switch (normalized) { + case 'free': + return 'Free'; + case 'plus': + return 'Plus'; + case 'pro': + return 'Pro'; + case 'team': + return 'Team'; + case 'enterprise': + return 'Enterprise'; + default: + return getDisplayText(value) || tt('未识别'); + } +}; + +const getAccountTypeTagColor = (value) => { + const normalized = normalizePlanType(value); + switch (normalized) { + case 'enterprise': + return 'green'; + case 'team': + return 'cyan'; + case 'pro': + return 'blue'; + case 'plus': + return 'violet'; + case 'free': + return 'amber'; + default: + return 'grey'; + } +}; + +const resolveUsageStatusTag = (t, rateLimit) => { + const tt = typeof t === 'function' ? t : (v) => v; + if (!rateLimit || Object.keys(rateLimit).length === 0) { + return {tt('待确认')}; + } + if (rateLimit?.allowed && !rateLimit?.limit_reached) { + return {tt('可用')}; + } + return {tt('受限')}; +}; + +const AccountInfoCard = ({ t, label, value, onCopy, monospace = false }) => { + const tt = typeof t === 'function' ? t : (v) => v; + const text = getDisplayText(value); + const hasValue = text !== ''; + + return ( +
+
+ {label} +
+
+
+ {hasValue ? text : '-'} +
+ +
+
+ ); +}; + const RateLimitWindowCard = ({ t, title, windowData }) => { const tt = typeof t === 'function' ? t : (v) => v; const hasWindowData = @@ -184,47 +269,92 @@ const CodexUsageView = ({ t, record, payload, onCopy, onRefresh }) => { const data = payload?.data ?? null; const rateLimit = data?.rate_limit ?? {}; const { fiveHourWindow, weeklyWindow } = resolveRateLimitWindows(data); - - const allowed = !!rateLimit?.allowed; - const limitReached = !!rateLimit?.limit_reached; const upstreamStatus = payload?.upstream_status; - - const statusTag = - allowed && !limitReached ? ( - {tt('可用')} - ) : ( - {tt('受限')} - ); + const accountType = data?.plan_type ?? rateLimit?.plan_type; + const accountTypeLabel = formatAccountTypeLabel(accountType, tt); + const accountTypeTagColor = getAccountTypeTagColor(accountType); + const statusTag = resolveUsageStatusTag(tt, rateLimit); + const userId = data?.user_id; + const email = data?.email; + const accountId = data?.account_id; + const errorMessage = + payload?.success === false ? getDisplayText(payload?.message) || tt('获取用量失败') : ''; const rawText = typeof data === 'string' ? data : JSON.stringify(data ?? payload, null, 2); return ( -
-
- +
+ {errorMessage && ( +
+ {errorMessage} +
+ )} + +
+
+
+
+
+ {tt('Codex 帐号')} +
+
+ + {accountTypeLabel} + + {statusTag} +
+ {tt('上游状态码:')} + {upstreamStatus ?? '-'} +
+
+
+ +
+
+ +
+ + + +
+ +
{tt('渠道:')} {record?.name || '-'} ({tt('编号:')} {record?.id || '-'}) - -
- {statusTag} -
-
- - {tt('上游状态码:')} - {upstreamStatus ?? '-'} - +
+
+
+ {tt('额度窗口')} +
+ + {tt('用于观察当前帐号在 Codex 上游的限额使用情况')} + +
@@ -351,7 +481,7 @@ export const openCodexUsageModal = ({ t, record, payload, onCopy }) => { const tt = typeof t === 'function' ? t : (v) => v; Modal.info({ - title: tt('Codex 用量'), + title: tt('Codex 帐号与用量'), centered: true, width: 900, style: { maxWidth: '95vw' }, From 755ece2f01543bb18a9ec746b21dff88eac554c3 Mon Sep 17 00:00:00 2001 From: Seefs Date: Mon, 23 Mar 2026 00:58:59 +0800 Subject: [PATCH 2/3] refactor: simplify codex account modal and collapse raw json by default --- .../table/channels/modals/CodexUsageModal.jsx | 104 ++++++++++-------- 1 file changed, 59 insertions(+), 45 deletions(-) diff --git a/web/src/components/table/channels/modals/CodexUsageModal.jsx b/web/src/components/table/channels/modals/CodexUsageModal.jsx index 2e36474a..cc454891 100644 --- a/web/src/components/table/channels/modals/CodexUsageModal.jsx +++ b/web/src/components/table/channels/modals/CodexUsageModal.jsx @@ -187,14 +187,14 @@ const AccountInfoCard = ({ t, label, value, onCopy, monospace = false }) => { const hasValue = text !== ''; return ( -
-
+
+
{label}
-
+
{hasValue ? text : '-'} @@ -203,6 +203,7 @@ const AccountInfoCard = ({ t, label, value, onCopy, monospace = false }) => { size='small' type='tertiary' theme='borderless' + className='px-1 text-xs' disabled={!hasValue} onClick={() => onCopy?.(text)} > @@ -266,6 +267,7 @@ const RateLimitWindowCard = ({ t, title, windowData }) => { const CodexUsageView = ({ t, record, payload, onCopy, onRefresh }) => { const tt = typeof t === 'function' ? t : (v) => v; + const [showRawJson, setShowRawJson] = useState(false); const data = payload?.data ?? null; const rateLimit = data?.rate_limit ?? {}; const { fiveHourWindow, weeklyWindow } = resolveRateLimitWindows(data); @@ -291,37 +293,35 @@ const CodexUsageView = ({ t, record, payload, onCopy, onRefresh }) => {
)} -
-
-
-
-
- {tt('Codex 帐号')} -
-
- - {accountTypeLabel} - - {statusTag} -
- {tt('上游状态码:')} - {upstreamStatus ?? '-'} -
-
+
+
+
+
+ {tt('Codex 帐号')} +
+
+ + {accountTypeLabel} + + {statusTag} + + {tt('上游状态码:')} + {upstreamStatus ?? '-'} +
-
+
-
+
{ />
-
+
{tt('渠道:')} {record?.name || '-'} ({tt('编号:')} {record?.id || '-'}) @@ -373,19 +373,33 @@ const CodexUsageView = ({ t, record, payload, onCopy, onRefresh }) => {
{tt('原始 JSON')}
- +
+ + {showRawJson && ( + + )} +
-
-          {rawText}
-        
+ {showRawJson && ( +
+            {rawText}
+          
+ )}
); From 929b5060eab2d178bc9929f162835e049a70ba78 Mon Sep 17 00:00:00 2001 From: Seefs Date: Mon, 23 Mar 2026 13:54:54 +0800 Subject: [PATCH 3/3] refactor: simplify codex account modal and collapse raw json by default --- .../table/channels/modals/CodexUsageModal.jsx | 118 +++++++++--------- 1 file changed, 57 insertions(+), 61 deletions(-) diff --git a/web/src/components/table/channels/modals/CodexUsageModal.jsx b/web/src/components/table/channels/modals/CodexUsageModal.jsx index cc454891..1a42eafd 100644 --- a/web/src/components/table/channels/modals/CodexUsageModal.jsx +++ b/web/src/components/table/channels/modals/CodexUsageModal.jsx @@ -25,6 +25,8 @@ import { Typography, Spin, Tag, + Descriptions, + Collapse, } from '@douyinfe/semi-ui'; import { API, showError } from '../../../../helpers'; @@ -181,35 +183,30 @@ const resolveUsageStatusTag = (t, rateLimit) => { return {tt('受限')}; }; -const AccountInfoCard = ({ t, label, value, onCopy, monospace = false }) => { +const AccountInfoValue = ({ t, value, onCopy, monospace = false }) => { const tt = typeof t === 'function' ? t : (v) => v; const text = getDisplayText(value); const hasValue = text !== ''; return ( -
-
- {label} -
-
-
- {hasValue ? text : '-'} -
- +
+
+ {hasValue ? text : '-'}
+
); }; @@ -321,22 +318,28 @@ const CodexUsageView = ({ t, record, payload, onCopy, onRefresh }) => {
-
- - - +
+ + + + + + + + + + +
@@ -370,37 +373,30 @@ const CodexUsageView = ({ t, record, payload, onCopy, onRefresh }) => { />
-
-
-
{tt('原始 JSON')}
-
+ { + const keys = Array.isArray(activeKey) ? activeKey : [activeKey]; + setShowRawJson(keys.includes('raw-json')); + }} + > + +
- {showRawJson && ( - - )}
-
- {showRawJson && (
             {rawText}
           
- )} -
+ +
); };