Skip to content

Commit 01bf8b9

Browse files
committed
update log layout
1 parent f00f4a4 commit 01bf8b9

File tree

3 files changed

+54
-46
lines changed

3 files changed

+54
-46
lines changed

bun.lock

Lines changed: 25 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"@rsbuild/core": "^1.7.5",
1616
"@rsbuild/plugin-react": "^1.4.6",
1717
"@rsbuild/plugin-svgr": "^1.3.1",
18-
"@tanstack/react-query": "^5.96.2",
18+
"@tanstack/react-query": "^5.97.0",
1919
"antd": "^6.3.5",
2020
"dayjs": "^1.11.20",
2121
"git-url-parse": "^16.1.0",
@@ -30,14 +30,14 @@
3030
"xlsx": "^0.18.5"
3131
},
3232
"devDependencies": {
33-
"@biomejs/biome": "2.4.10",
33+
"@biomejs/biome": "2.4.11",
3434
"@tailwindcss/postcss": "^4.2.2",
3535
"@types/git-url-parse": "^16.0.2",
36-
"@types/node": "^25.5.2",
36+
"@types/node": "^25.6.0",
3737
"@types/react": "^19",
3838
"@types/react-dom": "^19",
3939
"@types/react-router-dom": "^5.3.3",
40-
"@typescript/native-preview": "^7.0.0-dev.20260408.1",
40+
"@typescript/native-preview": "^7.0.0-dev.20260410.1",
4141
"mitata": "^1.0.34",
4242
"tailwindcss": "^4.2.2",
4343
"typescript": "^6.0.2"

src/pages/audit-logs.tsx

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ export const getUA = (userAgent: string) => {
3636

3737
const { Text } = Typography;
3838

39+
const getApiTokenLabel = (apiTokens?: AuditLog['apiTokens']) => {
40+
if (!apiTokens?.tokenSuffix) {
41+
return undefined;
42+
}
43+
44+
return apiTokens.name
45+
? `${apiTokens.name}(****${apiTokens.tokenSuffix})`
46+
: `****${apiTokens.tokenSuffix}`;
47+
};
48+
3949
// 将 path 中的数字替换为 {id},并移除末尾的斜杠
4050
const normalizePath = (path: string): string => {
4151
return path.replace(/\/\d+/g, '/{id}').replace(/\/$/, '');
@@ -181,18 +191,23 @@ const columns: ColumnType<AuditLog>[] = [
181191
title: '设备信息',
182192
dataIndex: 'userAgent',
183193
responsive: ['lg'],
184-
width: 250,
194+
width: 200,
185195
ellipsis: {
186196
showTitle: false,
187197
},
188198
render: (userAgent: string | undefined, record: AuditLog) => {
189-
const hasInfo = userAgent || record.ip;
199+
const apiToken = getApiTokenLabel(record.apiTokens);
200+
const hasInfo = userAgent || record.ip || apiToken;
190201
if (!hasInfo) {
191202
return <Text type="secondary">-</Text>;
192203
}
193204

205+
const title = [userAgent, record.ip && `IP: ${record.ip}`, apiToken]
206+
.filter(Boolean)
207+
.join('\n');
208+
194209
return (
195-
<div title={userAgent || record.ip}>
210+
<div title={title}>
196211
{userAgent && <div>{getUA(userAgent)}</div>}
197212
{record.ip && (
198213
<div className="mt-1">
@@ -201,24 +216,17 @@ const columns: ColumnType<AuditLog>[] = [
201216
</Text>
202217
</div>
203218
)}
219+
{apiToken && (
220+
<div className="mt-1">
221+
<Text type="secondary" className="font-mono text-xs">
222+
API Key:{apiToken}
223+
</Text>
224+
</div>
225+
)}
204226
</div>
205227
);
206228
},
207229
},
208-
{
209-
title: 'API Key',
210-
dataIndex: 'apiTokens',
211-
responsive: ['lg'],
212-
width: 150,
213-
render: (apiTokens?: { name: string; tokenSuffix: string }) =>
214-
apiTokens ? (
215-
<Text className="font-mono text-xs">
216-
{apiTokens.name}(****{apiTokens.tokenSuffix})
217-
</Text>
218-
) : (
219-
<Text type="secondary">-</Text>
220-
),
221-
},
222230
];
223231

224232
export const AuditLogs = () => {

0 commit comments

Comments
 (0)