merge: 同步 origin/ui-optimization(d224d5b6),保留 weiyuan 功能与 Semi 迁移
- 冲突以 weiyuan 功能(小程序登录、i18n 文案)为准,并保留远端 lint 重构与依赖收敛 - 删除 weiyuan 已移除、远端仅做 lint 修正的 3 个图片相关文件 - 适配远端零警告 ESLint:Monitoring/Subscription 改用 useEffectEvent,EditChannelModal 注明 t 依赖 - effect-events 单测补充 react-i18next mock - 对合并后仍不符合 Prettier 的文件做纯格式化
This commit is contained in:
+145
-147
@@ -24,6 +24,7 @@ import {
|
||||
} from '../../components/console/ConsolePrimitives';
|
||||
import { ConsolePageActions } from '../../components/console/ConsolePageContainer';
|
||||
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 {
|
||||
@@ -117,7 +118,9 @@ const RemainingTag = ({ endDate, status, t }) => {
|
||||
let cls = 'text-xs text-gray-500';
|
||||
if (days <= 3) cls = 'text-xs text-red-500 font-semibold';
|
||||
else if (days <= 7) cls = 'text-xs text-amber-500 font-medium';
|
||||
return <span className={cls}>{t('剩余 {{n}} 天', { n: days, count: days })}</span>;
|
||||
return (
|
||||
<span className={cls}>{t('剩余 {{n}} 天', { n: days, count: days })}</span>
|
||||
);
|
||||
};
|
||||
|
||||
const Subscription = () => {
|
||||
@@ -342,158 +345,152 @@ const Subscription = () => {
|
||||
}
|
||||
};
|
||||
|
||||
const columns = useMemo(() => {
|
||||
return [
|
||||
{ title: 'ID', dataIndex: 'id', width: 70 },
|
||||
{
|
||||
title: t('用户'),
|
||||
width: 180,
|
||||
render: (_, r) => {
|
||||
const display = r.display_name || '';
|
||||
const username = r.username || '';
|
||||
return (
|
||||
<div className='flex flex-col'>
|
||||
<span className='font-medium'>
|
||||
{display || username || `User#${r.user_id}`}
|
||||
</span>
|
||||
<span className='text-xs text-gray-400'>
|
||||
#{r.user_id}
|
||||
{username ? ` @${username}` : ''}
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: t('套餐'),
|
||||
width: 180,
|
||||
render: (_, r) => (
|
||||
<Space spacing={4} wrap>
|
||||
<Tag color={planTypeColorMap[r.plan_type] || 'grey'} size='small'>
|
||||
{r.plan_name || r.plan_type}
|
||||
</Tag>
|
||||
{r.tier ? (
|
||||
<Tag
|
||||
color={tierColorMap[r.tier] || 'grey'}
|
||||
size='small'
|
||||
type='ghost'
|
||||
>
|
||||
{r.tier}
|
||||
</Tag>
|
||||
) : null}
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t('状态'),
|
||||
dataIndex: 'status',
|
||||
width: 90,
|
||||
render: (s) => (
|
||||
<Tag color={statusColorMap[s] || 'grey'}>{t(s || '未知')}</Tag>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t('起始时间'),
|
||||
dataIndex: 'start_date',
|
||||
width: 110,
|
||||
render: formatDateOnly,
|
||||
},
|
||||
{
|
||||
title: t('到期时间'),
|
||||
width: 160,
|
||||
render: (_, r) => (
|
||||
const columns = [
|
||||
{ title: 'ID', dataIndex: 'id', width: 70 },
|
||||
{
|
||||
title: t('用户'),
|
||||
width: 180,
|
||||
render: (_, r) => {
|
||||
const display = r.display_name || '';
|
||||
const username = r.username || '';
|
||||
return (
|
||||
<div className='flex flex-col'>
|
||||
<span>{formatDateOnly(r.end_date)}</span>
|
||||
<RemainingTag endDate={r.end_date} status={r.status} t={t} />
|
||||
<span className='font-medium'>
|
||||
{display || username || `User#${r.user_id}`}
|
||||
</span>
|
||||
<span className='text-xs text-gray-400'>
|
||||
#{r.user_id}
|
||||
{username ? ` @${username}` : ''}
|
||||
</span>
|
||||
</div>
|
||||
),
|
||||
);
|
||||
},
|
||||
{
|
||||
title: t('每日额度'),
|
||||
dataIndex: 'daily_quota',
|
||||
width: 110,
|
||||
render: (v) => renderQuota(v, 2),
|
||||
},
|
||||
{
|
||||
title: t('支付金额'),
|
||||
dataIndex: 'price_paid',
|
||||
width: 100,
|
||||
render: (v) => (v != null ? `¥${Number(v).toFixed(2)}` : '-'),
|
||||
},
|
||||
{
|
||||
title: t('操作'),
|
||||
width: 300,
|
||||
fixed: 'right',
|
||||
render: (_, r) => (
|
||||
<Space spacing={4} wrap>
|
||||
},
|
||||
{
|
||||
title: t('套餐'),
|
||||
width: 180,
|
||||
render: (_, r) => (
|
||||
<Space spacing={4} wrap>
|
||||
<Tag color={planTypeColorMap[r.plan_type] || 'grey'} size='small'>
|
||||
{r.plan_name || r.plan_type}
|
||||
</Tag>
|
||||
{r.tier ? (
|
||||
<Tag
|
||||
color={tierColorMap[r.tier] || 'grey'}
|
||||
size='small'
|
||||
type='ghost'
|
||||
>
|
||||
{r.tier}
|
||||
</Tag>
|
||||
) : null}
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t('状态'),
|
||||
dataIndex: 'status',
|
||||
width: 90,
|
||||
render: (s) => (
|
||||
<Tag color={statusColorMap[s] || 'grey'}>{t(s || '未知')}</Tag>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t('起始时间'),
|
||||
dataIndex: 'start_date',
|
||||
width: 110,
|
||||
render: formatDateOnly,
|
||||
},
|
||||
{
|
||||
title: t('到期时间'),
|
||||
width: 160,
|
||||
render: (_, r) => (
|
||||
<div className='flex flex-col'>
|
||||
<span>{formatDateOnly(r.end_date)}</span>
|
||||
<RemainingTag endDate={r.end_date} status={r.status} t={t} />
|
||||
</div>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t('每日额度'),
|
||||
dataIndex: 'daily_quota',
|
||||
width: 110,
|
||||
render: (v) => renderQuota(v, 2),
|
||||
},
|
||||
{
|
||||
title: t('支付金额'),
|
||||
dataIndex: 'price_paid',
|
||||
width: 100,
|
||||
render: (v) => (v != null ? `¥${Number(v).toFixed(2)}` : '-'),
|
||||
},
|
||||
{
|
||||
title: t('操作'),
|
||||
width: 300,
|
||||
fixed: 'right',
|
||||
render: (_, r) => (
|
||||
<Space spacing={4} wrap>
|
||||
<Button size='small' theme='borderless' onClick={() => openDetail(r)}>
|
||||
{t('详情')}
|
||||
</Button>
|
||||
{admin && r.status !== 'banned' && (
|
||||
<Button
|
||||
size='small'
|
||||
theme='borderless'
|
||||
onClick={() => openDetail(r)}
|
||||
type='danger'
|
||||
icon={<Ban size={12} />}
|
||||
onClick={() => openBan(r)}
|
||||
>
|
||||
{t('详情')}
|
||||
{t('封禁')}
|
||||
</Button>
|
||||
{admin && r.status !== 'banned' && (
|
||||
)}
|
||||
{admin && r.status === 'banned' && (
|
||||
<Button
|
||||
size='small'
|
||||
theme='borderless'
|
||||
type='primary'
|
||||
icon={<ShieldCheck size={12} />}
|
||||
onClick={() => openUnban(r)}
|
||||
>
|
||||
{t('解封')}
|
||||
</Button>
|
||||
)}
|
||||
{admin && r.status !== 'canceled' && r.status !== 'banned' && (
|
||||
<Button
|
||||
size='small'
|
||||
theme='borderless'
|
||||
icon={<CalendarClock size={12} />}
|
||||
onClick={() => openExtend(r)}
|
||||
>
|
||||
{t('延长')}
|
||||
</Button>
|
||||
)}
|
||||
{admin && (
|
||||
<Button
|
||||
size='small'
|
||||
theme='borderless'
|
||||
icon={<Pencil size={12} />}
|
||||
onClick={() => openEdit(r)}
|
||||
>
|
||||
{t('编辑')}
|
||||
</Button>
|
||||
)}
|
||||
{admin && r.status === 'active' && (
|
||||
<Popconfirm
|
||||
title={t('确认手动补发今日额度?')}
|
||||
onConfirm={() => doGrant(r)}
|
||||
>
|
||||
<Button
|
||||
size='small'
|
||||
theme='borderless'
|
||||
type='danger'
|
||||
icon={<Ban size={12} />}
|
||||
onClick={() => openBan(r)}
|
||||
icon={<Sparkles size={12} />}
|
||||
>
|
||||
{t('封禁')}
|
||||
{t('补发')}
|
||||
</Button>
|
||||
)}
|
||||
{admin && r.status === 'banned' && (
|
||||
<Button
|
||||
size='small'
|
||||
theme='borderless'
|
||||
type='primary'
|
||||
icon={<ShieldCheck size={12} />}
|
||||
onClick={() => openUnban(r)}
|
||||
>
|
||||
{t('解封')}
|
||||
</Button>
|
||||
)}
|
||||
{admin && r.status !== 'canceled' && r.status !== 'banned' && (
|
||||
<Button
|
||||
size='small'
|
||||
theme='borderless'
|
||||
icon={<CalendarClock size={12} />}
|
||||
onClick={() => openExtend(r)}
|
||||
>
|
||||
{t('延长')}
|
||||
</Button>
|
||||
)}
|
||||
{admin && (
|
||||
<Button
|
||||
size='small'
|
||||
theme='borderless'
|
||||
icon={<Pencil 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>
|
||||
),
|
||||
},
|
||||
];
|
||||
}, [t, admin]);
|
||||
</Popconfirm>
|
||||
)}
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<div className='console-content'>
|
||||
@@ -760,14 +757,15 @@ const CreateMembershipModal = ({
|
||||
const [reason, setReason] = useState(() => t('管理员手动开通会员'));
|
||||
const [submitting, setSubmitting] = useState(false);
|
||||
|
||||
const resetForm = useEffectEvent(() => {
|
||||
setUserId(undefined);
|
||||
setPlanId(undefined);
|
||||
setDays(30);
|
||||
setReason(t('管理员手动开通会员'));
|
||||
});
|
||||
useEffect(() => {
|
||||
if (visible) {
|
||||
setUserId(undefined);
|
||||
setPlanId(undefined);
|
||||
setDays(30);
|
||||
setReason(t('管理员手动开通会员'));
|
||||
}
|
||||
}, [visible]);
|
||||
if (visible) resetForm();
|
||||
}, [visible, resetForm]);
|
||||
|
||||
const enabledPlans = useMemo(
|
||||
() => plans.filter((plan) => plan.is_enabled),
|
||||
|
||||
Reference in New Issue
Block a user