feat: 参考原型图 ui优化提交 个人端-用户中心 相关的页面
This commit is contained in:
@@ -18,55 +18,27 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React, { useState, useEffect, useMemo } from 'react';
|
||||
import { Empty as AntEmpty, Tag as AntTag } from 'antd';
|
||||
import {
|
||||
Card,
|
||||
Typography,
|
||||
Input,
|
||||
Table,
|
||||
Empty,
|
||||
Button,
|
||||
Modal,
|
||||
Toast,
|
||||
Pagination,
|
||||
} from '@douyinfe/semi-ui';
|
||||
import { IconSearch } from '@douyinfe/semi-icons';
|
||||
import {
|
||||
IllustrationNoResult,
|
||||
IllustrationNoResultDark,
|
||||
} from '../../components/common/illustrations';
|
||||
import {
|
||||
Receipt,
|
||||
Sparkles,
|
||||
Clock,
|
||||
CheckCircle,
|
||||
AlertCircle,
|
||||
XCircle,
|
||||
} from 'lucide-react';
|
||||
} from '@/components/ui';
|
||||
import { Search } from 'lucide-react';
|
||||
import { API, timestamp2string } from '../../helpers';
|
||||
import { isAdmin } from '../../helpers/utils';
|
||||
|
||||
const { Text, Title } = Typography;
|
||||
const { Text } = Typography;
|
||||
|
||||
// 状态映射
|
||||
const STATUS_CONFIG = {
|
||||
success: {
|
||||
type: 'success',
|
||||
key: '成功',
|
||||
icon: CheckCircle,
|
||||
color: 'text-emerald-500',
|
||||
},
|
||||
pending: {
|
||||
type: 'warning',
|
||||
key: '待支付',
|
||||
icon: Clock,
|
||||
color: 'text-amber-500',
|
||||
},
|
||||
expired: {
|
||||
type: 'danger',
|
||||
key: '已过期',
|
||||
icon: XCircle,
|
||||
color: 'text-red-500',
|
||||
},
|
||||
success: { color: 'success', key: '成功' },
|
||||
pending: { color: 'warning', key: '待支付' },
|
||||
expired: { color: undefined, key: '已过期' },
|
||||
};
|
||||
|
||||
const HistoryPanel = ({ t, refreshTrigger }) => {
|
||||
@@ -134,20 +106,16 @@ const HistoryPanel = ({ t, refreshTrigger }) => {
|
||||
});
|
||||
};
|
||||
|
||||
// 渲染状态徽章
|
||||
// 渲染状态标签
|
||||
const renderStatusBadge = (status) => {
|
||||
const config = STATUS_CONFIG[status] || {
|
||||
type: 'primary',
|
||||
color: 'processing',
|
||||
key: status,
|
||||
icon: AlertCircle,
|
||||
color: 'text-gray-500',
|
||||
};
|
||||
const IconComponent = config.icon;
|
||||
return (
|
||||
<span className={`flex items-center gap-1.5 ${config.color}`}>
|
||||
<IconComponent size={14} />
|
||||
<span className='text-xs font-medium'>{t(config.key)}</span>
|
||||
</span>
|
||||
<AntTag bordered={false} color={config.color}>
|
||||
{t(config.key)}
|
||||
</AntTag>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -162,24 +130,26 @@ const HistoryPanel = ({ t, refreshTrigger }) => {
|
||||
render: (text) => (
|
||||
<Text
|
||||
copyable={{ content: text }}
|
||||
size='small'
|
||||
className='font-mono'
|
||||
className='rc-history-mono'
|
||||
ellipsis={{ showTooltip: true }}
|
||||
style={{ maxWidth: 200 }}
|
||||
>
|
||||
{text || '-'}
|
||||
</Text>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t('支付'),
|
||||
title: t('支付金额'),
|
||||
dataIndex: 'money',
|
||||
key: 'money',
|
||||
width: 80,
|
||||
width: 160,
|
||||
render: (money) => (
|
||||
<Text type='danger' size='small'>
|
||||
¥{money?.toFixed(2)}
|
||||
</Text>
|
||||
<span className='rc-history-money'>
|
||||
¥
|
||||
{Number(money || 0).toLocaleString('en-US', {
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
})}
|
||||
</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
@@ -194,11 +164,7 @@ const HistoryPanel = ({ t, refreshTrigger }) => {
|
||||
dataIndex: 'create_time',
|
||||
key: 'create_time',
|
||||
width: 100,
|
||||
render: (time) => (
|
||||
<Text size='small' type='tertiary'>
|
||||
{timestamp2string(time).slice(5, 16)}
|
||||
</Text>
|
||||
),
|
||||
render: (time) => timestamp2string(time).slice(0, 16),
|
||||
},
|
||||
];
|
||||
|
||||
@@ -227,130 +193,70 @@ const HistoryPanel = ({ t, refreshTrigger }) => {
|
||||
}, [t, userIsAdmin]);
|
||||
|
||||
return (
|
||||
<div className='relative'>
|
||||
{/* 外层发光效果 - 与 RechargePanel 对齐 */}
|
||||
<div className='absolute -inset-0.5 bg-gradient-to-br from-emerald-400/20 via-teal-400/20 to-cyan-400/20 rounded-[20px] blur-md opacity-60' />
|
||||
<div className='rc-history'>
|
||||
<div className='rc-history-search'>
|
||||
<Input
|
||||
placeholder={t('请输入订单号')}
|
||||
value={keyword}
|
||||
onChange={(value) => {
|
||||
setKeyword(value);
|
||||
setPage(1);
|
||||
}}
|
||||
showClear
|
||||
/>
|
||||
{/* 重置等同清空订单号;搜索按当前订单号重新加载当前页 */}
|
||||
<Button
|
||||
onClick={() => {
|
||||
setKeyword('');
|
||||
setPage(1);
|
||||
}}
|
||||
>
|
||||
{t('重置')}
|
||||
</Button>
|
||||
<Button
|
||||
type='primary'
|
||||
icon={<Search size={14} />}
|
||||
onClick={() => loadTopups(page, pageSize)}
|
||||
>
|
||||
{t('搜索')}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<Card
|
||||
className='relative !rounded-2xl shadow-xl border border-white/60 dark:border-neutral-800/60 bg-white/70 dark:bg-neutral-900/70 backdrop-blur-xl overflow-hidden'
|
||||
style={{
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
maxHeight: 'calc(100vh - 160px)',
|
||||
}}
|
||||
bodyStyle={{
|
||||
flex: 1,
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
minHeight: 0,
|
||||
overflow: 'hidden',
|
||||
}}
|
||||
>
|
||||
{/* 顶部装饰线 */}
|
||||
<div className='absolute top-0 left-0 right-0 h-1 bg-gradient-to-r from-emerald-500 via-teal-500 to-cyan-500' />
|
||||
<Table
|
||||
columns={columns}
|
||||
dataSource={topups}
|
||||
loading={loading}
|
||||
rowKey='id'
|
||||
scroll={{ x: 'max-content' }}
|
||||
size='middle'
|
||||
pagination={false}
|
||||
className='rc-history-table'
|
||||
empty={
|
||||
<AntEmpty
|
||||
image={AntEmpty.PRESENTED_IMAGE_SIMPLE}
|
||||
description={t('暂无充值记录')}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
|
||||
{/* 背景装饰 */}
|
||||
<div className='absolute top-0 right-0 w-64 h-64 bg-gradient-to-br from-emerald-400/10 to-teal-400/10 rounded-full blur-3xl -mr-32 -mt-32 pointer-events-none' />
|
||||
<div className='absolute bottom-0 left-0 w-48 h-48 bg-gradient-to-br from-cyan-400/10 to-blue-400/10 rounded-full blur-3xl -ml-24 -mb-24 pointer-events-none' />
|
||||
|
||||
{/* 这层必须是 flex 列并参与父级伸缩:Card 的 bodyStyle 已经是
|
||||
flex-column + minHeight:0 + overflow:hidden,但中间隔着这个普通块级 div,
|
||||
下面表格区的 flex-1/min-h-0 与分页的 flex-shrink-0 就都不是 flex 项了——
|
||||
每页选 20/50 条时表格会顶破 maxHeight 被裁掉,分页控件跟着滚出可视区。 */}
|
||||
<div className='relative flex-1 min-h-0 flex flex-col'>
|
||||
{/* 头部 */}
|
||||
<div className='flex items-center justify-between mb-3 flex-shrink-0'>
|
||||
<div className='flex items-center gap-3'>
|
||||
<div className='relative'>
|
||||
<div className='absolute -inset-1 bg-gradient-to-br from-emerald-500/40 to-teal-500/40 rounded-xl blur-md' />
|
||||
<div className='relative w-10 h-10 rounded-xl bg-gradient-to-br from-emerald-500 to-teal-600 flex items-center justify-center shadow-lg shadow-emerald-500/30'>
|
||||
<Receipt size={20} className='text-white' />
|
||||
</div>
|
||||
<Sparkles
|
||||
size={12}
|
||||
className='absolute -top-1 -right-1 text-amber-400'
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<Title
|
||||
heading={5}
|
||||
className='!mb-0 bg-clip-text text-transparent bg-gradient-to-r from-emerald-600 to-teal-600 dark:from-emerald-400 dark:to-teal-400'
|
||||
>
|
||||
{t('充值记录')}
|
||||
</Title>
|
||||
<Text type='tertiary' size='small'>
|
||||
{t('查看历史充值订单')}
|
||||
</Text>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 搜索框 */}
|
||||
<div className='mb-3 flex-shrink-0'>
|
||||
<div className='relative group'>
|
||||
<div className='absolute -inset-0.5 bg-gradient-to-r from-emerald-400/20 to-teal-400/20 rounded-xl blur-sm opacity-0 group-hover:opacity-100 transition-opacity' />
|
||||
<Input
|
||||
prefix={<IconSearch className='text-emerald-500' />}
|
||||
placeholder={t('搜索订单号')}
|
||||
value={keyword}
|
||||
onChange={(value) => {
|
||||
setKeyword(value);
|
||||
setPage(1);
|
||||
}}
|
||||
showClear
|
||||
className='!rounded-xl relative'
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 表格区域 - 可滚动 */}
|
||||
<div className='flex-1 overflow-auto min-h-0 image-list-scroll rounded-xl bg-white/40 dark:bg-neutral-800/30 backdrop-blur-sm border border-white/60 dark:border-neutral-700/40'>
|
||||
<Table
|
||||
columns={columns}
|
||||
dataSource={topups}
|
||||
loading={loading}
|
||||
rowKey='id'
|
||||
size='small'
|
||||
pagination={false}
|
||||
className='history-table'
|
||||
empty={
|
||||
<Empty
|
||||
image={
|
||||
<IllustrationNoResult style={{ width: 100, height: 100 }} />
|
||||
}
|
||||
darkModeImage={
|
||||
<IllustrationNoResultDark
|
||||
style={{ width: 100, height: 100 }}
|
||||
/>
|
||||
}
|
||||
description={t('暂无充值记录')}
|
||||
style={{ padding: 20 }}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* 分页器 - 固定在底部 */}
|
||||
{total > 0 && (
|
||||
<div className='flex-shrink-0 pt-3 border-t border-gray-100 dark:border-gray-700 mt-3'>
|
||||
<Pagination
|
||||
total={total}
|
||||
currentPage={page}
|
||||
pageSize={pageSize}
|
||||
showSizeChanger
|
||||
pageSizeOpts={[10, 20, 50]}
|
||||
onPageChange={(p) => setPage(p)}
|
||||
onPageSizeChange={(size) => {
|
||||
setPageSize(size);
|
||||
setPage(1);
|
||||
}}
|
||||
showTotal
|
||||
style={{ justifyContent: 'flex-end' }}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
{total > 0 && (
|
||||
<div className='rc-history-pagination'>
|
||||
<Pagination
|
||||
total={total}
|
||||
currentPage={page}
|
||||
pageSize={pageSize}
|
||||
showSizeChanger
|
||||
pageSizeOpts={[10, 20, 50]}
|
||||
onPageChange={(p) => setPage(p)}
|
||||
onPageSizeChange={(size) => {
|
||||
setPageSize(size);
|
||||
setPage(1);
|
||||
}}
|
||||
size='small'
|
||||
showTotal={(count) => t('共 {{total}} 条', { total: count })}
|
||||
/>
|
||||
</div>
|
||||
</Card>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user