merge: 合入总仓库 weiyuan(bfdfb339) web/ 新功能,保留 ui-optimization 的 UI 重构
来源:luoguang/monkey-ai weiyuan@bfdfb339 的 web/(经 sync/main-weiyuan-web-bfdfb339 同步)
同步基准:总仓库 a2ca13cb = 本仓库初始导入 d8f3aee2
冲突处理原则:保留 ui-optimization 的 UI(样式/结构/组件),嫁接 weiyuan 的功能逻辑。
- i18n:按键三方合并;ours 的「令牌→密钥」改名键上移植 theirs 的术语修订
- task-logs / OrgLogs:ours 已手工移植同一功能(6ad95e2),保留 ours
- 删除:OrgCreate(theirs 下线 /org/create)、旧 image 组件与 VideoRegenerateModal(theirs 体验中心重写)、
OrgAvatarSection / PricingBentoPage / CommissionConsole(ours 重构中已移除)
- 测试:users-pagination 的 i18next mock 补 t();theirs 新增文件补 license header
This commit is contained in:
@@ -20,6 +20,7 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
import React from 'react';
|
||||
import { getCurrencyConfig } from '../../helpers/render';
|
||||
import { renderQuota } from '../../helpers';
|
||||
import { calculatePresetPayableAmount } from '../../helpers/rechargeAmount';
|
||||
import { Check } from 'lucide-react';
|
||||
|
||||
// 折扣角标:0.99 → 99折,0.9 → 9折(与原型一致的中文折扣写法)
|
||||
@@ -37,16 +38,18 @@ const AmountCard = ({
|
||||
t,
|
||||
}) => {
|
||||
const discount =
|
||||
preset.discount || topupInfo?.discount?.[preset.value] || 1.0;
|
||||
preset.discount ?? topupInfo?.discount?.[preset.value] ?? 1.0;
|
||||
const hasDiscount = discount < 1.0;
|
||||
|
||||
// 计算实付金额(人民币)
|
||||
// 新版档位(有 id 字段):amount 已经是人民币金额,直接乘以折扣
|
||||
// 旧版档位或自定义金额:需要乘以汇率
|
||||
const isNewVersion = preset.id !== undefined;
|
||||
const discountedPrice = isNewVersion
|
||||
? preset.value * discount // 新版:人民币金额 * 折扣
|
||||
: preset.value * priceRatio * discount; // 旧版:额度 * 汇率 * 折扣
|
||||
const discountedPrice = calculatePresetPayableAmount(
|
||||
preset,
|
||||
priceRatio,
|
||||
topupInfo,
|
||||
);
|
||||
|
||||
// 获取货币显示配置(仅用于显示充值额度的货币符号)
|
||||
const { symbol } = getCurrencyConfig();
|
||||
|
||||
@@ -44,7 +44,7 @@ const planTypeConfig = {
|
||||
};
|
||||
|
||||
const MembershipPanel = () => {
|
||||
const { t } = useTranslation();
|
||||
const { t, i18n } = useTranslation();
|
||||
const [, userDispatch] = useContext(UserContext);
|
||||
|
||||
const [loading, setLoading] = useState(true);
|
||||
@@ -227,7 +227,7 @@ const MembershipPanel = () => {
|
||||
});
|
||||
const { success, message } = res.data;
|
||||
if (success) {
|
||||
showSuccess(message || '升级成功!');
|
||||
showSuccess(message || t('升级成功!'));
|
||||
setUpgradeModalVisible(false);
|
||||
setSelectedPlan(null);
|
||||
setUpgradeInfo(null);
|
||||
@@ -286,7 +286,7 @@ const MembershipPanel = () => {
|
||||
|
||||
// 格式化日期
|
||||
const formatDate = (timestamp) => {
|
||||
return new Date(timestamp * 1000).toLocaleDateString('zh-CN');
|
||||
return new Date(timestamp * 1000).toLocaleDateString(i18n.language);
|
||||
};
|
||||
|
||||
// 原型展示固定的周卡/月卡/季卡三个时长,没有方案的时长显示“待补充”空态
|
||||
@@ -345,7 +345,10 @@ const MembershipPanel = () => {
|
||||
{t('到期日')}: {formatDate(membershipInfo.end_date)}
|
||||
</span>
|
||||
<span>
|
||||
{t('剩余')} {membershipInfo.remaining_days} {t('天')}
|
||||
{t('剩余 {{n}} 天', {
|
||||
n: membershipInfo.remaining_days,
|
||||
count: membershipInfo.remaining_days,
|
||||
})}
|
||||
</span>
|
||||
</div>
|
||||
{/* 已续费提示 */}
|
||||
@@ -353,17 +356,11 @@ const MembershipPanel = () => {
|
||||
<Banner
|
||||
type='success'
|
||||
closeIcon={null}
|
||||
description={
|
||||
t('已续费') +
|
||||
':' +
|
||||
membershipInfo.future_plan_name +
|
||||
',' +
|
||||
formatDate(membershipInfo.future_start_date) +
|
||||
' ~ ' +
|
||||
formatDate(membershipInfo.future_end_date) +
|
||||
' ' +
|
||||
t('生效')
|
||||
}
|
||||
description={t('已续费:{{plan}},{{start}} ~ {{end}} 生效', {
|
||||
plan: membershipInfo.future_plan_name,
|
||||
start: formatDate(membershipInfo.future_start_date),
|
||||
end: formatDate(membershipInfo.future_end_date),
|
||||
})}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
@@ -458,7 +455,7 @@ const MembershipPanel = () => {
|
||||
{Number(plan.price).toLocaleString('en-US')}
|
||||
</strong>
|
||||
<span>
|
||||
/ {plan.duration_days} {t('天')}
|
||||
/ {t('{{days}} 天', { days: plan.duration_days })}
|
||||
</span>
|
||||
</span>
|
||||
<span className='rc-plan-quota'>
|
||||
@@ -534,8 +531,7 @@ const MembershipPanel = () => {
|
||||
{selectedPlan.name}
|
||||
</Text>
|
||||
<Tag color='blue' size='small'>
|
||||
{selectedPlan.duration_days}
|
||||
{t('天')}
|
||||
{t('{{days}} 天', { days: selectedPlan.duration_days })}
|
||||
</Tag>
|
||||
</div>
|
||||
<div className='flex justify-between items-center mb-2'>
|
||||
@@ -590,17 +586,14 @@ const MembershipPanel = () => {
|
||||
{isRenewal && (
|
||||
<Banner
|
||||
type='success'
|
||||
description={
|
||||
t('续费提示') +
|
||||
':' +
|
||||
t('您将续费当前「') +
|
||||
membershipInfo.plan_name +
|
||||
t('」,新的 ') +
|
||||
selectedPlan.duration_days +
|
||||
t(' 天会员将在当前会员到期后(') +
|
||||
formatDate(membershipInfo.end_date) +
|
||||
t(')自动生效,届时每日额度保持不变。')
|
||||
}
|
||||
description={t(
|
||||
'续费提示:您将续费当前「{{plan}}」,新的 {{days}} 天会员将在当前会员到期后({{date}})自动生效,届时每日额度保持不变。',
|
||||
{
|
||||
plan: membershipInfo.plan_name,
|
||||
days: selectedPlan.duration_days,
|
||||
date: formatDate(membershipInfo.end_date),
|
||||
},
|
||||
)}
|
||||
closeIcon={null}
|
||||
/>
|
||||
)}
|
||||
@@ -609,15 +602,14 @@ const MembershipPanel = () => {
|
||||
{!isRenewal && !isDowngrade && (
|
||||
<Banner
|
||||
type='info'
|
||||
description={
|
||||
t('您当前有「') +
|
||||
membershipInfo.plan_name +
|
||||
t('」会员(到期日:') +
|
||||
formatDate(membershipInfo.end_date) +
|
||||
t(')。新购买的「') +
|
||||
selectedPlan.name +
|
||||
t('」将在当前会员到期后开始生效。')
|
||||
}
|
||||
description={t(
|
||||
'您当前有「{{plan}}」会员(到期日:{{date}})。新购买的「{{newPlan}}」将在当前会员到期后开始生效。',
|
||||
{
|
||||
plan: membershipInfo.plan_name,
|
||||
date: formatDate(membershipInfo.end_date),
|
||||
newPlan: selectedPlan.name,
|
||||
},
|
||||
)}
|
||||
closeIcon={null}
|
||||
/>
|
||||
)}
|
||||
@@ -626,15 +618,13 @@ const MembershipPanel = () => {
|
||||
{isDowngrade && (
|
||||
<Banner
|
||||
type='warning'
|
||||
description={
|
||||
t('注意:此方案的每日额度(') +
|
||||
renderQuota(selectedPlan.daily_quota) +
|
||||
t(')低于您当前方案(') +
|
||||
renderQuota(membershipInfo.daily_quota) +
|
||||
t(
|
||||
')。新会员将在当前会员到期后生效,届时每日额度将降低。如需立即提升额度,建议使用「升级」功能。',
|
||||
)
|
||||
}
|
||||
description={t(
|
||||
'注意:此方案的每日额度({{newQuota}})低于您当前方案({{currentQuota}})。新会员将在当前会员到期后生效,届时每日额度将降低。如需立即提升额度,建议使用「升级」功能。',
|
||||
{
|
||||
newQuota: renderQuota(selectedPlan.daily_quota),
|
||||
currentQuota: renderQuota(membershipInfo.daily_quota),
|
||||
},
|
||||
)}
|
||||
closeIcon={null}
|
||||
/>
|
||||
)}
|
||||
@@ -656,15 +646,13 @@ const MembershipPanel = () => {
|
||||
{membershipInfo.has_future_membership && (
|
||||
<Banner
|
||||
type='warning'
|
||||
description={
|
||||
t('您已有一个待生效的续费会员「') +
|
||||
membershipInfo.future_plan_name +
|
||||
t('」(') +
|
||||
formatDate(membershipInfo.future_start_date) +
|
||||
t(
|
||||
' 生效)。再次购买将在其到期后生效,请确认是否需要继续。',
|
||||
)
|
||||
}
|
||||
description={t(
|
||||
'您已有一个待生效的续费会员「{{plan}}」({{date}} 生效)。再次购买将在其到期后生效,请确认是否需要继续。',
|
||||
{
|
||||
plan: membershipInfo.future_plan_name,
|
||||
date: formatDate(membershipInfo.future_start_date),
|
||||
},
|
||||
)}
|
||||
closeIcon={null}
|
||||
/>
|
||||
)}
|
||||
@@ -745,7 +733,7 @@ const MembershipPanel = () => {
|
||||
<div className='flex justify-between items-center mb-2'>
|
||||
<Text className='text-gray-500'>{t('剩余会员天数')}</Text>
|
||||
<Text strong>
|
||||
{upgradeInfo.remaining_days} {t('天')}
|
||||
{t('{{days}} 天', { days: upgradeInfo.remaining_days })}
|
||||
</Text>
|
||||
</div>
|
||||
<div className='flex justify-between items-center mb-2'>
|
||||
|
||||
@@ -53,6 +53,7 @@ import {
|
||||
requestPayPalOrder,
|
||||
removePayPalReturnState,
|
||||
} from '../../helpers/paypalPayment';
|
||||
import { calculatePresetPayableAmount } from '../../helpers/rechargeAmount';
|
||||
|
||||
const Recharge = ({ embedded = false }) => {
|
||||
const consolePage = useConsolePage();
|
||||
@@ -213,6 +214,20 @@ const Recharge = ({ embedded = false }) => {
|
||||
}
|
||||
|
||||
setPayWay(payment);
|
||||
if (payment !== 'paypal') {
|
||||
// A PayPal quote stores the USD amount in the shared `amount` state.
|
||||
// Restore the selected tier's CNY amount before showing another method.
|
||||
setPayPalQuote(null);
|
||||
if (selectedPresetObj) {
|
||||
setAmount(
|
||||
calculatePresetPayableAmount(
|
||||
selectedPresetObj,
|
||||
priceRatio,
|
||||
topupInfo,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
setPaymentLoading(true);
|
||||
try {
|
||||
// 如果选择了预设档位,已经在 selectPresetAmount 中计算好了金额(包含折扣和汇率),不需要重新获取
|
||||
@@ -229,7 +244,7 @@ const Recharge = ({ embedded = false }) => {
|
||||
|
||||
const selectedMinimum = payment === 'paypal' ? payPalMinTopUp : minTopUp;
|
||||
if (topUpCount < selectedMinimum) {
|
||||
showError(t('充值数量不能小于') + selectedMinimum);
|
||||
showError(t('充值数量不能小于 {{n}}', { n: selectedMinimum }));
|
||||
return;
|
||||
}
|
||||
setOpen(true);
|
||||
@@ -259,7 +274,7 @@ const Recharge = ({ embedded = false }) => {
|
||||
|
||||
const selectedMinimum = payWay === 'paypal' ? payPalMinTopUp : minTopUp;
|
||||
if (topUpCount < selectedMinimum) {
|
||||
showError('充值数量不能小于' + selectedMinimum);
|
||||
showError(t('充值数量不能小于 {{n}}', { n: selectedMinimum }));
|
||||
return;
|
||||
}
|
||||
setConfirmLoading(true);
|
||||
@@ -613,7 +628,10 @@ const Recharge = ({ embedded = false }) => {
|
||||
setAmount(parseFloat(data));
|
||||
} else {
|
||||
setAmount(0);
|
||||
Toast.error({ content: '错误:' + data, id: 'getAmount' });
|
||||
Toast.error({
|
||||
content: t('错误:{{msg}}', { msg: data }),
|
||||
id: 'getAmount',
|
||||
});
|
||||
}
|
||||
} else {
|
||||
showError(res);
|
||||
@@ -640,7 +658,10 @@ const Recharge = ({ embedded = false }) => {
|
||||
setAmount(parseFloat(data));
|
||||
} else {
|
||||
setAmount(0);
|
||||
Toast.error({ content: '错误:' + data, id: 'getAmount' });
|
||||
Toast.error({
|
||||
content: t('错误:{{msg}}', { msg: data }),
|
||||
id: 'getAmount',
|
||||
});
|
||||
}
|
||||
} else {
|
||||
showError(res);
|
||||
@@ -657,17 +678,8 @@ const Recharge = ({ embedded = false }) => {
|
||||
setTopUpCount(preset.value);
|
||||
setSelectedPreset(preset.value);
|
||||
setSelectedPresetObj(preset); // 保存完整的预设对象
|
||||
const discount = preset.discount || topupInfo.discount[preset.value] || 1.0;
|
||||
|
||||
// 计算实付金额(人民币)
|
||||
// 新版档位(有 id 字段):amount 已经是人民币金额,直接乘以折扣
|
||||
// 旧版档位或自定义金额:需要乘以汇率
|
||||
const isNewVersion = preset.id !== undefined;
|
||||
const discountedAmount = isNewVersion
|
||||
? preset.value * discount // 新版:人民币金额 * 折扣
|
||||
: preset.value * priceRatio * discount; // 旧版:额度 * 汇率 * 折扣
|
||||
|
||||
setAmount(discountedAmount);
|
||||
setPayPalQuote(null);
|
||||
setAmount(calculatePresetPayableAmount(preset, priceRatio, topupInfo));
|
||||
};
|
||||
|
||||
// 生成预设充值额度
|
||||
|
||||
Reference in New Issue
Block a user