🎨 chore(web): apply ESLint and Prettier auto-fixes (baseline)

- Ran: bun run eslint:fix && bun run lint:fix
- Inserted AGPL license header via eslint-plugin-header
- Enforced no-multiple-empty-lines and other lint rules
- Formatted code using Prettier v3 (@so1ve/prettier-config)
- No functional changes; formatting-only baseline across JS/JSX files
This commit is contained in:
t0ng7u
2025-08-30 21:15:10 +08:00
parent 41cf516ec5
commit 0d57b1acd4
274 changed files with 11025 additions and 7659 deletions

View File

@@ -40,15 +40,17 @@ const InvitationCard = ({
handleAffLinkClick,
}) => {
return (
<Card className="!rounded-2xl shadow-sm border-0">
<Card className='!rounded-2xl shadow-sm border-0'>
{/* 卡片头部 */}
<div className="flex items-center mb-4">
<Avatar size="small" color="green" className="mr-3 shadow-md">
<div className='flex items-center mb-4'>
<Avatar size='small' color='green' className='mr-3 shadow-md'>
<Gift size={16} />
</Avatar>
<div>
<Typography.Text className="text-lg font-medium">{t('邀请奖励')}</Typography.Text>
<div className="text-xs">{t('邀请好友获得额外奖励')}</div>
<Typography.Text className='text-lg font-medium'>
{t('邀请奖励')}
</Typography.Text>
<div className='text-xs'>{t('邀请好友获得额外奖励')}</div>
</div>
</div>
@@ -59,28 +61,33 @@ const InvitationCard = ({
className='!rounded-xl w-full'
cover={
<div
className="relative h-30"
className='relative h-30'
style={{
'--palette-primary-darkerChannel': '0 75 80',
backgroundImage: `linear-gradient(0deg, rgba(var(--palette-primary-darkerChannel) / 80%), rgba(var(--palette-primary-darkerChannel) / 80%)), url('/cover-4.webp')`,
backgroundSize: 'cover',
backgroundPosition: 'center',
backgroundRepeat: 'no-repeat'
backgroundRepeat: 'no-repeat',
}}
>
{/* 标题和按钮 */}
<div className="relative z-10 h-full flex flex-col justify-between p-4">
<div className='relative z-10 h-full flex flex-col justify-between p-4'>
<div className='flex justify-between items-center'>
<Text strong style={{ color: 'white', fontSize: '16px' }}>{t('收益统计')}</Text>
<Text strong style={{ color: 'white', fontSize: '16px' }}>
{t('收益统计')}
</Text>
<Button
type='primary'
theme='solid'
size='small'
disabled={!userState?.user?.aff_quota || userState?.user?.aff_quota <= 0}
disabled={
!userState?.user?.aff_quota ||
userState?.user?.aff_quota <= 0
}
onClick={() => setOpenTransfer(true)}
className='!rounded-lg'
>
<Zap size={12} className="mr-1" />
<Zap size={12} className='mr-1' />
{t('划转到余额')}
</Button>
</div>
@@ -89,34 +96,76 @@ const InvitationCard = ({
<div className='grid grid-cols-3 gap-6 mt-4'>
{/* 待使用收益 */}
<div className='text-center'>
<div className='text-base sm:text-2xl font-bold mb-2' style={{ color: 'white' }}>
<div
className='text-base sm:text-2xl font-bold mb-2'
style={{ color: 'white' }}
>
{renderQuota(userState?.user?.aff_quota || 0)}
</div>
<div className='flex items-center justify-center text-sm'>
<TrendingUp size={14} className="mr-1" style={{ color: 'rgba(255,255,255,0.8)' }} />
<Text style={{ color: 'rgba(255,255,255,0.8)', fontSize: '12px' }}>{t('待使用收益')}</Text>
<TrendingUp
size={14}
className='mr-1'
style={{ color: 'rgba(255,255,255,0.8)' }}
/>
<Text
style={{
color: 'rgba(255,255,255,0.8)',
fontSize: '12px',
}}
>
{t('待使用收益')}
</Text>
</div>
</div>
{/* 总收益 */}
<div className='text-center'>
<div className='text-base sm:text-2xl font-bold mb-2' style={{ color: 'white' }}>
<div
className='text-base sm:text-2xl font-bold mb-2'
style={{ color: 'white' }}
>
{renderQuota(userState?.user?.aff_history_quota || 0)}
</div>
<div className='flex items-center justify-center text-sm'>
<BarChart2 size={14} className="mr-1" style={{ color: 'rgba(255,255,255,0.8)' }} />
<Text style={{ color: 'rgba(255,255,255,0.8)', fontSize: '12px' }}>{t('总收益')}</Text>
<BarChart2
size={14}
className='mr-1'
style={{ color: 'rgba(255,255,255,0.8)' }}
/>
<Text
style={{
color: 'rgba(255,255,255,0.8)',
fontSize: '12px',
}}
>
{t('总收益')}
</Text>
</div>
</div>
{/* 邀请人数 */}
<div className='text-center'>
<div className='text-base sm:text-2xl font-bold mb-2' style={{ color: 'white' }}>
<div
className='text-base sm:text-2xl font-bold mb-2'
style={{ color: 'white' }}
>
{userState?.user?.aff_count || 0}
</div>
<div className='flex items-center justify-center text-sm'>
<Users size={14} className="mr-1" style={{ color: 'rgba(255,255,255,0.8)' }} />
<Text style={{ color: 'rgba(255,255,255,0.8)', fontSize: '12px' }}>{t('邀请人数')}</Text>
<Users
size={14}
className='mr-1'
style={{ color: 'rgba(255,255,255,0.8)' }}
/>
<Text
style={{
color: 'rgba(255,255,255,0.8)',
fontSize: '12px',
}}
>
{t('邀请人数')}
</Text>
</div>
</div>
</div>
@@ -147,11 +196,7 @@ const InvitationCard = ({
{/* 奖励说明 */}
<Card
className='!rounded-xl w-full'
title={
<Text type='tertiary'>
{t('奖励说明')}
</Text>
}
title={<Text type='tertiary'>{t('奖励说明')}</Text>}
>
<div className='space-y-3'>
<div className='flex items-start gap-2'>

View File

@@ -73,15 +73,17 @@ const RechargeCard = ({
const redeemFormApiRef = useRef(null);
const showAmountSkeleton = useMinimumLoadingTime(amountLoading);
return (
<Card className="!rounded-2xl shadow-sm border-0">
<Card className='!rounded-2xl shadow-sm border-0'>
{/* 卡片头部 */}
<div className="flex items-center mb-4">
<Avatar size="small" color="blue" className="mr-3 shadow-md">
<div className='flex items-center mb-4'>
<Avatar size='small' color='blue' className='mr-3 shadow-md'>
<CreditCard size={16} />
</Avatar>
<div>
<Typography.Text className="text-lg font-medium">{t('账户充值')}</Typography.Text>
<div className="text-xs">{t('多种充值方式,安全便捷')}</div>
<Typography.Text className='text-lg font-medium'>
{t('账户充值')}
</Typography.Text>
<div className='text-xs'>{t('多种充值方式,安全便捷')}</div>
</div>
</div>
@@ -91,52 +93,96 @@ const RechargeCard = ({
className='!rounded-xl w-full'
cover={
<div
className="relative h-30"
className='relative h-30'
style={{
'--palette-primary-darkerChannel': '37 99 235',
backgroundImage: `linear-gradient(0deg, rgba(var(--palette-primary-darkerChannel) / 80%), rgba(var(--palette-primary-darkerChannel) / 80%)), url('/cover-4.webp')`,
backgroundSize: 'cover',
backgroundPosition: 'center',
backgroundRepeat: 'no-repeat'
backgroundRepeat: 'no-repeat',
}}
>
<div className="relative z-10 h-full flex flex-col justify-between p-4">
<div className='relative z-10 h-full flex flex-col justify-between p-4'>
<div className='flex justify-between items-center'>
<Text strong style={{ color: 'white', fontSize: '16px' }}>{t('账户统计')}</Text>
<Text strong style={{ color: 'white', fontSize: '16px' }}>
{t('账户统计')}
</Text>
</div>
{/* 统计数据 */}
<div className='grid grid-cols-3 gap-6 mt-4'>
{/* 当前余额 */}
<div className='text-center'>
<div className='text-base sm:text-2xl font-bold mb-2' style={{ color: 'white' }}>
<div
className='text-base sm:text-2xl font-bold mb-2'
style={{ color: 'white' }}
>
{renderQuota(userState?.user?.quota)}
</div>
<div className='flex items-center justify-center text-sm'>
<Wallet size={14} className="mr-1" style={{ color: 'rgba(255,255,255,0.8)' }} />
<Text style={{ color: 'rgba(255,255,255,0.8)', fontSize: '12px' }}>{t('当前余额')}</Text>
<Wallet
size={14}
className='mr-1'
style={{ color: 'rgba(255,255,255,0.8)' }}
/>
<Text
style={{
color: 'rgba(255,255,255,0.8)',
fontSize: '12px',
}}
>
{t('当前余额')}
</Text>
</div>
</div>
{/* 历史消耗 */}
<div className='text-center'>
<div className='text-base sm:text-2xl font-bold mb-2' style={{ color: 'white' }}>
<div
className='text-base sm:text-2xl font-bold mb-2'
style={{ color: 'white' }}
>
{renderQuota(userState?.user?.used_quota)}
</div>
<div className='flex items-center justify-center text-sm'>
<TrendingUp size={14} className="mr-1" style={{ color: 'rgba(255,255,255,0.8)' }} />
<Text style={{ color: 'rgba(255,255,255,0.8)', fontSize: '12px' }}>{t('历史消耗')}</Text>
<TrendingUp
size={14}
className='mr-1'
style={{ color: 'rgba(255,255,255,0.8)' }}
/>
<Text
style={{
color: 'rgba(255,255,255,0.8)',
fontSize: '12px',
}}
>
{t('历史消耗')}
</Text>
</div>
</div>
{/* 请求次数 */}
<div className='text-center'>
<div className='text-base sm:text-2xl font-bold mb-2' style={{ color: 'white' }}>
<div
className='text-base sm:text-2xl font-bold mb-2'
style={{ color: 'white' }}
>
{userState?.user?.request_count || 0}
</div>
<div className='flex items-center justify-center text-sm'>
<BarChart2 size={14} className="mr-1" style={{ color: 'rgba(255,255,255,0.8)' }} />
<Text style={{ color: 'rgba(255,255,255,0.8)', fontSize: '12px' }}>{t('请求次数')}</Text>
<BarChart2
size={14}
className='mr-1'
style={{ color: 'rgba(255,255,255,0.8)' }}
/>
<Text
style={{
color: 'rgba(255,255,255,0.8)',
fontSize: '12px',
}}
>
{t('请求次数')}
</Text>
</div>
</div>
</div>
@@ -147,9 +193,9 @@ const RechargeCard = ({
{/* 在线充值表单 */}
{statusLoading ? (
<div className='py-8 flex justify-center'>
<Spin size="large" />
<Spin size='large' />
</div>
) : (enableOnlineTopUp || enableStripeTopUp) ? (
) : enableOnlineTopUp || enableStripeTopUp ? (
<Form
getFormApi={(api) => (onlineFormApiRef.current = api)}
initValues={{ topUpCount: topUpCount }}
@@ -162,7 +208,9 @@ const RechargeCard = ({
field='topUpCount'
label={t('充值数量')}
disabled={!enableOnlineTopUp && !enableStripeTopUp}
placeholder={t('充值数量,最低 ') + renderQuotaWithAmount(minTopUp)}
placeholder={
t('充值数量,最低 ') + renderQuotaWithAmount(minTopUp)
}
value={topUpCount}
min={minTopUp}
max={999999999}
@@ -183,15 +231,28 @@ const RechargeCard = ({
}
}}
formatter={(value) => (value ? `${value}` : '')}
parser={(value) => value ? parseInt(value.replace(/[^\d]/g, '')) : 0}
parser={(value) =>
value ? parseInt(value.replace(/[^\d]/g, '')) : 0
}
extraText={
<Skeleton
loading={showAmountSkeleton}
active
placeholder={<Skeleton.Title style={{ width: 120, height: 20, borderRadius: 6 }} />}
placeholder={
<Skeleton.Title
style={{
width: 120,
height: 20,
borderRadius: 6,
}}
/>
}
>
<Text type="secondary" className='text-red-600'>
{t('实付金额:')}<span style={{ color: 'red' }}>{renderAmount()}</span>
<Text type='secondary' className='text-red-600'>
{t('实付金额:')}
<span style={{ color: 'red' }}>
{renderAmount()}
</span>
</Text>
</Skeleton>
}
@@ -207,18 +268,30 @@ const RechargeCard = ({
theme='outline'
type='tertiary'
onClick={() => preTopUp(payMethod.type)}
disabled={(!enableOnlineTopUp && payMethod.type !== 'stripe') ||
(!enableStripeTopUp && payMethod.type === 'stripe')}
loading={paymentLoading && payWay === payMethod.type}
disabled={
(!enableOnlineTopUp &&
payMethod.type !== 'stripe') ||
(!enableStripeTopUp &&
payMethod.type === 'stripe')
}
loading={
paymentLoading && payWay === payMethod.type
}
icon={
payMethod.type === 'alipay' ? (
<SiAlipay size={18} color="#1677FF" />
<SiAlipay size={18} color='#1677FF' />
) : payMethod.type === 'wxpay' ? (
<SiWechat size={18} color="#07C160" />
<SiWechat size={18} color='#07C160' />
) : payMethod.type === 'stripe' ? (
<SiStripe size={18} color="#635BFF" />
<SiStripe size={18} color='#635BFF' />
) : (
<CreditCard size={18} color={payMethod.color || 'var(--semi-color-text-2)'} />
<CreditCard
size={18}
color={
payMethod.color ||
'var(--semi-color-text-2)'
}
/>
)
}
>
@@ -237,18 +310,33 @@ const RechargeCard = ({
{presetAmounts.map((preset, index) => (
<Button
key={index}
theme={selectedPreset === preset.value ? 'solid' : 'outline'}
type={selectedPreset === preset.value ? 'primary' : 'tertiary'}
theme={
selectedPreset === preset.value
? 'solid'
: 'outline'
}
type={
selectedPreset === preset.value
? 'primary'
: 'tertiary'
}
onClick={() => {
selectPresetAmount(preset);
onlineFormApiRef.current?.setValue('topUpCount', preset.value);
onlineFormApiRef.current?.setValue(
'topUpCount',
preset.value,
);
}}
className='!rounded-lg !py-2 !px-3'
>
<div className='flex items-center gap-2'>
<Coins size={14} className='opacity-80' />
<span className='font-medium'>{formatLargeNumber(preset.value)}</span>
<span className='text-xs text-gray-500'>{(preset.value * priceRatio).toFixed(2)}</span>
<span className='font-medium'>
{formatLargeNumber(preset.value)}
</span>
<span className='text-xs text-gray-500'>
{(preset.value * priceRatio).toFixed(2)}
</span>
</div>
</Button>
))}
@@ -260,7 +348,9 @@ const RechargeCard = ({
) : (
<Banner
type='info'
description={t('管理员未开启在线充值功能,请联系管理员开启或使用兑换码充值。')}
description={t(
'管理员未开启在线充值功能,请联系管理员开启或使用兑换码充值。',
)}
className='!rounded-xl'
closeIcon={null}
/>
@@ -301,19 +391,21 @@ const RechargeCard = ({
}
showClear
style={{ width: '100%' }}
extraText={topUpLink && (
<Text type="tertiary">
{t('在找兑换码?')}
<Text
type="secondary"
underline
className="cursor-pointer"
onClick={openTopUpLink}
>
{t('购买兑换码')}
extraText={
topUpLink && (
<Text type='tertiary'>
{t('在找兑换码?')}
<Text
type='secondary'
underline
className='cursor-pointer'
onClick={openTopUpLink}
>
{t('购买兑换码')}
</Text>
</Text>
</Text>
)}
)
}
/>
</Form>
</Card>

View File

@@ -28,10 +28,7 @@ import {
copy,
getQuotaPerUnit,
} from '../../helpers';
import {
Modal,
Toast,
} from '@douyinfe/semi-ui';
import { Modal, Toast } from '@douyinfe/semi-ui';
import { useTranslation } from 'react-i18next';
import { UserContext } from '../../context/User';
import { StatusContext } from '../../context/Status';
@@ -60,7 +57,9 @@ const TopUp = () => {
);
const [priceRatio, setPriceRatio] = useState(statusState?.status?.price || 1);
const [enableStripeTopUp, setEnableStripeTopUp] = useState(statusState?.status?.enable_stripe_topup || false);
const [enableStripeTopUp, setEnableStripeTopUp] = useState(
statusState?.status?.enable_stripe_topup || false,
);
const [statusLoading, setStatusLoading] = useState(true);
const [isSubmitting, setIsSubmitting] = useState(false);
@@ -321,12 +320,12 @@ const TopUp = () => {
// 如果启用了 Stripe 支付,添加到支付方法列表
if (statusState?.status?.enable_stripe_topup) {
const hasStripe = payMethods.some(method => method.type === 'stripe');
const hasStripe = payMethods.some((method) => method.type === 'stripe');
if (!hasStripe) {
payMethods.push({
name: 'Stripe',
type: 'stripe',
color: 'rgba(var(--semi-purple-5), 1)'
color: 'rgba(var(--semi-purple-5), 1)',
});
}
}
@@ -418,7 +417,7 @@ const TopUp = () => {
} finally {
setAmountLoading(false);
}
}
};
const handleCancel = () => {
setOpen(false);
@@ -443,8 +442,8 @@ const TopUp = () => {
// 根据最小充值金额生成预设充值额度选项
const generatePresetAmounts = (minAmount) => {
const multipliers = [1, 5, 10, 30, 50, 100, 300, 500];
return multipliers.map(multiplier => ({
value: minAmount * multiplier
return multipliers.map((multiplier) => ({
value: minAmount * multiplier,
}));
};

View File

@@ -18,12 +18,7 @@ For commercial licensing, please contact support@quantumnous.com
*/
import React from 'react';
import {
Modal,
Typography,
Card,
Skeleton,
} from '@douyinfe/semi-ui';
import { Modal, Typography, Card, Skeleton } from '@douyinfe/semi-ui';
import { SiAlipay, SiWechat, SiStripe } from 'react-icons/si';
import { CreditCard } from 'lucide-react';
@@ -62,11 +57,17 @@ const PaymentConfirmModal = ({
<Card className='!rounded-xl !border-0 bg-slate-50 dark:bg-slate-800'>
<div className='space-y-3'>
<div className='flex justify-between items-center'>
<Text strong className='text-slate-700 dark:text-slate-200'>{t('充值数量')}</Text>
<Text className='text-slate-900 dark:text-slate-100'>{renderQuotaWithAmount(topUpCount)}</Text>
<Text strong className='text-slate-700 dark:text-slate-200'>
{t('充值数量')}
</Text>
<Text className='text-slate-900 dark:text-slate-100'>
{renderQuotaWithAmount(topUpCount)}
</Text>
</div>
<div className='flex justify-between items-center'>
<Text strong className='text-slate-700 dark:text-slate-200'>{t('实付金额')}</Text>
<Text strong className='text-slate-700 dark:text-slate-200'>
{t('实付金额')}
</Text>
{amountLoading ? (
<Skeleton.Title style={{ width: '60px', height: '16px' }} />
) : (
@@ -76,7 +77,9 @@ const PaymentConfirmModal = ({
)}
</div>
<div className='flex justify-between items-center'>
<Text strong className='text-slate-700 dark:text-slate-200'>{t('支付方式')}</Text>
<Text strong className='text-slate-700 dark:text-slate-200'>
{t('支付方式')}
</Text>
<div className='flex items-center'>
{(() => {
const payMethod = payMethods.find(
@@ -86,15 +89,35 @@ const PaymentConfirmModal = ({
return (
<>
{payMethod.type === 'alipay' ? (
<SiAlipay className='mr-2' size={16} color="#1677FF" />
<SiAlipay
className='mr-2'
size={16}
color='#1677FF'
/>
) : payMethod.type === 'wxpay' ? (
<SiWechat className='mr-2' size={16} color="#07C160" />
<SiWechat
className='mr-2'
size={16}
color='#07C160'
/>
) : payMethod.type === 'stripe' ? (
<SiStripe className='mr-2' size={16} color="#635BFF" />
<SiStripe
className='mr-2'
size={16}
color='#635BFF'
/>
) : (
<CreditCard className='mr-2' size={16} color={payMethod.color || 'var(--semi-color-text-2)'} />
<CreditCard
className='mr-2'
size={16}
color={
payMethod.color || 'var(--semi-color-text-2)'
}
/>
)}
<Text className='text-slate-900 dark:text-slate-100'>{payMethod.name}</Text>
<Text className='text-slate-900 dark:text-slate-100'>
{payMethod.name}
</Text>
</>
);
} else {
@@ -102,22 +125,40 @@ const PaymentConfirmModal = ({
if (payWay === 'alipay') {
return (
<>
<SiAlipay className='mr-2' size={16} color="#1677FF" />
<Text className='text-slate-900 dark:text-slate-100'>{t('支付宝')}</Text>
<SiAlipay
className='mr-2'
size={16}
color='#1677FF'
/>
<Text className='text-slate-900 dark:text-slate-100'>
{t('支付宝')}
</Text>
</>
);
} else if (payWay === 'stripe') {
return (
<>
<SiStripe className='mr-2' size={16} color="#635BFF" />
<Text className='text-slate-900 dark:text-slate-100'>Stripe</Text>
<SiStripe
className='mr-2'
size={16}
color='#635BFF'
/>
<Text className='text-slate-900 dark:text-slate-100'>
Stripe
</Text>
</>
);
} else {
return (
<>
<SiWechat className='mr-2' size={16} color="#07C160" />
<Text className='text-slate-900 dark:text-slate-100'>{t('微信')}</Text>
<SiWechat
className='mr-2'
size={16}
color='#07C160'
/>
<Text className='text-slate-900 dark:text-slate-100'>
{t('微信')}
</Text>
</>
);
}

View File

@@ -18,12 +18,7 @@ For commercial licensing, please contact support@quantumnous.com
*/
import React from 'react';
import {
Modal,
Typography,
Input,
InputNumber,
} from '@douyinfe/semi-ui';
import { Modal, Typography, Input, InputNumber } from '@douyinfe/semi-ui';
import { CreditCard } from 'lucide-react';
const TransferModal = ({