fix(ui): 修复登录与并发请求并统一表格、主题和页面展示
验证:868 项单测、ESLint、Prettier、UI 依赖审计和差异检查通过。
This commit is contained in:
+226
-224
@@ -16,27 +16,28 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
import { formatUserReference } from '../../helpers/safeDisplay';
|
||||
|
||||
import { Trans } from 'react-i18next';
|
||||
import {
|
||||
Ban as ActionBan,
|
||||
ShieldCheck as ActionShieldCheck,
|
||||
CalendarClock as ActionCalendarClock,
|
||||
Pencil as ActionPencil,
|
||||
Plus as ActionPlus,
|
||||
CreditCard as ActionCreditCard,
|
||||
} from '@/components/common/icons/ActionIcons';
|
||||
import {
|
||||
ConsoleCard,
|
||||
ConsoleSearchBar,
|
||||
ConsoleSearchActions,
|
||||
ConsoleFilterField,
|
||||
ConsoleFilterGrid,
|
||||
ConsoleListTable,
|
||||
} from '../../components/console/ConsolePrimitives';
|
||||
import { ConsolePageActions } from '../../components/console/ConsolePageContainer';
|
||||
import ConsoleCollection from '../../components/console/ConsoleCollection';
|
||||
import { TableRowActions } from '../../components/common/table/TableToolbar';
|
||||
import { useIsMobile } from '../../hooks/common/useIsMobile';
|
||||
import { createCardProPagination } from '../../helpers/utils';
|
||||
import { Button as AntButton } from 'antd';
|
||||
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import { useEffectEvent } from '../../hooks/common/useEffectEvent';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { CreditCard, Search, Sparkles, History } from 'lucide-react';
|
||||
import { CreditCard, Search, History } from 'lucide-react';
|
||||
import {
|
||||
Button,
|
||||
Checkbox,
|
||||
@@ -45,10 +46,8 @@ import {
|
||||
Input,
|
||||
InputNumber,
|
||||
Modal,
|
||||
Popconfirm,
|
||||
Select,
|
||||
Space,
|
||||
Table,
|
||||
Tag,
|
||||
TextArea,
|
||||
Timeline,
|
||||
@@ -125,6 +124,7 @@ const RemainingTag = ({ endDate, status, t }) => {
|
||||
const Subscription = () => {
|
||||
const { t } = useTranslation();
|
||||
const navigate = useNavigate();
|
||||
const isMobile = useIsMobile();
|
||||
const admin = isAdmin();
|
||||
|
||||
// 列表数据
|
||||
@@ -355,7 +355,7 @@ const Subscription = () => {
|
||||
return (
|
||||
<div className='flex flex-col'>
|
||||
<span className='font-medium'>
|
||||
{display || username || `User#${r.user_id}`}
|
||||
{formatUserReference(display || username, r.user_id)}
|
||||
</span>
|
||||
<span className='text-xs text-gray-400'>
|
||||
#{r.user_id}
|
||||
@@ -423,234 +423,230 @@ const Subscription = () => {
|
||||
},
|
||||
{
|
||||
title: t('操作'),
|
||||
width: 300,
|
||||
key: 'actions',
|
||||
width: 140,
|
||||
fixed: 'right',
|
||||
render: (_, r) => (
|
||||
<Space spacing={4} wrap>
|
||||
<Button size='small' theme='borderless' onClick={() => openDetail(r)}>
|
||||
<TableRowActions
|
||||
items={[
|
||||
admin && {
|
||||
key: 'edit',
|
||||
label: t('编辑'),
|
||||
onClick: () => openEdit(r),
|
||||
},
|
||||
admin &&
|
||||
r.status !== 'canceled' &&
|
||||
r.status !== 'banned' && {
|
||||
key: 'extend',
|
||||
label: t('延长'),
|
||||
onClick: () => openExtend(r),
|
||||
},
|
||||
admin &&
|
||||
r.status === 'active' && {
|
||||
key: 'grant',
|
||||
label: t('补发'),
|
||||
onClick: () =>
|
||||
Modal.confirm({
|
||||
title: t('确认手动补发今日额度?'),
|
||||
onOk: () => doGrant(r),
|
||||
}),
|
||||
},
|
||||
admin &&
|
||||
r.status === 'banned' && {
|
||||
key: 'unban',
|
||||
label: t('解封'),
|
||||
onClick: () => openUnban(r),
|
||||
},
|
||||
admin &&
|
||||
r.status !== 'banned' && {
|
||||
key: 'ban',
|
||||
label: t('封禁'),
|
||||
danger: true,
|
||||
onClick: () => openBan(r),
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Button type='link' size='small' onClick={() => openDetail(r)}>
|
||||
{t('详情')}
|
||||
</Button>
|
||||
{admin && r.status !== 'banned' && (
|
||||
<Button
|
||||
size='small'
|
||||
theme='borderless'
|
||||
type='danger'
|
||||
icon={<ActionBan size={12} />}
|
||||
onClick={() => openBan(r)}
|
||||
>
|
||||
{t('封禁')}
|
||||
</Button>
|
||||
)}
|
||||
{admin && r.status === 'banned' && (
|
||||
<Button
|
||||
size='small'
|
||||
theme='borderless'
|
||||
type='primary'
|
||||
icon={<ActionShieldCheck size={12} />}
|
||||
onClick={() => openUnban(r)}
|
||||
>
|
||||
{t('解封')}
|
||||
</Button>
|
||||
)}
|
||||
{admin && r.status !== 'canceled' && r.status !== 'banned' && (
|
||||
<Button
|
||||
size='small'
|
||||
theme='borderless'
|
||||
icon={<ActionCalendarClock size={12} />}
|
||||
onClick={() => openExtend(r)}
|
||||
>
|
||||
{t('延长')}
|
||||
</Button>
|
||||
)}
|
||||
{admin && (
|
||||
<Button
|
||||
size='small'
|
||||
theme='borderless'
|
||||
icon={<ActionPencil size={12} />}
|
||||
onClick={() => openEdit(r)}
|
||||
>
|
||||
{t('编辑')}
|
||||
</Button>
|
||||
)}
|
||||
{admin && r.status === 'active' && (
|
||||
<Popconfirm
|
||||
title={t('确认手动补发今日额度?')}
|
||||
onConfirm={() => doGrant(r)}
|
||||
>
|
||||
<Button
|
||||
size='small'
|
||||
theme='borderless'
|
||||
icon={<Sparkles size={12} />}
|
||||
>
|
||||
{t('补发')}
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
)}
|
||||
</Space>
|
||||
</TableRowActions>
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<div className='console-content'>
|
||||
{/* 筛选区 */}
|
||||
<ConsoleSearchBar formProps={{ layout: 'inline' }}>
|
||||
<div className='console-search-fields'>
|
||||
<Input
|
||||
prefix={<Search size={14} />}
|
||||
placeholder={t('搜索用户名/昵称/订单号')}
|
||||
value={keyword}
|
||||
onChange={setKeyword}
|
||||
onEnterPress={handleSearch}
|
||||
style={{ width: 240 }}
|
||||
/>
|
||||
<InputNumber
|
||||
placeholder={t('用户ID')}
|
||||
value={userId}
|
||||
onChange={setUserId}
|
||||
min={0}
|
||||
style={{ width: 110 }}
|
||||
hideButtons
|
||||
/>
|
||||
<Select
|
||||
placeholder={t('套餐类型')}
|
||||
value={planTypes}
|
||||
onChange={(v) => {
|
||||
setPage(1);
|
||||
setPlanTypes(v || []);
|
||||
}}
|
||||
multiple
|
||||
maxTagCount={2}
|
||||
style={{ width: 160 }}
|
||||
optionList={[
|
||||
{ label: t('周卡'), value: 'weekly' },
|
||||
{ label: t('月卡'), value: 'monthly' },
|
||||
{ label: t('季卡'), value: 'quarterly' },
|
||||
]}
|
||||
/>
|
||||
<Select
|
||||
placeholder={t('档位')}
|
||||
value={tiers}
|
||||
onChange={(v) => {
|
||||
setPage(1);
|
||||
setTiers(v || []);
|
||||
}}
|
||||
multiple
|
||||
maxTagCount={2}
|
||||
style={{ width: 140 }}
|
||||
optionList={[
|
||||
{ label: 'Lite', value: 'lite' },
|
||||
{ label: 'Pro', value: 'pro' },
|
||||
]}
|
||||
/>
|
||||
<Select
|
||||
placeholder={t('状态')}
|
||||
value={statuses}
|
||||
onChange={(v) => {
|
||||
setPage(1);
|
||||
setStatuses(v || []);
|
||||
}}
|
||||
multiple
|
||||
maxTagCount={2}
|
||||
style={{ width: 180 }}
|
||||
optionList={[
|
||||
{ label: t('active'), value: 'active' },
|
||||
{ label: t('expired'), value: 'expired' },
|
||||
{ label: t('canceled'), value: 'canceled' },
|
||||
{ label: t('banned'), value: 'banned' },
|
||||
]}
|
||||
/>
|
||||
<DatePicker
|
||||
type='dateRange'
|
||||
value={endDateRange}
|
||||
onChange={(d) => {
|
||||
setPage(1);
|
||||
setEndDateRange(d || null);
|
||||
}}
|
||||
placeholder={[t('到期开始'), t('到期结束')]}
|
||||
style={{ width: 280 }}
|
||||
density='compact'
|
||||
/>
|
||||
<ConsoleSearchActions
|
||||
<ConsoleCollection
|
||||
searchArea={
|
||||
<ConsoleFilterGrid
|
||||
onReset={handleReset}
|
||||
onSearch={handleSearch}
|
||||
loading={loading}
|
||||
/>
|
||||
{admin && (
|
||||
<ConsolePageActions>
|
||||
<Button
|
||||
theme='solid'
|
||||
type='primary'
|
||||
icon={<ActionPlus size={14} />}
|
||||
onClick={openCreate}
|
||||
>
|
||||
{t('新建会员')}
|
||||
</Button>
|
||||
<Button
|
||||
type='tertiary'
|
||||
icon={<ActionCreditCard size={14} />}
|
||||
onClick={() => navigate('/console/setting?tab=membership')}
|
||||
>
|
||||
{t('会员管理')}
|
||||
</Button>
|
||||
</ConsolePageActions>
|
||||
)}
|
||||
</div>
|
||||
</ConsoleSearchBar>
|
||||
|
||||
{/* 快捷筛选 */}
|
||||
<div className='flex flex-wrap items-center gap-2 mb-4'>
|
||||
<span className='text-xs text-gray-500'>{t('快捷筛选')}:</span>
|
||||
<Tag
|
||||
color={quickFilter === 'expiring3' ? 'red' : 'white'}
|
||||
type={quickFilter === 'expiring3' ? 'solid' : 'ghost'}
|
||||
className='cursor-pointer'
|
||||
onClick={() => applyQuickFilter('expiring3')}
|
||||
>
|
||||
{t('3 天内到期')}
|
||||
</Tag>
|
||||
<Tag
|
||||
color={quickFilter === 'expiring7' ? 'orange' : 'white'}
|
||||
type={quickFilter === 'expiring7' ? 'solid' : 'ghost'}
|
||||
className='cursor-pointer'
|
||||
onClick={() => applyQuickFilter('expiring7')}
|
||||
>
|
||||
{t('7 天内到期')}
|
||||
</Tag>
|
||||
<Tag
|
||||
color={quickFilter === 'overdue' ? 'grey' : 'white'}
|
||||
type={quickFilter === 'overdue' ? 'solid' : 'ghost'}
|
||||
className='cursor-pointer'
|
||||
onClick={() => applyQuickFilter('overdue')}
|
||||
>
|
||||
{t('已过期未处理')}
|
||||
</Tag>
|
||||
</div>
|
||||
|
||||
{/* 表格 */}
|
||||
<ConsoleCard>
|
||||
<Table
|
||||
>
|
||||
<ConsoleFilterField
|
||||
label={t('搜索关键字')}
|
||||
id='subscription-keyword'
|
||||
>
|
||||
<Input
|
||||
id='subscription-keyword'
|
||||
prefix={<Search size={14} />}
|
||||
placeholder={t('搜索用户名/昵称/订单号')}
|
||||
value={keyword}
|
||||
onChange={setKeyword}
|
||||
onEnterPress={handleSearch}
|
||||
/>
|
||||
</ConsoleFilterField>
|
||||
<ConsoleFilterField label={t('用户ID')} id='subscription-user-id'>
|
||||
<InputNumber
|
||||
id='subscription-user-id'
|
||||
placeholder={t('用户ID')}
|
||||
value={userId}
|
||||
onChange={setUserId}
|
||||
min={0}
|
||||
hideButtons
|
||||
/>
|
||||
</ConsoleFilterField>
|
||||
<ConsoleFilterField
|
||||
label={t('套餐类型')}
|
||||
id='subscription-plan-type'
|
||||
>
|
||||
<Select
|
||||
id='subscription-plan-type'
|
||||
placeholder={t('套餐类型')}
|
||||
value={planTypes}
|
||||
onChange={(v) => {
|
||||
setPage(1);
|
||||
setPlanTypes(v || []);
|
||||
}}
|
||||
multiple
|
||||
maxTagCount={2}
|
||||
optionList={[
|
||||
{ label: t('周卡'), value: 'weekly' },
|
||||
{ label: t('月卡'), value: 'monthly' },
|
||||
{ label: t('季卡'), value: 'quarterly' },
|
||||
]}
|
||||
/>
|
||||
</ConsoleFilterField>
|
||||
<ConsoleFilterField label={t('档位')} id='subscription-tier'>
|
||||
<Select
|
||||
id='subscription-tier'
|
||||
placeholder={t('档位')}
|
||||
value={tiers}
|
||||
onChange={(v) => {
|
||||
setPage(1);
|
||||
setTiers(v || []);
|
||||
}}
|
||||
multiple
|
||||
maxTagCount={2}
|
||||
optionList={[
|
||||
{ label: 'Lite', value: 'lite' },
|
||||
{ label: 'Pro', value: 'pro' },
|
||||
]}
|
||||
/>
|
||||
</ConsoleFilterField>
|
||||
<ConsoleFilterField label={t('状态')} id='subscription-status'>
|
||||
<Select
|
||||
id='subscription-status'
|
||||
placeholder={t('状态')}
|
||||
value={statuses}
|
||||
onChange={(v) => {
|
||||
setPage(1);
|
||||
setStatuses(v || []);
|
||||
}}
|
||||
multiple
|
||||
maxTagCount={2}
|
||||
optionList={[
|
||||
{ label: t('active'), value: 'active' },
|
||||
{ label: t('expired'), value: 'expired' },
|
||||
{ label: t('canceled'), value: 'canceled' },
|
||||
{ label: t('banned'), value: 'banned' },
|
||||
]}
|
||||
/>
|
||||
</ConsoleFilterField>
|
||||
<ConsoleFilterField
|
||||
label={t('到期时间')}
|
||||
id='subscription-end-date'
|
||||
>
|
||||
<DatePicker
|
||||
id={{
|
||||
start: 'subscription-end-date',
|
||||
end: 'subscription-end-date-end',
|
||||
}}
|
||||
type='dateRange'
|
||||
value={endDateRange}
|
||||
onChange={(d) => {
|
||||
setPage(1);
|
||||
setEndDateRange(d || null);
|
||||
}}
|
||||
placeholder={[t('到期开始'), t('到期结束')]}
|
||||
density='compact'
|
||||
/>
|
||||
</ConsoleFilterField>
|
||||
</ConsoleFilterGrid>
|
||||
}
|
||||
actionsArea={
|
||||
<div className='console-list-tools'>
|
||||
<div
|
||||
className='console-list-quick-filters'
|
||||
role='group'
|
||||
aria-label={t('快捷筛选')}
|
||||
>
|
||||
{[
|
||||
['expiring3', t('3 天内到期')],
|
||||
['expiring7', t('7 天内到期')],
|
||||
['overdue', t('已过期未处理')],
|
||||
].map(([key, label]) => (
|
||||
<AntButton
|
||||
key={key}
|
||||
type={quickFilter === key ? 'primary' : 'default'}
|
||||
aria-pressed={quickFilter === key}
|
||||
onClick={() => applyQuickFilter(key)}
|
||||
>
|
||||
{label}
|
||||
</AntButton>
|
||||
))}
|
||||
</div>
|
||||
{admin && (
|
||||
<div className='console-list-tool-actions'>
|
||||
<Button
|
||||
icon={<ActionCreditCard size={14} />}
|
||||
onClick={() => navigate('/console/setting?tab=membership')}
|
||||
>
|
||||
{t('会员管理')}
|
||||
</Button>
|
||||
<Button
|
||||
type='primary'
|
||||
icon={<ActionPlus size={14} />}
|
||||
onClick={openCreate}
|
||||
>
|
||||
{t('新建会员')}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
}
|
||||
paginationArea={createCardProPagination({
|
||||
currentPage: page,
|
||||
pageSize,
|
||||
total,
|
||||
onPageChange: setPage,
|
||||
onPageSizeChange: (size) => {
|
||||
setPage(1);
|
||||
setPageSize(size);
|
||||
},
|
||||
showSizeChanger: false,
|
||||
isMobile,
|
||||
t,
|
||||
})}
|
||||
>
|
||||
<ConsoleListTable
|
||||
columns={columns}
|
||||
dataSource={list}
|
||||
loading={loading}
|
||||
rowKey='id'
|
||||
pagination={{
|
||||
currentPage: page,
|
||||
total,
|
||||
pageSize,
|
||||
onPageChange: setPage,
|
||||
onPageSizeChange: (size) => {
|
||||
setPage(1);
|
||||
setPageSize(size);
|
||||
},
|
||||
showTotal: true,
|
||||
showSizeChanger: false,
|
||||
}}
|
||||
scroll={{ x: 1300 }}
|
||||
size='middle'
|
||||
empty={t('暂无订阅数据')}
|
||||
pagination={false}
|
||||
/>
|
||||
</ConsoleCard>
|
||||
</ConsoleCollection>
|
||||
|
||||
{/* 封禁弹窗 */}
|
||||
<BanModal
|
||||
@@ -978,7 +974,10 @@ const BanModal = ({ visible, row, onCancel, onDone, t }) => {
|
||||
<div className='text-sm text-gray-500'>
|
||||
{t('用户')}:
|
||||
<span className='font-medium text-gray-900 dark:text-white'>
|
||||
{row.display_name || row.username || `User#${row.user_id}`}
|
||||
{formatUserReference(
|
||||
row.display_name || row.username,
|
||||
row.user_id,
|
||||
)}
|
||||
</span>
|
||||
<span className='ml-2 text-xs text-gray-400'>#{row.user_id}</span>
|
||||
</div>
|
||||
@@ -1366,7 +1365,10 @@ const DetailDrawer = ({ visible, row, loading, auditLogs, onClose, t }) => {
|
||||
<div className='flex justify-between'>
|
||||
<span className='text-gray-500'>{t('用户')}</span>
|
||||
<span>
|
||||
{row.display_name || row.username || `User#${row.user_id}`}
|
||||
{formatUserReference(
|
||||
row.display_name || row.username,
|
||||
row.user_id,
|
||||
)}
|
||||
<span className='ml-2 text-xs text-gray-400'>#{row.user_id}</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user