Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
929b5060
authored
Mar 23, 2026
by
Seefs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: simplify codex account modal and collapse raw json by default
parent
755ece2f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
31 deletions
+27
-31
web/src/components/table/channels/modals/CodexUsageModal.jsx
+27
-31
No files found.
web/src/components/table/channels/modals/CodexUsageModal.jsx
View file @
929b5060
...
@@ -25,6 +25,8 @@ import {
...
@@ -25,6 +25,8 @@ import {
Typography
,
Typography
,
Spin
,
Spin
,
Tag
,
Tag
,
Descriptions
,
Collapse
,
}
from
'@douyinfe/semi-ui'
;
}
from
'@douyinfe/semi-ui'
;
import
{
API
,
showError
}
from
'../../../../helpers'
;
import
{
API
,
showError
}
from
'../../../../helpers'
;
...
@@ -181,17 +183,13 @@ const resolveUsageStatusTag = (t, rateLimit) => {
...
@@ -181,17 +183,13 @@ const resolveUsageStatusTag = (t, rateLimit) => {
return
<
Tag
color=
'red'
>
{
tt
(
'受限'
)
}
</
Tag
>;
return
<
Tag
color=
'red'
>
{
tt
(
'受限'
)
}
</
Tag
>;
};
};
const
AccountInfo
Card
=
({
t
,
label
,
value
,
onCopy
,
monospace
=
false
})
=>
{
const
AccountInfo
Value
=
({
t
,
value
,
onCopy
,
monospace
=
false
})
=>
{
const
tt
=
typeof
t
===
'function'
?
t
:
(
v
)
=>
v
;
const
tt
=
typeof
t
===
'function'
?
t
:
(
v
)
=>
v
;
const
text
=
getDisplayText
(
value
);
const
text
=
getDisplayText
(
value
);
const
hasValue
=
text
!==
''
;
const
hasValue
=
text
!==
''
;
return
(
return
(
<
div
className=
'rounded-md bg-semi-color-fill-0 px-2.5 py-2'
>
<
div
className=
'flex min-w-0 items-start justify-between gap-2'
>
<
div
className=
'text-[11px] text-semi-color-text-2'
>
{
label
}
</
div
>
<
div
className=
'mt-1 flex items-start justify-between gap-2'
>
<
div
<
div
className=
{
`min-w-0 flex-1 break-all text-xs leading-5 text-semi-color-text-1 ${
className=
{
`min-w-0 flex-1 break-all text-xs leading-5 text-semi-color-text-1 ${
monospace ? 'font-mono' : ''
monospace ? 'font-mono' : ''
...
@@ -203,14 +201,13 @@ const AccountInfoCard = ({ t, label, value, onCopy, monospace = false }) => {
...
@@ -203,14 +201,13 @@ const AccountInfoCard = ({ t, label, value, onCopy, monospace = false }) => {
size=
'small'
size=
'small'
type=
'tertiary'
type=
'tertiary'
theme=
'borderless'
theme=
'borderless'
className=
'
px-1 text-xs'
className=
'shrink-0
px-1 text-xs'
disabled=
{
!
hasValue
}
disabled=
{
!
hasValue
}
onClick=
{
()
=>
onCopy
?.(
text
)
}
onClick=
{
()
=>
onCopy
?.(
text
)
}
>
>
{
tt
(
'复制'
)
}
{
tt
(
'复制'
)
}
</
Button
>
</
Button
>
</
div
>
</
div
>
</
div
>
);
);
};
};
...
@@ -321,22 +318,28 @@ const CodexUsageView = ({ t, record, payload, onCopy, onRefresh }) => {
...
@@ -321,22 +318,28 @@ const CodexUsageView = ({ t, record, payload, onCopy, onRefresh }) => {
</
Button
>
</
Button
>
</
div
>
</
div
>
<
div
className=
'mt-2 grid grid-cols-1 gap-2 md:grid-cols-3'
>
<
div
className=
'mt-2 rounded-lg bg-semi-color-fill-0 px-3 py-2'
>
<
AccountInfoCard
<
Descriptions
>
<
Descriptions
.
Item
itemKey=
'User ID'
>
<
AccountInfoValue
t=
{
tt
}
t=
{
tt
}
label=
'User ID'
value=
{
userId
}
value=
{
userId
}
onCopy=
{
onCopy
}
onCopy=
{
onCopy
}
monospace=
{
true
}
monospace=
{
true
}
/>
/>
<
AccountInfoCard
t=
{
tt
}
label=
{
tt
(
'邮箱'
)
}
value=
{
email
}
onCopy=
{
onCopy
}
/>
</
Descriptions
.
Item
>
<
AccountInfoCard
<
Descriptions
.
Item
itemKey=
{
tt
(
'邮箱'
)
}
>
<
AccountInfoValue
t=
{
tt
}
value=
{
email
}
onCopy=
{
onCopy
}
/>
</
Descriptions
.
Item
>
<
Descriptions
.
Item
itemKey=
'Account ID'
>
<
AccountInfoValue
t=
{
tt
}
t=
{
tt
}
label=
'Account ID'
value=
{
accountId
}
value=
{
accountId
}
onCopy=
{
onCopy
}
onCopy=
{
onCopy
}
monospace=
{
true
}
monospace=
{
true
}
/>
/>
</
Descriptions
.
Item
>
</
Descriptions
>
</
div
>
</
div
>
<
div
className=
'mt-2 text-xs text-semi-color-text-2'
>
<
div
className=
'mt-2 text-xs text-semi-color-text-2'
>
...
@@ -370,19 +373,15 @@ const CodexUsageView = ({ t, record, payload, onCopy, onRefresh }) => {
...
@@ -370,19 +373,15 @@ const CodexUsageView = ({ t, record, payload, onCopy, onRefresh }) => {
/>
/>
</
div
>
</
div
>
<
div
>
<
Collapse
<
div
className=
'mb-1 flex items-center justify-between gap-2'
>
activeKey=
{
showRawJson
?
[
'raw-json'
]
:
[]
}
<
div
className=
'text-sm font-medium'
>
{
tt
(
'原始 JSON'
)
}
</
div
>
onChange=
{
(
activeKey
)
=>
{
<
div
className=
'flex items-center gap-2'
>
const
keys
=
Array
.
isArray
(
activeKey
)
?
activeKey
:
[
activeKey
];
<
Button
setShowRawJson
(
keys
.
includes
(
'raw-json'
));
size=
'small'
}
}
type=
'tertiary'
theme=
'outline'
onClick=
{
()
=>
setShowRawJson
((
prev
)
=>
!
prev
)
}
>
>
{
showRawJson
?
tt
(
'收起'
)
:
tt
(
'展开'
)
}
<
Collapse
.
Panel
header=
{
tt
(
'原始 JSON'
)
}
itemKey=
'raw-json'
>
</
Button
>
<
div
className=
'mb-2 flex justify-end'
>
{
showRawJson
&&
(
<
Button
<
Button
size=
'small'
size=
'small'
type=
'primary'
type=
'primary'
...
@@ -392,15 +391,12 @@ const CodexUsageView = ({ t, record, payload, onCopy, onRefresh }) => {
...
@@ -392,15 +391,12 @@ const CodexUsageView = ({ t, record, payload, onCopy, onRefresh }) => {
>
>
{
tt
(
'复制'
)
}
{
tt
(
'复制'
)
}
</
Button
>
</
Button
>
)
}
</
div
>
</
div
>
</
div
>
{
showRawJson
&&
(
<
pre
className=
'max-h-[50vh] overflow-y-auto rounded-lg bg-semi-color-fill-0 p-3 text-xs text-semi-color-text-0'
>
<
pre
className=
'max-h-[50vh] overflow-y-auto rounded-lg bg-semi-color-fill-0 p-3 text-xs text-semi-color-text-0'
>
{
rawText
}
{
rawText
}
</
pre
>
</
pre
>
)
}
</
Collapse
.
Panel
>
</
div
>
</
Collapse
>
</
div
>
</
div
>
);
);
};
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment