fix(ui): 修复登录和并发请求并统一页面展示

调整登录流程和请求处理,统一各中心的表格交互、主题样式和页面展示。
This commit is contained in:
zhanjunhao
2026-11-19 18:58:46 +08:00
parent 9b6eb1c7c4
commit 7908ed53a3
128 changed files with 4672 additions and 5391 deletions
+195 -381
View File
@@ -19,7 +19,6 @@ For commercial licensing, please contact support@quantumnous.com
import {
Copy as ActionCopy,
CheckCircle as ActionCheckCircle,
Download as ActionDownload,
} from '@/components/common/icons/ActionIcons';
import React, { useState, useEffect, useRef, useCallback } from 'react';
@@ -30,26 +29,17 @@ import {
Button,
Typography,
Tabs,
TabPane,
Input,
Tag,
} from '@/components/ui';
Alert,
Skeleton,
Radio,
} from 'antd';
import { QRCodeCanvas } from 'qrcode.react';
import {
Share2,
Smartphone,
Monitor,
Gift,
Users,
Sparkles,
ChevronRight,
CheckCircle,
Coins,
TrendingUp,
} from 'lucide-react';
import { Smartphone, Monitor, Gift, Users, ChevronRight } from 'lucide-react';
import './promotion-poster.css';
import { API, showError, showSuccess, copy } from '../../helpers';
const { Text } = Typography;
const { Text, Title, Paragraph } = Typography;
// 默认海报模板配置
const DEFAULT_TEMPLATES = [
@@ -311,409 +301,233 @@ const PromotionPosterModal = ({ visible, onClose }) => {
copyWithFeedback(affCode, t('邀请码'));
};
// 链接分享模式 - PC友好
const renderLinkMode = () => (
<div className='flex flex-col items-center w-full'>
{/* 分享卡片 */}
<div
className='w-full rounded-2xl p-6 mb-6 relative overflow-hidden'
style={{ background: selectedTemplate.bgGradient }}
>
{/* 装饰元素 */}
<div className='absolute top-0 right-0 w-32 h-32 bg-white/10 rounded-full -translate-y-1/2 translate-x-1/2' />
<div className='absolute bottom-0 left-0 w-24 h-24 bg-white/10 rounded-full translate-y-1/2 -translate-x-1/2' />
<div className='absolute top-1/2 right-4 w-16 h-16 bg-white/5 rounded-full' />
<div className='relative z-10'>
{/* 平台信息 */}
<div className='flex items-center gap-3 mb-4'>
<div className='w-12 h-12 bg-white/20 backdrop-blur-sm rounded-xl flex items-center justify-center shadow-lg'>
<Sparkles size={24} className='text-white' />
</div>
<div>
<h3 className='text-white font-bold text-lg drop-shadow-sm'>
{systemName}
</h3>
<p className='text-white/80 text-sm'>
{posterConfig?.slogan || t('邀请好友,共享AI')}
</p>
</div>
</div>
{/* 福利说明 */}
<div className='flex gap-4 mb-5'>
<div className='flex items-center gap-2 text-white/90 text-sm bg-white/10 backdrop-blur-sm px-3 py-1.5 rounded-full'>
<Gift size={14} />
<span>{t('注册即送额度')}</span>
</div>
<div className='flex items-center gap-2 text-white/90 text-sm bg-white/10 backdrop-blur-sm px-3 py-1.5 rounded-full'>
<Users size={14} />
<span>{t('消费返佣')}</span>
</div>
</div>
{/* 二维码(小尺寸) */}
<div className='flex items-center gap-4'>
<div className='bg-white rounded-xl p-2.5 shadow-xl'>
<QRCodeCanvas
id='link-mode-qrcode'
value={affLink || 'https://example.com'}
size={80}
level='M'
includeMargin={false}
/>
</div>
<div className='flex-1'>
<p className='text-white/70 text-xs mb-1'>{t('手机扫码注册')}</p>
<p className='text-white font-mono text-sm'>
{t('邀请码')}:{' '}
<span className='font-bold bg-white/20 px-2 py-0.5 rounded'>
{affCode}
</span>
</p>
</div>
</div>
</div>
</div>
{/* 链接输入框 */}
<div className='w-full mb-4'>
<Text className='text-sm text-gray-500 dark:text-gray-400 mb-2 block font-medium'>
{t('邀请链接')}
</Text>
<div className='relative group'>
<div className='absolute -inset-0.5 bg-gradient-to-r from-brand-from/30 to-brand-to/30 rounded-lg opacity-0 group-hover:opacity-100 transition-opacity duration-300 blur-sm' />
<Input
<div className='pm-link-layout'>
<section className='pm-invitation-card'>
<div className='pm-eyebrow'>{t('推广分享')}</div>
<Title level={4}>{systemName}</Title>
<Paragraph type='secondary'>
{posterConfig?.slogan || t('邀请好友,共享AI')}
</Paragraph>
<div className='pm-qrcode'>
<QRCodeCanvas
id='link-mode-qrcode'
value={affLink}
readOnly
size='large'
className='!rounded-xl'
suffix={
<Button
theme='solid'
type='primary'
size='small'
icon={<ActionCopy size={14} />}
onClick={handleCopyLink}
className='!bg-gradient-to-r !from-brand-from !to-brand-to !border-0 !rounded-lg'
>
{t('复制')}
</Button>
}
size={144}
level='M'
marginSize={2}
/>
</div>
</div>
{/* 邀请码 */}
<div className='w-full mb-4'>
<Text className='text-sm text-gray-500 dark:text-gray-400 mb-2 block font-medium'>
{t('邀请码')}
</Text>
<div className='flex items-center gap-3'>
<div className='relative'>
<div className='absolute -inset-1 bg-gradient-to-r from-blue-500/20 to-brand-to/20 rounded-lg blur-sm' />
<Tag
size='large'
color='blue'
className='!text-lg !px-5 !py-2.5 !rounded-xl !font-bold relative'
>
{affCode}
</Tag>
</div>
<Text type='secondary'>{t('手机扫码注册')}</Text>
<div className='pm-benefits'>
<span>
<Gift size={14} aria-hidden />
{t('注册即送额度')}
</span>
<span>
<Users size={14} aria-hidden />
{t('消费返佣')}
</span>
</div>
</section>
<section className='pm-share-details'>
<div className='pm-field'>
<label htmlFor='promotion-link'>{t('邀请链接')}</label>
<Input id='promotion-link' value={affLink} readOnly size='large' />
<Button
theme='light'
type='tertiary'
icon={<ActionCopy size={14} />}
onClick={handleCopyCode}
className='!rounded-lg'
type='primary'
icon={<ActionCopy size={16} aria-hidden />}
onClick={handleCopyLink}
>
{t('复制')}
{t('复制链接')}
</Button>
</div>
</div>
{/* 使用说明 */}
<div className='w-full p-4 bg-gradient-to-r from-blue-50 to-brand-to/5 dark:from-blue-900/20 dark:to-brand-to/20 rounded-xl border border-blue-100 dark:border-blue-800/30'>
<div className='flex items-start gap-2'>
<CheckCircle
size={16}
className='text-blue-500 mt-0.5 flex-shrink-0'
/>
<Text className='text-sm text-blue-700 dark:text-blue-300'>
{t(
'将链接发送给好友,好友点击即可注册。支持微信、QQ、邮件等任意方式分享。',
)}
<div className='pm-field'>
<Text strong id='promotion-code-label'>
{t('邀请码')}
</Text>
<div
className='pm-code-row'
role='group'
aria-labelledby='promotion-code-label'
>
<Text id='promotion-code' className='pm-code'>
{affCode}
</Text>
<Button
icon={<ActionCopy size={16} aria-hidden />}
onClick={handleCopyCode}
>
{t('复制')}
</Button>
</div>
</div>
</div>
<Paragraph type='secondary' className='pm-share-hint'>
{t(
'将链接发送给好友,好友点击即可注册。支持微信、QQ、邮件等任意方式分享。',
)}
</Paragraph>
</section>
</div>
);
// 海报模式 - 移动端友好
const renderPosterMode = () => (
<div className='flex flex-col items-center'>
{/* 模板选择 */}
<div className='w-full mb-4'>
<Text className='text-sm text-gray-500 dark:text-gray-400 mb-2 block font-medium'>
{t('选择模板')}
</Text>
<div className='flex gap-3 flex-wrap'>
{DEFAULT_TEMPLATES.map((template) => (
<button
key={template.id}
onClick={() => setSelectedTemplate(template)}
className={[
'app-action-button',
`relative w-14 h-14 rounded-xl border-2 transition-all duration-300 overflow-hidden ${
selectedTemplate.id === template.id
? 'border-brand scale-110 shadow-lg shadow-brand/30'
: 'border-transparent hover:border-gray-300 hover:scale-105'
}`,
]
.filter(Boolean)
.join(' ')}
style={{ background: template.bgGradient }}
title={t(template.name)}
>
{selectedTemplate.id === template.id && (
<div className='absolute inset-0 flex items-center justify-center bg-black/20'>
<ActionCheckCircle size={20} className='text-white' />
</div>
)}
</button>
))}
</div>
</div>
{/* 海报预览 */}
<div
className='relative rounded-2xl overflow-hidden shadow-2xl'
style={{
width: 280,
height: 497,
background: selectedTemplate.bgGradient,
}}
>
{/* 装饰元素 */}
<div className='absolute top-0 right-0 w-24 h-24 bg-white/10 rounded-full -translate-y-1/2 translate-x-1/2' />
<div className='absolute bottom-20 left-0 w-16 h-16 bg-white/10 rounded-full -translate-x-1/2' />
<div className='absolute inset-0 flex flex-col items-center pt-10 px-5'>
<h2
className='text-xl font-bold mb-2 text-center drop-shadow-sm'
style={{ color: selectedTemplate.textColor }}
>
{posterConfig?.slogan || t('邀请好友,共享AI')}
</h2>
<p
className='text-xs mb-5 opacity-90'
style={{ color: selectedTemplate.textColor }}
>
<div className='pm-poster-layout'>
<div className='pm-preview-stage'>
<div
className='pm-poster'
style={{
'--pm-poster-background': selectedTemplate.bgGradient,
'--pm-poster-ink': selectedTemplate.textColor,
}}
>
<h2>{posterConfig?.slogan || t('邀请好友,共享AI')}</h2>
<p className='pm-poster-subtitle'>
{posterConfig?.sub_slogan || t('注册即可获得免费额度')}
</p>
<h3
className='text-lg font-bold mb-6 drop-shadow-sm'
style={{ color: selectedTemplate.textColor }}
>
{systemName}
</h3>
<div className='bg-white rounded-xl p-3 shadow-2xl'>
<h3>{systemName}</h3>
<div className='pm-poster-qr'>
<QRCodeCanvas
id='poster-qrcode'
value={affLink || 'https://example.com'}
value={affLink}
size={130}
level='H'
includeMargin={false}
marginSize={2}
/>
</div>
<p
className='text-xs mt-3 opacity-90'
style={{ color: selectedTemplate.textColor }}
>
{t('扫码注册')}
<p>{t('扫码注册')}</p>
<p className='pm-poster-code'>
{t('邀请码')}: {affCode}
</p>
<p className='pm-poster-footer'>
{posterConfig?.footer_text || t('长按识别二维码,立即体验AI')}
</p>
<div
className='mt-2 px-4 py-1.5 rounded-full'
style={{ backgroundColor: 'rgba(255,255,255,0.2)' }}
>
<p
className='text-sm font-bold'
style={{ color: selectedTemplate.textColor }}
>
{t('邀请码')}: {affCode}
</p>
</div>
<div className='absolute bottom-6 left-0 right-0 text-center'>
<div
className='h-px mx-6 mb-3 opacity-30'
style={{ backgroundColor: selectedTemplate.textColor }}
/>
<p
className='text-xs opacity-80'
style={{ color: selectedTemplate.textColor }}
>
{posterConfig?.footer_text || t('长按识别二维码,立即体验AI')}
</p>
</div>
</div>
</div>
{/* 隐藏的 canvas 用于导出 */}
<canvas ref={canvasRef} style={{ display: 'none' }} />
{/* 操作按钮 */}
<div className='flex gap-3 mt-5 w-full'>
<Button
theme='solid'
type='primary'
icon={<ActionDownload size={16} />}
onClick={handleDownload}
loading={downloading}
className='flex-1 !bg-gradient-to-r !from-brand-from !to-brand-to !border-0 !rounded-xl !h-10'
>
{t('下载海报')}
</Button>
<Button
theme='light'
type='tertiary'
icon={<ActionCopy size={16} />}
onClick={handleCopyLink}
className='flex-1 !rounded-xl !h-10'
>
{t('复制链接')}
</Button>
</div>
<section className='pm-poster-options'>
<div className='pm-field'>
<Text strong id='promotion-template-label'>
{t('选择模板')}
</Text>
<Radio.Group
className='pm-template-list'
aria-labelledby='promotion-template-label'
value={selectedTemplate.id}
onChange={(event) =>
setSelectedTemplate(
DEFAULT_TEMPLATES.find(
(item) => item.id === event.target.value,
),
)
}
>
{DEFAULT_TEMPLATES.map((template) => (
<Radio key={template.id} value={template.id}>
<span className='pm-template-label'>
<span
className='pm-template-swatch'
style={{ '--pm-template-background': template.bgGradient }}
/>
{t(template.name)}
</span>
</Radio>
))}
</Radio.Group>
</div>
<div className='pm-poster-actions'>
<Button
type='primary'
icon={<ActionDownload size={16} aria-hidden />}
onClick={handleDownload}
loading={downloading}
>
{t('下载海报')}
</Button>
<Button
icon={<ActionCopy size={16} aria-hidden />}
onClick={handleCopyLink}
>
{t('复制链接')}
</Button>
</div>
<Text type='secondary' className='pm-share-hint'>
{posterConfig?.footer_text || t('长按识别二维码,立即体验AI')}
</Text>
</section>
<canvas ref={canvasRef} hidden />
</div>
);
return (
<Modal
title={
<div className='flex items-center gap-2'>
<div className='w-8 h-8 rounded-lg bg-gradient-to-br from-brand-from to-brand-to flex items-center justify-center shadow-lg shadow-brand/30'>
<Share2 size={16} className='text-white' />
</div>
<span className='font-bold text-lg'>{t('推广分享')}</span>
</div>
}
visible={visible}
title={t('推广分享')}
open={visible}
onCancel={onClose}
footer={null}
width={520}
width={800}
centered
className='promotion-modal'
bodyStyle={{ padding: '0 24px 24px' }}
>
<div style={{ minHeight: 540 }}>
{loading ? (
<div
className='flex flex-col justify-center items-center'
style={{ height: 540 }}
>
<div className='relative'>
<div className='w-16 h-16 rounded-full border-4 border-brand/10 dark:border-brand-deep' />
<div className='absolute inset-0 w-16 h-16 rounded-full border-4 border-brand border-t-transparent animate-spin' />
</div>
<span className='mt-4 text-gray-500 dark:text-gray-400'>
{t('加载中...')}
</span>
</div>
) : (
<>
{/* 查看邀请奖励规则 - 顶部显眼横幅 */}
<div
className='group mb-5 p-4 rounded-2xl cursor-pointer transition-all duration-300 hover:scale-[1.02] hover:shadow-xl relative overflow-hidden'
style={{
background: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)',
}}
onClick={() => {
onClose();
navigate('/user-center/invite');
}}
>
{/* 装饰元素 */}
<div className='absolute top-0 right-0 w-20 h-20 bg-white/10 rounded-full -translate-y-1/2 translate-x-1/2' />
<div className='absolute bottom-0 left-1/2 w-32 h-32 bg-white/5 rounded-full translate-y-1/2' />
{/* 动态光效 */}
<div className='absolute inset-0 bg-gradient-to-r from-transparent via-white/10 to-transparent -translate-x-full group-hover:translate-x-full transition-transform duration-1000' />
<div className='relative flex items-center justify-between'>
<div className='flex items-center gap-3'>
<div className='w-12 h-12 bg-white/20 backdrop-blur-sm rounded-xl flex items-center justify-center shadow-lg'>
<Gift size={22} className='text-white' />
</div>
<div>
<div className='text-white font-bold text-base flex items-center gap-2'>
{t('查看邀请奖励规则')}
<Sparkles
size={14}
className='text-amber-300 animate-pulse'
/>
</div>
<div className='text-white/80 text-sm mt-0.5'>
{t('了解返佣比例和奖励详情')}
</div>
</div>
</div>
<div className='flex items-center gap-1 text-white/90 group-hover:translate-x-1 transition-transform'>
<span className='text-xs font-medium hidden sm:block'>
{t('立即查看')}
</span>
<ChevronRight size={20} />
</div>
</div>
{/* 底部小标签 */}
<div className='flex gap-2 mt-3'>
<span className='text-xs bg-white/20 backdrop-blur-sm text-white px-2 py-1 rounded-full flex items-center gap-1'>
<Coins size={12} />
{t('消费返佣')}
</span>
<span className='text-xs bg-white/20 backdrop-blur-sm text-white px-2 py-1 rounded-full flex items-center gap-1'>
<TrendingUp size={12} />
{t('额度奖励')}
</span>
</div>
</div>
{/* Tab 导航 */}
{loading ? (
<div className='pm-loading' aria-label={t('加载中...')}>
<Skeleton active paragraph={{ rows: 7 }} />
</div>
) : (
<>
{affLink ? (
<Tabs
activeKey={activeTab}
onChange={setActiveTab}
className='promotion-tabs'
>
<TabPane
tab={
<span className='flex items-center gap-2 px-2'>
<Monitor size={16} />
<span className='font-medium'>{t('链接分享')}</span>
</span>
}
itemKey='link'
>
<div className='pt-4'>{renderLinkMode()}</div>
</TabPane>
<TabPane
tab={
<span className='flex items-center gap-2 px-2'>
<Smartphone size={16} />
<span className='font-medium'>{t('海报分享')}</span>
</span>
}
itemKey='poster'
>
<div className='pt-4'>{renderPosterMode()}</div>
</TabPane>
</Tabs>
</>
)}
</div>
items={[
{
key: 'link',
label: (
<span className='pm-tab-label'>
<Monitor size={16} aria-hidden />
{t('链接分享')}
</span>
),
children: renderLinkMode(),
},
{
key: 'poster',
label: (
<span className='pm-tab-label'>
<Smartphone size={16} aria-hidden />
{t('海报分享')}
</span>
),
children: renderPosterMode(),
},
]}
/>
) : (
<Alert
type='warning'
showIcon
title={t('邀请链接获取中,请稍后')}
/>
)}
<button
type='button'
className='pm-rewards'
onClick={() => {
onClose();
navigate('/user-center/invite');
}}
>
<span className='pm-rewards-icon'>
<Gift size={20} aria-hidden />
</span>
<span className='pm-rewards-copy'>
<strong>{t('查看邀请奖励规则')}</strong>
<span>{t('了解返佣比例和奖励详情')}</span>
</span>
<ChevronRight size={18} aria-hidden />
</button>
</>
)}
</Modal>
);
};