feat: 参考原型图 ui优化提交 个人端-用户中心 相关的页面

This commit is contained in:
zhanjunhao
2026-11-04 19:59:06 +08:00
parent 1fd4e084b6
commit 15192c433b
576 changed files with 18075 additions and 18912 deletions
@@ -18,7 +18,8 @@ For commercial licensing, please contact support@quantumnous.com
*/
import React, { useMemo, useState } from 'react';
import { Button, Empty, Modal, Typography } from '@douyinfe/semi-ui';
import { Empty as AntEmpty } from 'antd';
import { Button, Empty, Modal, Typography } from '@/components/ui';
import {
Coins,
Cpu,
@@ -51,7 +52,7 @@ const formatRatio = (value) => {
return `${Number.isInteger(num) ? num : num.toFixed(3).replace(/0+$/, '').replace(/\.$/, '')}x`;
};
const MetricCard = ({ icon: Icon, label, value, tone = 'brand' }) => {
const MetricCard = ({ icon: Icon, label, value, tone = 'brand', plain }) => {
const toneClass = {
brand:
'bg-brand/10 text-brand-deep border-brand/20 dark:bg-brand/15 dark:text-brand-from',
@@ -63,7 +64,13 @@ const MetricCard = ({ icon: Icon, label, value, tone = 'brand' }) => {
}[tone];
return (
<div className='rounded-2xl border border-white/55 bg-white/[0.45] p-3 backdrop-blur-xl dark:border-white/10 dark:bg-white/[0.045]'>
<div
className={
plain
? 'usage-billing-tile'
: 'rounded-2xl border border-white/55 bg-white/[0.45] p-3 backdrop-blur-xl dark:border-white/10 dark:bg-white/[0.045]'
}
>
<div className='mb-2 flex items-center gap-2'>
<span
className={`inline-flex h-7 w-7 items-center justify-center rounded-xl border ${toneClass}`}
@@ -81,11 +88,17 @@ const MetricCard = ({ icon: Icon, label, value, tone = 'brand' }) => {
);
};
const DetailPill = ({ label, value }) => {
const DetailPill = ({ label, value, plain }) => {
if (value === undefined || value === null || value === '' || value === '-')
return null;
return (
<span className='inline-flex items-center gap-1 rounded-full border border-white/55 bg-white/[0.45] px-2.5 py-1 text-xs text-gray-600 backdrop-blur dark:border-white/10 dark:bg-white/[0.055] dark:text-gray-300'>
<span
className={
plain
? 'usage-billing-pill'
: 'inline-flex items-center gap-1 rounded-full border border-white/55 bg-white/[0.45] px-2.5 py-1 text-xs text-gray-600 backdrop-blur dark:border-white/10 dark:bg-white/[0.055] dark:text-gray-300'
}
>
<span className='text-gray-400 dark:text-gray-500'>{label}</span>
<strong className='font-semibold text-gray-800 dark:text-gray-100'>
{value}
@@ -94,7 +107,14 @@ const DetailPill = ({ label, value }) => {
);
};
const UsageBillingDetail = ({ record, expandItems, isAdminUser, t }) => {
const UsageBillingDetail = ({
record,
expandItems,
isAdminUser,
usageRecordMode = false,
t,
}) => {
const plain = usageRecordMode;
const other = getLogOther(record.other) || {};
const inputTokens = Number(record.prompt_tokens || 0);
const outputTokens = Number(record.completion_tokens || 0);
@@ -252,6 +272,7 @@ const UsageBillingDetail = ({ record, expandItems, isAdminUser, t }) => {
icon={Sparkles}
label={item.key}
value={item.value}
plain={plain}
/>
))}
</div>
@@ -278,27 +299,34 @@ const UsageBillingDetail = ({ record, expandItems, isAdminUser, t }) => {
<div className='grid gap-3 sm:grid-cols-2 xl:grid-cols-4'>
{metrics.map((item) => (
<MetricCard key={item.label} {...item} />
<MetricCard key={item.label} {...item} plain={plain} />
))}
</div>
<div className='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={
plain
? 'usage-billing-factors'
: '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'>
<Layers3 size={13} />
{t('成本因子')}
</div>
<div className='flex flex-wrap gap-2'>
{details.map((item) => (
<DetailPill key={item.label} {...item} />
<DetailPill key={item.label} {...item} plain={plain} />
))}
{mappedModel && (
<DetailPill
label={t('实际模型')}
value={other.upstream_model_name}
plain={plain}
/>
)}
{billingMode && (
<DetailPill label={t('计费源')} value={billingMode} />
<DetailPill label={t('计费源')} value={billingMode} plain={plain} />
)}
</div>
</div>
@@ -325,6 +353,7 @@ const LogsTable = (logsData) => {
isRootUser,
t,
COLUMN_KEYS,
usageRecordMode = false,
} = logsData;
const [detailRecord, setDetailRecord] = useState(null);
@@ -337,8 +366,17 @@ const LogsTable = (logsData) => {
showUserInfoFunc,
isAdminUser,
isRootUser,
usageRecordMode,
});
}, [t, COLUMN_KEYS, copyText, showUserInfoFunc, isAdminUser, isRootUser]);
}, [
t,
COLUMN_KEYS,
copyText,
showUserInfoFunc,
isAdminUser,
isRootUser,
usageRecordMode,
]);
// Filter columns based on visibility settings
const getVisibleColumns = () => {
@@ -375,7 +413,11 @@ const LogsTable = (logsData) => {
e?.stopPropagation?.();
if (canView) setDetailRecord(record);
}}
className='usage-record-action-button usage-record-action-button-soft !rounded-full'
className={
usageRecordMode
? undefined
: 'usage-record-action-button usage-record-action-button-soft !rounded-full'
}
>
{t('查看')}
</Button>
@@ -389,6 +431,7 @@ const LogsTable = (logsData) => {
expandData,
hasExpandableRows,
t,
usageRecordMode,
]);
return (
@@ -399,29 +442,49 @@ const LogsTable = (logsData) => {
rowKey='key'
loading={loading}
scroll={compactMode ? undefined : { x: 'max-content' }}
className='rounded-xl overflow-hidden usage-logs-table'
className={
usageRecordMode
? 'usage-logs-table usage-record-table'
: 'rounded-xl overflow-hidden usage-logs-table'
}
size='middle'
empty={
<div className='py-12'>
<Empty
image={
<IllustrationNoResult style={{ width: 180, height: 180 }} />
}
darkModeImage={
<IllustrationNoResultDark style={{ width: 180, height: 180 }} />
}
usageRecordMode ? (
<AntEmpty
image={AntEmpty.PRESENTED_IMAGE_SIMPLE}
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'>
<>
<div>{t('搜索无结果')}</div>
<div className='usage-record-empty-hint'>
{t('尝试调整筛选条件')}
</span>
</div>
</div>
</>
}
/>
</div>
) : (
<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,
@@ -443,12 +506,16 @@ const LogsTable = (logsData) => {
centered
width={860}
title={
<div className='flex items-center gap-2'>
<span className='inline-flex h-9 w-9 items-center justify-center rounded-2xl bg-brand/10 text-brand-deep dark:bg-brand/15 dark:text-brand-from'>
<ReceiptText size={18} />
</span>
<span>{t('计费详情')}</span>
</div>
usageRecordMode ? (
t('计费详情')
) : (
<div className='flex items-center gap-2'>
<span className='inline-flex h-9 w-9 items-center justify-center rounded-2xl bg-brand/10 text-brand-deep dark:bg-brand/15 dark:text-brand-from'>
<ReceiptText size={18} />
</span>
<span>{t('计费详情')}</span>
</div>
)
}
bodyStyle={{ padding: 20 }}
>
@@ -457,6 +524,7 @@ const LogsTable = (logsData) => {
record={detailRecord}
expandItems={expandData[detailRecord.key] || []}
isAdminUser={isAdminUser}
usageRecordMode={usageRecordMode}
t={t}
/>
)}