feat: 自行开发设计 ui样式优化 超管端-控制台 相关的页面

This commit is contained in:
zhanjunhao
2026-11-09 21:45:37 +08:00
parent 6ad95e2baa
commit 5713d541b0
242 changed files with 9242 additions and 5043 deletions
@@ -18,15 +18,8 @@ For commercial licensing, please contact support@quantumnous.com
*/
import React from 'react';
import {
Button,
Space,
Tag,
Typography,
Popover,
Dropdown,
} from '@/components/ui';
import { IconMore } from '@/components/ui/icons';
import { Button, Switch, Tag as AntTag } from 'antd';
import { Tag, Typography, Popover } from '@/components/ui';
import {
renderGroup,
renderQuota,
@@ -37,18 +30,33 @@ import {
const { Text } = Typography;
const statusMeta = {
1: { color: 'green', label: '已启用' },
2: { color: 'grey', label: '已禁用' },
3: { color: 'red', label: '已过期' },
4: { color: 'orange', label: '已耗尽' },
3: { color: 'error', label: '已过期' },
4: { color: 'warning', label: '已耗尽' },
};
const renderStatus = (status, t) => {
const meta = statusMeta[status] || { color: 'red', label: t('未知状态') };
const renderStatus = (status, record, t, showEnableDisableModal) => {
const meta =
statusMeta[status] ||
(![1, 2].includes(status) ? { color: 'error', label: '未知状态' } : null);
return (
<Tag color={meta.color} shape='circle' size='small'>
{t(meta.label)}
</Tag>
<div className='admin-tokens-status'>
<Switch
size='small'
checked={status === 1}
checkedChildren={t('启用')}
unCheckedChildren={t('禁用')}
aria-label={status === 1 ? t('禁用') : t('启用')}
disabled={!isAdmin() || Boolean(record.DeletedAt)}
onChange={() =>
showEnableDisableModal(record, status === 1 ? 'disable' : 'enable')
}
/>
{meta && (
<AntTag color={meta.color} bordered={false}>
{t(meta.label)}
</AntTag>
)}
</div>
);
};
@@ -72,21 +80,17 @@ const renderUserCell = (text, record, t) => {
);
};
const renderKey = (text, record) => {
const renderKey = (text) => {
// 后端已脱敏,前端再加 sk- 前缀
return (
<code className='text-xs bg-[var(--ui-color-fill-0)] px-2 py-0.5 rounded font-mono'>
sk-{text}
</code>
);
return <code className='admin-tokens-key'>sk-{text}</code>;
};
const renderQuotaCell = (text, record, t) => {
if (record.unlimited_quota) {
return (
<Tag color='violet' shape='circle' size='small'>
<AntTag color='success' bordered={false}>
{t('无限制')}
</Tag>
</AntTag>
);
}
const used = record.used_quota || 0;
@@ -103,9 +107,7 @@ const renderQuotaCell = (text, record, t) => {
);
return (
<Popover content={popoverContent} position='top'>
<Tag color='white' shape='circle' size='small'>
{renderQuota(remain)}
</Tag>
<span>{renderQuota(remain)}</span>
</Popover>
);
};
@@ -113,13 +115,8 @@ const renderQuotaCell = (text, record, t) => {
const renderTime = (ts, t) => {
if (!ts || ts === 0)
return <span className='text-[var(--ui-color-text-2)]'>—</span>;
if (ts === -1)
return (
<Tag color='blue' shape='circle' size='small'>
{t('永不过期')}
</Tag>
);
return <span className='text-xs'>{timestamp2string(ts)}</span>;
if (ts === -1) return <span>{t('永不过期')}</span>;
return <span>{timestamp2string(ts)}</span>;
};
const renderScope = (orgId, t) => {
@@ -140,51 +137,28 @@ const renderScope = (orgId, t) => {
const renderOperations = (
text,
record,
{ showEditTokenModal, showEnableDisableModal, showDeleteTokenModal, t },
{ showEditTokenModal, showDeleteTokenModal, t },
) => {
if (record.DeletedAt) return <></>;
const isEnabled = record.status === 1;
if (!isAdmin()) return null;
return (
<Space>
<div className='admin-tokens-row-actions'>
<Button
size='small'
type='tertiary'
type='link'
onClick={() => showEditTokenModal(record)}
>
{t('编辑')}
</Button>
{isEnabled ? (
<Button
size='small'
type='danger'
onClick={() => showEnableDisableModal(record, 'disable')}
>
{t('禁用')}
</Button>
) : (
<Button
size='small'
onClick={() => showEnableDisableModal(record, 'enable')}
>
{t('启用')}
</Button>
)}
<Dropdown
trigger='click'
position='bottomRight'
menu={[
{
node: 'item',
name: t('删除'),
type: 'danger',
onClick: () => showDeleteTokenModal(record),
},
]}
<Button
size='small'
type='link'
danger
onClick={() => showDeleteTokenModal(record)}
>
<Button size='small' type='tertiary' icon={<IconMore />} />
</Dropdown>
</Space>
{t('删除')}
</Button>
</div>
);
};
@@ -207,10 +181,13 @@ export const getAdminTokensColumns = ({
render: (text, record) => renderUserCell(text, record, t),
},
{
title: t('密钥名称'),
title: t('名称'),
dataIndex: 'name',
render: (text) => (
<span className='truncate inline-block max-w-[160px]' title={text}>
<span
className='admin-tokens-name truncate inline-block max-w-[160px]'
title={text}
>
{text || <Text type='tertiary'>—</Text>}
</span>
),
@@ -223,8 +200,9 @@ export const getAdminTokensColumns = ({
{
title: t('状态'),
dataIndex: 'status',
width: 90,
render: (text) => renderStatus(text, t),
width: 150,
render: (text, record) =>
renderStatus(text, record, t, showEnableDisableModal),
},
{
title: t('归属'),
@@ -248,11 +226,7 @@ export const getAdminTokensColumns = ({
title: t('已用额度'),
dataIndex: 'used_quota',
width: 110,
render: (text) => (
<Text type='tertiary' size='small'>
{renderQuota(text || 0)}
</Text>
),
render: (text) => <span>{renderQuota(text || 0)}</span>,
},
{
title: t('创建时间'),
@@ -273,14 +247,13 @@ export const getAdminTokensColumns = ({
render: (text) => renderTime(text, t),
},
{
title: '',
title: t('操作'),
dataIndex: 'operate',
fixed: 'right',
width: 200,
width: 130,
render: (text, record) =>
renderOperations(text, record, {
showEditTokenModal,
showEnableDisableModal,
showDeleteTokenModal,
t,
}),