feat: 自行开发设计 ui样式优化 超管端-控制台 相关的页面
This commit is contained in:
@@ -49,6 +49,18 @@
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.usage-billing-detail .usage-billing-heading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
line-height: 20px;
|
||||
}
|
||||
|
||||
.usage-billing-heading > svg {
|
||||
display: block;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.usage-logs-date-panel {
|
||||
--usage-date-accent: var(--brand-gradient-via);
|
||||
--usage-date-accent-strong: var(--brand-gradient-to);
|
||||
|
||||
@@ -336,12 +336,56 @@ const formatRecordNumber = (value) => {
|
||||
return Number.isFinite(number) ? number.toLocaleString('en-US') : value;
|
||||
};
|
||||
|
||||
// Both reference images show the same 2097px table at opposite scroll positions.
|
||||
const RECORD_COLUMN_WIDTHS = {
|
||||
time: 152,
|
||||
channel: 85,
|
||||
username: 120,
|
||||
token: 120,
|
||||
group: 148,
|
||||
type: 110,
|
||||
model: 225,
|
||||
use_time: 126,
|
||||
prompt: 110,
|
||||
completion: 110,
|
||||
cost: 136,
|
||||
ip: 110,
|
||||
retry: 120,
|
||||
details: 305,
|
||||
};
|
||||
|
||||
// 仅替换展示,不改变列的显示条件、复制回调与数据来源
|
||||
const applyUsageRecordPresentation = (columns, { t, COLUMN_KEYS, copyText }) =>
|
||||
columns.map((column) => {
|
||||
const applyUsageRecordPresentation = (
|
||||
columns,
|
||||
{ t, COLUMN_KEYS, copyText, showUserInfoFunc, isAdminUser },
|
||||
) =>
|
||||
columns.map((baseColumn) => {
|
||||
const column = {
|
||||
...baseColumn,
|
||||
width: RECORD_COLUMN_WIDTHS[baseColumn.key],
|
||||
fixed: undefined,
|
||||
className: `usage-record-cell-${baseColumn.key}`,
|
||||
};
|
||||
switch (column.key) {
|
||||
case COLUMN_KEYS.TIME:
|
||||
return { ...column, render: (text) => renderRecordTime(text) };
|
||||
case COLUMN_KEYS.USERNAME:
|
||||
return {
|
||||
...column,
|
||||
render: (text, record) =>
|
||||
isAdminUser ? (
|
||||
<button
|
||||
type='button'
|
||||
className='usage-record-copy-text'
|
||||
onClick={(event) => {
|
||||
event.stopPropagation();
|
||||
showUserInfoFunc(record.user_id);
|
||||
}}
|
||||
>
|
||||
{record.display_name || text}
|
||||
</button>
|
||||
) : null,
|
||||
};
|
||||
case COLUMN_KEYS.TOKEN:
|
||||
return {
|
||||
...column,
|
||||
@@ -374,16 +418,21 @@ const applyUsageRecordPresentation = (columns, { t, COLUMN_KEYS, copyText }) =>
|
||||
case COLUMN_KEYS.MODEL:
|
||||
return {
|
||||
...column,
|
||||
render: (text, record, index) =>
|
||||
render: (text, record) =>
|
||||
record.type === 0 || record.type === 2 || record.type === 5 ? (
|
||||
<span className='usage-record-model'>
|
||||
{column.render(text, record, index)}
|
||||
</span>
|
||||
<button
|
||||
type='button'
|
||||
className='usage-record-copy-text usage-record-model'
|
||||
onClick={(event) => copyText(event, record.model_name)}
|
||||
>
|
||||
{record.model_name}
|
||||
</button>
|
||||
) : null,
|
||||
};
|
||||
case COLUMN_KEYS.USE_TIME:
|
||||
return {
|
||||
...column,
|
||||
title: t('用时/首字').replace('/', ' / '),
|
||||
render: (text, record) =>
|
||||
record.type === 2 || record.type === 5
|
||||
? renderRecordUseTime(record, t)
|
||||
@@ -396,7 +445,13 @@ const applyUsageRecordPresentation = (columns, { t, COLUMN_KEYS, copyText }) =>
|
||||
align: 'right',
|
||||
render: (text, record, index) => {
|
||||
const node = column.render(text, record, index);
|
||||
return node?.props?.children ? formatRecordNumber(text) : null;
|
||||
const showZero =
|
||||
column.key === COLUMN_KEYS.COMPLETION &&
|
||||
Number(text) === 0 &&
|
||||
[0, 2, 5].includes(record.type);
|
||||
return node?.props?.children || showZero
|
||||
? formatRecordNumber(text)
|
||||
: null;
|
||||
},
|
||||
};
|
||||
case COLUMN_KEYS.COST:
|
||||
@@ -412,11 +467,50 @@ const applyUsageRecordPresentation = (columns, { t, COLUMN_KEYS, copyText }) =>
|
||||
case COLUMN_KEYS.IP:
|
||||
return {
|
||||
...column,
|
||||
title: (
|
||||
<Tooltip
|
||||
content={t(
|
||||
'只有当用户设置开启IP记录时,才会进行请求和错误类型日志的IP记录',
|
||||
)}
|
||||
>
|
||||
<span>{t('IP')}</span>
|
||||
</Tooltip>
|
||||
),
|
||||
render: (text, record, index) =>
|
||||
(record.type === 2 || record.type === 5) && text
|
||||
? column.render(text, record, index)
|
||||
: '—',
|
||||
};
|
||||
case COLUMN_KEYS.RETRY:
|
||||
return {
|
||||
...column,
|
||||
render: (text, record) => {
|
||||
if (!isAdminUser || (record.type !== 2 && record.type !== 5))
|
||||
return null;
|
||||
const other = getLogOther(record.other);
|
||||
const channels = other?.admin_info?.use_channel;
|
||||
return Array.isArray(channels) && channels.length
|
||||
? channels.join(' → ')
|
||||
: record.channel;
|
||||
},
|
||||
};
|
||||
case COLUMN_KEYS.DETAILS:
|
||||
return {
|
||||
...column,
|
||||
render: (text, record, index) => {
|
||||
const node = column.render(text, record, index);
|
||||
return React.cloneElement(
|
||||
node,
|
||||
{
|
||||
className: 'usage-record-details',
|
||||
style: { maxWidth: 'none', whiteSpace: 'nowrap' },
|
||||
},
|
||||
typeof node.props.children === 'string'
|
||||
? node.props.children.replaceAll(' * ', ' × ')
|
||||
: node.props.children,
|
||||
);
|
||||
},
|
||||
};
|
||||
default:
|
||||
return column;
|
||||
}
|
||||
@@ -787,6 +881,12 @@ export const getLogsColumns = ({
|
||||
},
|
||||
];
|
||||
return usageRecordMode
|
||||
? applyUsageRecordPresentation(columns, { t, COLUMN_KEYS, copyText })
|
||||
? applyUsageRecordPresentation(columns, {
|
||||
t,
|
||||
COLUMN_KEYS,
|
||||
copyText,
|
||||
showUserInfoFunc,
|
||||
isAdminUser,
|
||||
})
|
||||
: columns;
|
||||
};
|
||||
|
||||
@@ -19,20 +19,10 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
|
||||
import React from 'react';
|
||||
import { Button, Form } from '@/components/ui';
|
||||
import {
|
||||
Calendar,
|
||||
Cpu,
|
||||
Download,
|
||||
Filter,
|
||||
Hash,
|
||||
Key,
|
||||
Layers,
|
||||
Radio,
|
||||
RotateCcw,
|
||||
Search,
|
||||
Settings2,
|
||||
Users,
|
||||
} from 'lucide-react';
|
||||
import { Search } from 'lucide-react';
|
||||
import '../../common/table/log-filters.css';
|
||||
import FilterSearchButton from '../../common/table/FilterSearchButton';
|
||||
import { useFilterSearch } from '../../../hooks/common/useFilterSearch';
|
||||
|
||||
import { DATE_RANGE_PRESETS } from '../../../constants/console.constants';
|
||||
|
||||
@@ -40,8 +30,6 @@ const LogsFilters = ({
|
||||
formInitValues,
|
||||
setFormApi,
|
||||
refresh,
|
||||
setShowColumnSelector,
|
||||
setShowExportModal,
|
||||
formApi,
|
||||
loading,
|
||||
isAdminUser,
|
||||
@@ -49,18 +37,8 @@ const LogsFilters = ({
|
||||
usageRecordMode = false,
|
||||
t,
|
||||
}) => {
|
||||
const controlClass = 'w-full';
|
||||
const SearchIcon = Search;
|
||||
const ResetIcon = RotateCcw;
|
||||
const ColumnsIcon = Settings2;
|
||||
const ExportIcon = Download;
|
||||
const InputPrefix = ({ icon: Icon }) => (
|
||||
<Icon
|
||||
className='ml-1 mr-1.5 w-3.5 h-3.5 text-gray-400 dark:text-gray-500'
|
||||
strokeWidth={2}
|
||||
/>
|
||||
);
|
||||
|
||||
const { scheduleSearch, submitSearch, cancelPendingSearch } =
|
||||
useFilterSearch(refresh);
|
||||
// 用户 ID 仅允许数字:键入过滤与粘贴清洗(两种布局共用)
|
||||
const digitsOnlyKeyDown = (e) => {
|
||||
if (
|
||||
@@ -104,6 +82,7 @@ const LogsFilters = ({
|
||||
? getFreshInitValues()
|
||||
: formInitValues;
|
||||
formApi.setValues(fresh, { isOverride: true });
|
||||
cancelPendingSearch();
|
||||
setTimeout(() => {
|
||||
refresh();
|
||||
}, 100);
|
||||
@@ -223,119 +202,79 @@ const LogsFilters = ({
|
||||
<Form
|
||||
initValues={formInitValues}
|
||||
getFormApi={(api) => setFormApi(api)}
|
||||
onSubmit={refresh}
|
||||
onSubmit={submitSearch}
|
||||
allowEmpty={true}
|
||||
autoComplete='off'
|
||||
layout='vertical'
|
||||
trigger='change'
|
||||
stopValidateWithError={false}
|
||||
className='usage-logs-filter-form'
|
||||
className='usage-logs-filter-form log-filter-form'
|
||||
onValueChange={scheduleSearch}
|
||||
>
|
||||
<div className='usage-logs-filter-content'>
|
||||
<header className='usage-logs-filter-title'>
|
||||
<span className='usage-logs-filter-title-icon'>
|
||||
<Filter className='w-3.5 h-3.5' />
|
||||
</span>
|
||||
<span className='text-sm font-semibold text-gray-700 dark:text-gray-200'>
|
||||
{t('筛选条件')}
|
||||
</span>
|
||||
</header>
|
||||
|
||||
<div className='grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-3'>
|
||||
<div className='log-filter-content'>
|
||||
<div className='log-filter-grid'>
|
||||
<Form.DatePicker
|
||||
field='dateRange'
|
||||
className={`${controlClass} lg:col-span-2`}
|
||||
label={t('时间范围')}
|
||||
className='log-filter-wide'
|
||||
dropdownClassName='usage-logs-date-panel'
|
||||
type='dateTimeRange'
|
||||
placeholder={[t('开始时间'), t('结束时间')]}
|
||||
showClear
|
||||
pure
|
||||
size='small'
|
||||
prefix={<InputPrefix icon={Calendar} />}
|
||||
presets={datePresets}
|
||||
/>
|
||||
|
||||
<Form.Input
|
||||
field='token_name'
|
||||
className={controlClass}
|
||||
prefix={<InputPrefix icon={Key} />}
|
||||
label={t('密钥名称')}
|
||||
placeholder={t('密钥名称')}
|
||||
showClear
|
||||
pure
|
||||
size='small'
|
||||
/>
|
||||
|
||||
<Form.Input
|
||||
field='model_name'
|
||||
className={controlClass}
|
||||
prefix={<InputPrefix icon={Cpu} />}
|
||||
label={t('模型名称')}
|
||||
placeholder={t('模型名称')}
|
||||
showClear
|
||||
pure
|
||||
size='small'
|
||||
/>
|
||||
|
||||
<Form.Input
|
||||
field='group'
|
||||
className={controlClass}
|
||||
prefix={<InputPrefix icon={Layers} />}
|
||||
label={t('分组')}
|
||||
placeholder={t('分组')}
|
||||
showClear
|
||||
pure
|
||||
size='small'
|
||||
/>
|
||||
|
||||
{isAdminUser && (
|
||||
<>
|
||||
<Form.Input
|
||||
field='channel'
|
||||
className={controlClass}
|
||||
prefix={<InputPrefix icon={Radio} />}
|
||||
label={t('渠道 ID')}
|
||||
placeholder={t('渠道 ID')}
|
||||
showClear
|
||||
pure
|
||||
size='small'
|
||||
/>
|
||||
|
||||
<Form.Input
|
||||
field='username'
|
||||
className={controlClass}
|
||||
prefix={<InputPrefix icon={Users} />}
|
||||
label={t('用户名称')}
|
||||
placeholder={t('用户名称')}
|
||||
showClear
|
||||
pure
|
||||
size='small'
|
||||
/>
|
||||
|
||||
<Form.Input
|
||||
field='user_id'
|
||||
className={controlClass}
|
||||
prefix={<InputPrefix icon={Hash} />}
|
||||
label={t('用户 ID')}
|
||||
placeholder={t('用户 ID')}
|
||||
showClear
|
||||
pure
|
||||
size='small'
|
||||
inputMode='numeric'
|
||||
onKeyDown={digitsOnlyKeyDown}
|
||||
onPaste={digitsOnlyPaste}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className='flex flex-col sm:flex-row justify-between items-start sm:items-center gap-3'>
|
||||
<Form.Select
|
||||
field='logType'
|
||||
label={t('类型')}
|
||||
placeholder={t('日志类型')}
|
||||
className='w-full sm:w-auto min-w-[140px]'
|
||||
showClear
|
||||
pure
|
||||
onChange={() => {
|
||||
setTimeout(() => {
|
||||
refresh();
|
||||
}, 0);
|
||||
}}
|
||||
size='small'
|
||||
>
|
||||
<Form.Select.Option value='0'>{t('全部')}</Form.Select.Option>
|
||||
<Form.Select.Option value='1'>{t('充值')}</Form.Select.Option>
|
||||
@@ -347,45 +286,10 @@ const LogsFilters = ({
|
||||
<Form.Select.Option value='5'>{t('错误')}</Form.Select.Option>
|
||||
)}
|
||||
</Form.Select>
|
||||
|
||||
<div className='flex flex-wrap gap-2 w-full sm:w-auto sm:justify-end'>
|
||||
<Button
|
||||
type='primary'
|
||||
htmlType='submit'
|
||||
loading={loading}
|
||||
size='small'
|
||||
icon={<SearchIcon className='w-3.5 h-3.5' />}
|
||||
>
|
||||
{t('查询')}
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
type='tertiary'
|
||||
onClick={resetFilters}
|
||||
size='small'
|
||||
icon={<ResetIcon className='w-3.5 h-3.5' />}
|
||||
>
|
||||
{t('重置')}
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
type='tertiary'
|
||||
onClick={() => setShowColumnSelector(true)}
|
||||
size='small'
|
||||
icon={<ColumnsIcon className='w-3.5 h-3.5' />}
|
||||
>
|
||||
{t('列设置')}
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
type='tertiary'
|
||||
size='small'
|
||||
icon={<ExportIcon className='w-3.5 h-3.5' />}
|
||||
onClick={() => setShowExportModal(true)}
|
||||
>
|
||||
{t('导出')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div className='log-filter-actions'>
|
||||
<Button onClick={resetFilters}>{t('重置')}</Button>
|
||||
<FilterSearchButton loading={loading} />
|
||||
</div>
|
||||
</div>
|
||||
</Form>
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -19,9 +19,11 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
|
||||
import React, { useState } from 'react';
|
||||
import { Card } from 'antd';
|
||||
import { Download, Settings } from 'lucide-react';
|
||||
import { Button, Pagination, Tooltip } from '@/components/ui';
|
||||
import { Download } from 'lucide-react';
|
||||
import { Button, Pagination } from '@/components/ui';
|
||||
import CardPro from '../../common/ui/CardPro';
|
||||
import { TableTitle } from '../../common/table/TableToolbar';
|
||||
import { ColumnSettingsButton } from '../../common/table/ColumnSettings';
|
||||
import LogsTable from './UsageLogsTable';
|
||||
import LogsFilters from './UsageLogsFilters';
|
||||
import ColumnSelectorModal from './modals/ColumnSelectorModal';
|
||||
@@ -62,9 +64,9 @@ const LogsPage = ({ usageRecordMode = false }) => {
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
<Card className='usage-record-card usage-record-table-card'>
|
||||
<Card className='usage-record-card usage-record-table-card usage-record-consume-card'>
|
||||
<div className='usage-record-table-head'>
|
||||
<h3>{t('调用明细')}</h3>
|
||||
<TableTitle>{t('调用明细')}</TableTitle>
|
||||
<div className='usage-record-table-actions'>
|
||||
<Button
|
||||
icon={<Download size={14} />}
|
||||
@@ -72,14 +74,10 @@ const LogsPage = ({ usageRecordMode = false }) => {
|
||||
>
|
||||
{t('导出')}
|
||||
</Button>
|
||||
<Tooltip content={t('列设置')}>
|
||||
<Button
|
||||
theme='borderless'
|
||||
aria-label={t('列设置')}
|
||||
icon={<Settings size={16} />}
|
||||
onClick={() => logsData.setShowColumnSelector(true)}
|
||||
/>
|
||||
</Tooltip>
|
||||
<ColumnSettingsButton
|
||||
open={logsData.showColumnSelector}
|
||||
onClick={() => logsData.setShowColumnSelector(true)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<LogsTable {...logsData} compactMode={false} usageRecordMode />
|
||||
@@ -115,11 +113,26 @@ const LogsPage = ({ usageRecordMode = false }) => {
|
||||
|
||||
{/* Main Content */}
|
||||
<CardPro
|
||||
tableTitle={logsData.t('使用明细')}
|
||||
type='type2'
|
||||
className='usage-logs-page usage-logs-panel'
|
||||
searchArea={
|
||||
<LogsFilters {...logsData} usageRecordMode={usageRecordMode} />
|
||||
}
|
||||
tableActions={
|
||||
<>
|
||||
<Button
|
||||
icon={<Download size={14} />}
|
||||
onClick={() => logsData.setShowExportModal(true)}
|
||||
>
|
||||
{logsData.t('导出')}
|
||||
</Button>
|
||||
<ColumnSettingsButton
|
||||
open={logsData.showColumnSelector}
|
||||
onClick={() => logsData.setShowColumnSelector(true)}
|
||||
/>
|
||||
</>
|
||||
}
|
||||
paginationArea={createCardProPagination({
|
||||
currentPage: logsData.activePage,
|
||||
pageSize: logsData.pageSize,
|
||||
@@ -131,12 +144,10 @@ const LogsPage = ({ usageRecordMode = false }) => {
|
||||
})}
|
||||
t={logsData.t}
|
||||
>
|
||||
<div className='app-card usage-logs-table-shell usage-logs-glass-table mt-4 overflow-hidden'>
|
||||
<LogsTable
|
||||
{...logsData}
|
||||
compactMode={usageRecordMode ? false : logsData.compactMode}
|
||||
/>
|
||||
</div>
|
||||
<LogsTable
|
||||
{...logsData}
|
||||
compactMode={usageRecordMode ? false : logsData.compactMode}
|
||||
/>
|
||||
</CardPro>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -18,16 +18,15 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { Modal, Button, Checkbox } from '@/components/ui';
|
||||
import { ColumnVisibilitySettings } from '../../../common/table/ColumnSettings';
|
||||
import { getLogsColumns } from '../UsageLogsColumnDefs';
|
||||
|
||||
const ColumnSelectorModal = ({
|
||||
showColumnSelector,
|
||||
setShowColumnSelector,
|
||||
visibleColumns,
|
||||
handleColumnVisibilityChange,
|
||||
handleSelectAll,
|
||||
initDefaultColumns,
|
||||
setVisibleColumns,
|
||||
getDefaultColumnVisibility,
|
||||
COLUMN_KEYS,
|
||||
isAdminUser,
|
||||
isRootUser,
|
||||
@@ -47,76 +46,25 @@ const ColumnSelectorModal = ({
|
||||
usageRecordMode,
|
||||
});
|
||||
|
||||
// 计算"全选"状态时应忽略的 key:当前角色下不可见的管理员专属列
|
||||
// 否则非管理员下 CHANNEL/USERNAME/RETRY 永远为 false,全选框永远半选
|
||||
const isHiddenForRole = (key) =>
|
||||
!isAdminUser &&
|
||||
(key === COLUMN_KEYS.CHANNEL ||
|
||||
key === COLUMN_KEYS.USERNAME ||
|
||||
key === COLUMN_KEYS.RETRY);
|
||||
const effectiveValues = Object.entries(visibleColumns)
|
||||
.filter(([key]) => !isHiddenForRole(key))
|
||||
.map(([, v]) => v);
|
||||
const allChecked =
|
||||
effectiveValues.length > 0 && effectiveValues.every((v) => v === true);
|
||||
const someChecked = effectiveValues.some((v) => v === true);
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title={t('列设置')}
|
||||
visible={showColumnSelector}
|
||||
onCancel={() => setShowColumnSelector(false)}
|
||||
footer={
|
||||
<div className='flex justify-end gap-2'>
|
||||
<Button onClick={() => initDefaultColumns()}>{t('重置')}</Button>
|
||||
<Button onClick={() => setShowColumnSelector(false)}>
|
||||
{t('取消')}
|
||||
</Button>
|
||||
<Button onClick={() => setShowColumnSelector(false)}>
|
||||
{t('确定')}
|
||||
</Button>
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<div style={{ marginBottom: 20 }}>
|
||||
<Checkbox
|
||||
checked={allChecked}
|
||||
indeterminate={someChecked && !allChecked}
|
||||
onChange={(e) => handleSelectAll(e.target.checked)}
|
||||
>
|
||||
{t('全选')}
|
||||
</Checkbox>
|
||||
</div>
|
||||
<div
|
||||
className='flex flex-wrap max-h-96 overflow-y-auto rounded-lg p-4'
|
||||
style={{ border: '1px solid var(--ui-color-border)' }}
|
||||
>
|
||||
{allColumns.map((column) => {
|
||||
// Skip admin-only columns for non-admin users
|
||||
if (
|
||||
<ColumnVisibilitySettings
|
||||
showColumnSelector={showColumnSelector}
|
||||
setShowColumnSelector={setShowColumnSelector}
|
||||
columns={allColumns.filter(
|
||||
(column) =>
|
||||
!(
|
||||
!isAdminUser &&
|
||||
(column.key === COLUMN_KEYS.CHANNEL ||
|
||||
column.key === COLUMN_KEYS.USERNAME ||
|
||||
column.key === COLUMN_KEYS.RETRY)
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<div key={column.key} className='w-1/2 mb-4 pr-2'>
|
||||
<Checkbox
|
||||
checked={!!visibleColumns[column.key]}
|
||||
onChange={(e) =>
|
||||
handleColumnVisibilityChange(column.key, e.target.checked)
|
||||
}
|
||||
>
|
||||
{column.title}
|
||||
</Checkbox>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</Modal>
|
||||
[
|
||||
COLUMN_KEYS.CHANNEL,
|
||||
COLUMN_KEYS.USERNAME,
|
||||
COLUMN_KEYS.RETRY,
|
||||
].includes(column.key)
|
||||
),
|
||||
)}
|
||||
visibleColumns={visibleColumns}
|
||||
setVisibleColumns={setVisibleColumns}
|
||||
getDefaultColumnVisibility={getDefaultColumnVisibility}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user