Skip to content

Commit 6e4f284

Browse files
committed
feat: 管理后台用户名和脚本名添加可点击链接
用户管理、脚本管理、评分管理页面中的用户名和脚本名改为可点击链接, 点击后在新标签页打开对应的用户主页或脚本详情页。
1 parent d328cd6 commit 6e4f284

3 files changed

Lines changed: 28 additions & 5 deletions

File tree

src/app/[locale]/(main)/admin/scores/components/ScoresClient.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import type { ScoreItem } from '@/lib/api/services/admin';
1818
import { scriptService } from '@/lib/api/services/scripts/scripts';
1919
import { APIError } from '@/types/api';
2020
import type { ColumnsType } from 'antd/es/table';
21+
import { Link } from '@/i18n/routing';
2122

2223
export default function ScoresClient() {
2324
const t = useTranslations('admin.scores');
@@ -86,14 +87,22 @@ export default function ScoresClient() {
8687
},
8788
{
8889
title: t('col_username'),
89-
dataIndex: 'username',
9090
key: 'username',
91+
render: (_: unknown, record: ScoreItem) => (
92+
<Link href={`/users/${record.user_id}`} target="_blank">
93+
{record.username}
94+
</Link>
95+
),
9196
},
9297
{
9398
title: t('col_script'),
94-
dataIndex: 'script_name',
9599
key: 'script_name',
96100
ellipsis: true,
101+
render: (_: unknown, record: ScoreItem) => (
102+
<Link href={`/script-show-page/${record.script_id}`} target="_blank">
103+
{record.script_name}
104+
</Link>
105+
),
97106
},
98107
{
99108
title: t('col_score'),

src/app/[locale]/(main)/admin/scripts/components/ScriptsClient.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import type { ScriptItem } from '@/lib/api/services/admin';
1919
import { scriptService } from '@/lib/api/services/scripts/scripts';
2020
import { APIError } from '@/types/api';
2121
import type { ColumnsType } from 'antd/es/table';
22+
import { Link } from '@/i18n/routing';
2223

2324
export default function ScriptsClient() {
2425
const t = useTranslations('admin.scripts');
@@ -155,14 +156,22 @@ export default function ScriptsClient() {
155156
},
156157
{
157158
title: t('col_name'),
158-
dataIndex: 'name',
159159
key: 'name',
160160
ellipsis: true,
161+
render: (_: unknown, record: ScriptItem) => (
162+
<Link href={`/script-show-page/${record.id}`} target="_blank">
163+
{record.name}
164+
</Link>
165+
),
161166
},
162167
{
163168
title: t('col_author'),
164-
dataIndex: 'username',
165169
key: 'username',
170+
render: (_: unknown, record: ScriptItem) => (
171+
<Link href={`/users/${record.user_id}`} target="_blank">
172+
{record.username}
173+
</Link>
174+
),
166175
},
167176
{
168177
title: t('col_type'),

src/app/[locale]/(main)/admin/users/components/UsersClient.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { adminService } from '@/lib/api/services/admin';
1818
import type { UserItem } from '@/lib/api/services/admin';
1919
import { APIError } from '@/types/api';
2020
import type { ColumnsType } from 'antd/es/table';
21+
import { Link } from '@/i18n/routing';
2122

2223
export default function UsersClient() {
2324
const t = useTranslations('admin.users');
@@ -129,8 +130,12 @@ export default function UsersClient() {
129130
},
130131
{
131132
title: t('col_username'),
132-
dataIndex: 'username',
133133
key: 'username',
134+
render: (_: unknown, record: UserItem) => (
135+
<Link href={`/users/${record.id}`} target="_blank">
136+
{record.username}
137+
</Link>
138+
),
134139
},
135140
{
136141
title: t('col_email'),

0 commit comments

Comments
 (0)