feat: 自行开发设计 ui样式优化 超管端-控制台 相关的页面
This commit is contained in:
@@ -17,13 +17,13 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import TableEmpty from '../../common/table/TableEmpty';
|
||||
import React, { useMemo, useState } from 'react';
|
||||
import { Empty as AntEmpty } from 'antd';
|
||||
import { Button, Empty, Modal, Typography } from '@/components/ui';
|
||||
import { Button as AntButton, Table as AntTable } from 'antd';
|
||||
import { Modal, Typography } from '@/components/ui';
|
||||
import {
|
||||
Coins,
|
||||
Cpu,
|
||||
Eye,
|
||||
Gauge,
|
||||
Layers3,
|
||||
ReceiptText,
|
||||
@@ -31,10 +31,7 @@ import {
|
||||
Sparkles,
|
||||
} from 'lucide-react';
|
||||
import CardTable from '../../common/ui/CardTable';
|
||||
import {
|
||||
IllustrationNoResult,
|
||||
IllustrationNoResultDark,
|
||||
} from '../../common/illustrations';
|
||||
|
||||
import { getLogOther, renderQuota } from '../../../helpers';
|
||||
import { getLogsColumns } from './UsageLogsColumnDefs';
|
||||
|
||||
@@ -284,9 +281,9 @@ const UsageBillingDetail = ({
|
||||
<div className='usage-billing-detail'>
|
||||
<div className='mb-3 flex flex-wrap items-center justify-between gap-2'>
|
||||
<div>
|
||||
<div className='flex items-center gap-2 text-sm font-semibold text-gray-900 dark:text-white'>
|
||||
<div className='usage-billing-heading flex items-center text-sm font-semibold text-gray-900 dark:text-white'>
|
||||
<Sparkles size={15} className='text-brand' />
|
||||
{t('计费摘要')}
|
||||
<span>{t('计费摘要')}</span>
|
||||
</div>
|
||||
<Text type='tertiary' size='small'>
|
||||
{t('保留关键成本因子,省略冗长计算公式')}
|
||||
@@ -310,9 +307,9 @@ const UsageBillingDetail = ({
|
||||
: 'mt-3 rounded-2xl border border-white/55 bg-white/[0.35] p-3 backdrop-blur-xl dark:border-white/10 dark:bg-white/[0.04]'
|
||||
}
|
||||
>
|
||||
<div className='mb-2 flex items-center gap-2 text-xs font-medium uppercase tracking-[0.18em] text-gray-400'>
|
||||
<div className='usage-billing-heading mb-2 flex items-center text-xs font-medium uppercase tracking-[0.18em] text-gray-400'>
|
||||
<Layers3 size={13} />
|
||||
{t('成本因子')}
|
||||
<span>{t('成本因子')}</span>
|
||||
</div>
|
||||
<div className='flex flex-wrap gap-2'>
|
||||
{details.map((item) => (
|
||||
@@ -356,6 +353,7 @@ const LogsTable = (logsData) => {
|
||||
usageRecordMode = false,
|
||||
} = logsData;
|
||||
const [detailRecord, setDetailRecord] = useState(null);
|
||||
const TableComponent = usageRecordMode ? AntTable : CardTable;
|
||||
|
||||
// Get all columns
|
||||
const allColumns = useMemo(() => {
|
||||
@@ -378,14 +376,10 @@ const LogsTable = (logsData) => {
|
||||
usageRecordMode,
|
||||
]);
|
||||
|
||||
// Filter columns based on visibility settings
|
||||
const getVisibleColumns = () => {
|
||||
return allColumns.filter((column) => visibleColumns[column.key]);
|
||||
};
|
||||
|
||||
const visibleColumnsList = useMemo(() => {
|
||||
return getVisibleColumns();
|
||||
}, [visibleColumns, allColumns]);
|
||||
const visibleColumnsList = useMemo(
|
||||
() => allColumns.filter((column) => visibleColumns[column.key]),
|
||||
[visibleColumns, allColumns],
|
||||
);
|
||||
|
||||
const tableColumns = useMemo(() => {
|
||||
const baseColumns = compactMode
|
||||
@@ -395,32 +389,41 @@ const LogsTable = (logsData) => {
|
||||
return [
|
||||
...baseColumns,
|
||||
{
|
||||
title: t('计费详情'),
|
||||
title: usageRecordMode ? t('操作') : t('计费详情'),
|
||||
key: 'billingDetailAction',
|
||||
fixed: compactMode ? undefined : 'right',
|
||||
fixed: compactMode || usageRecordMode ? undefined : 'right',
|
||||
width: 120,
|
||||
render: (_, record) => {
|
||||
const canView =
|
||||
expandData[record.key] && expandData[record.key].length > 0;
|
||||
if (usageRecordMode) {
|
||||
return (
|
||||
<AntButton
|
||||
type='link'
|
||||
size='small'
|
||||
className='usage-record-view'
|
||||
disabled={!canView}
|
||||
onClick={(event) => {
|
||||
event.stopPropagation();
|
||||
if (canView) setDetailRecord(record);
|
||||
}}
|
||||
>
|
||||
{t('查看')}
|
||||
</AntButton>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<Button
|
||||
<AntButton
|
||||
size='small'
|
||||
theme='light'
|
||||
type='primary'
|
||||
type='link'
|
||||
disabled={!canView}
|
||||
icon={<Eye size={14} />}
|
||||
onClick={(e) => {
|
||||
e?.stopPropagation?.();
|
||||
if (canView) setDetailRecord(record);
|
||||
}}
|
||||
className={
|
||||
usageRecordMode
|
||||
? undefined
|
||||
: 'usage-record-action-button usage-record-action-button-soft !rounded-full'
|
||||
}
|
||||
>
|
||||
{t('查看')}
|
||||
</Button>
|
||||
</AntButton>
|
||||
);
|
||||
},
|
||||
},
|
||||
@@ -436,7 +439,7 @@ const LogsTable = (logsData) => {
|
||||
|
||||
return (
|
||||
<>
|
||||
<CardTable
|
||||
<TableComponent
|
||||
columns={tableColumns}
|
||||
dataSource={logs}
|
||||
rowKey='key'
|
||||
@@ -448,56 +451,32 @@ const LogsTable = (logsData) => {
|
||||
: 'rounded-xl overflow-hidden usage-logs-table'
|
||||
}
|
||||
size='middle'
|
||||
empty={
|
||||
usageRecordMode ? (
|
||||
<AntEmpty
|
||||
image={AntEmpty.PRESENTED_IMAGE_SIMPLE}
|
||||
description={
|
||||
<>
|
||||
<div>{t('搜索无结果')}</div>
|
||||
<div className='usage-record-empty-hint'>
|
||||
{t('尝试调整筛选条件')}
|
||||
</div>
|
||||
</>
|
||||
{...(usageRecordMode
|
||||
? {
|
||||
tableLayout: 'fixed',
|
||||
locale: {
|
||||
emptyText: <TableEmpty />,
|
||||
},
|
||||
}
|
||||
: {
|
||||
empty: <TableEmpty />,
|
||||
})}
|
||||
pagination={
|
||||
usageRecordMode
|
||||
? false
|
||||
: {
|
||||
currentPage: activePage,
|
||||
pageSize: pageSize,
|
||||
total: logCount,
|
||||
pageSizeOptions: [10, 20, 50, 100],
|
||||
showSizeChanger: true,
|
||||
onPageSizeChange: (size) => {
|
||||
handlePageSizeChange(size);
|
||||
},
|
||||
onPageChange: handlePageChange,
|
||||
}
|
||||
/>
|
||||
) : (
|
||||
<div className='py-12'>
|
||||
<Empty
|
||||
image={
|
||||
<IllustrationNoResult style={{ width: 180, height: 180 }} />
|
||||
}
|
||||
darkModeImage={
|
||||
<IllustrationNoResultDark
|
||||
style={{ width: 180, height: 180 }}
|
||||
/>
|
||||
}
|
||||
description={
|
||||
<div className='flex flex-col items-center gap-2'>
|
||||
<span className='text-gray-500 dark:text-gray-400 text-sm'>
|
||||
{t('搜索无结果')}
|
||||
</span>
|
||||
<span className='text-gray-400 dark:text-gray-500 text-xs'>
|
||||
{t('尝试调整筛选条件')}
|
||||
</span>
|
||||
</div>
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
pagination={{
|
||||
currentPage: activePage,
|
||||
pageSize: pageSize,
|
||||
total: logCount,
|
||||
pageSizeOptions: [10, 20, 50, 100],
|
||||
showSizeChanger: true,
|
||||
onPageSizeChange: (size) => {
|
||||
handlePageSizeChange(size);
|
||||
},
|
||||
onPageChange: handlePageChange,
|
||||
}}
|
||||
hidePagination={true}
|
||||
{...(!usageRecordMode && { hidePagination: true })}
|
||||
/>
|
||||
<Modal
|
||||
visible={!!detailRecord}
|
||||
|
||||
Reference in New Issue
Block a user