Files
tangzhuan-yu/frontend/App.tsx
T
jinghui fea5aee0cb v3.6.15: 使用说明页导航吸顶浮动 + 页面宽度自适应全屏
- 根因修复: main 上的 overflow-y:auto 把 sticky 锁死(自身不滚动, 滚动在 document), 去掉后吸顶恢复
- 使用说明页包裹层去掉 max-w-[1320px], 改 w-full 铺满(仅 help 页, 其他页保持原宽度)
- 导航移动端 nav 自身 sticky top-14(停在 header 下沿), 桌面端内层卡片 lg:sticky lg:top-2
- 锚点 scroll-mt-32 lg:scroll-mt-4, 跳转不被吸顶导航遮挡
- 顺带修上一轮中断遗留: ItemList 引用已删的 showOffShelf 会 ReferenceError, 改接 statusFilter
2026-11-16 22:57:49 +08:00

666 lines
30 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import React, { Suspense, lazy, useState, useEffect } from 'react';
import Sidebar from './components/Sidebar';
import GlobalFeedback from './components/GlobalFeedback';
import AnnouncementBanner from './components/AnnouncementBanner';
import ThemeToggle from './components/ThemeToggle';
import CaptchaInput from './components/CaptchaInput';
import { useCaptcha } from './lib/useCaptcha';
import { validateEmail, validatePassword, validateUsername } from './lib/authValidation';
import { login, verifyToken, getPublicSettings, register, sendVerificationCode } from './services/api';
import { ShieldCheck, ArrowRight, Loader2, User, Lock, Menu, Mail, KeyRound, CheckCircle2 } from 'lucide-react';
const Dashboard = lazy(() => import('./components/Dashboard'));
const AccountList = lazy(() => import('./components/AccountList'));
const OrderList = lazy(() => import('./components/OrderList'));
const CardList = lazy(() => import('./components/CardList'));
const ItemList = lazy(() => import('./components/ItemList'));
const ProductAutomation = lazy(() => import('./components/ProductAutomation'));
const AIReply = lazy(() => import('./components/AIReply'));
const Settings = lazy(() => import('./components/Settings'));
const Keywords = lazy(() => import('./components/Keywords'));
const MessageManagement = lazy(() => import('./components/MessageManagement'));
const NotificationsAndLogs = lazy(() => import('./components/NotificationsAndLogs'));
const UserManagement = lazy(() => import('./components/UserManagement'));
const About = lazy(() => import('./components/About'));
const BuyerInteraction = lazy(() => import('./components/BuyerInteraction'));
const Resell = lazy(() => import('./components/Resell'));
const HotList = lazy(() => import('./components/HotList'));
const PeerShops = lazy(() => import('./components/PeerShops'));
const PriceWatch = lazy(() => import('./components/PriceWatch'));
const Help = lazy(() => import('./components/Help'));
const PageLoader = () => (
<div className="page-loading">
<Loader2 className="h-5 w-5 animate-spin" />
<span>正在加载页面</span>
</div>
);
const pageLabels: Record<string, string> = {
dashboard: '总览',
accounts: '账号管理',
items: '商品与发货',
resell: '一键转卖',
hotlist: '实时热卖榜',
peershops: '同行热卖店铺',
pricewatch: '价格监控',
orders: '订单管理',
'buyer-interaction': '买家互动',
cards: '卡密库存',
messages: '消息中心',
'auto-reply': '自动回复',
'ai-reply': 'AI 回复',
'product-automation': '商品自动化',
notifications: '通知与日志',
settings: '系统设置',
users: '用户管理',
about: '关于',
help: '使用说明',
};
// 系统级页面仅管理员可用;普通用户 localStorage 里残留这些 tab 时切回总览
const ADMIN_ONLY_TABS = ['settings', 'users'];
const App: React.FC = () => {
const [isLoggedIn, setIsLoggedIn] = useState(false);
const [activeTab, setActiveTab] = useState(() => localStorage.getItem('active_page') || 'dashboard');
const [checkingAuth, setCheckingAuth] = useState(true);
const [username, setUsername] = useState('');
const [password, setPassword] = useState('');
const [loginLoading, setLoginLoading] = useState(false);
const [loginError, setLoginError] = useState('');
// 注册成功后回到登录页时的提示
const [loginNotice, setLoginNotice] = useState('');
const [mobileMenuOpen, setMobileMenuOpen] = useState(false);
const [isAdmin, setIsAdmin] = useState(false);
// 注册相关。是否显示入口由后台「允许用户注册」控制,
// 是否需要填验证码由后台「注册邮箱验证」控制(没配 SMTP 时可以关掉)。
const [authMode, setAuthMode] = useState<'login' | 'register'>('login');
const [allowRegister, setAllowRegister] = useState(false);
const [needEmailCode, setNeedEmailCode] = useState(true);
const [regForm, setRegForm] = useState({ username: '', email: '', password: '', code: '' });
const [regLoading, setRegLoading] = useState(false);
const [regError, setRegError] = useState('');
const [regNotice, setRegNotice] = useState('');
const [codeSending, setCodeSending] = useState(false);
const [codeCountdown, setCodeCountdown] = useState(0);
// 图形验证码:注册发码前必填;登录仅在连续失败被后端要求时出现
const regCaptcha = useCaptcha();
const loginCaptcha = useCaptcha();
// 切到注册页时拉一张新图(离开登录态图形码随 required 重置)
useEffect(() => {
if (authMode === 'register') void regCaptcha.refresh();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [authMode]);
useEffect(() => {
getPublicSettings()
.then(s => {
setAllowRegister(String(s.registration_enabled) === 'true');
setNeedEmailCode(String(s.email_verification_enabled ?? 'true') !== 'false');
})
.catch(() => setAllowRegister(false));
}, []);
// 验证码重发倒计时
useEffect(() => {
if (codeCountdown <= 0) return;
const timer = setTimeout(() => setCodeCountdown(codeCountdown - 1), 1000);
return () => clearTimeout(timer);
}, [codeCountdown]);
const handleSendCode = async () => {
if (!regForm.email.trim()) {
setRegError('请先填写邮箱');
return;
}
// 后端强制图形验证码通过后才会发邮箱码(防刷发件资源)
if (!regCaptcha.code.trim()) {
setRegError('请先输入图形验证码');
return;
}
setCodeSending(true);
setRegError('');
setRegNotice('');
try {
const res = await sendVerificationCode(regForm.email.trim(), 'register', {
session_id: regCaptcha.sessionId,
code: regCaptcha.code.trim(),
});
if (res?.success === false) {
// 多半是没配 SMTP,直接把后端原因透出来,省得对着"发送失败"猜
setRegError(res.message || '验证码发送失败,请确认邮件服务已配置');
// 图形码一次性,无论成败都换新图
void regCaptcha.refresh();
return;
}
setRegNotice('验证码已发送,请查收邮箱');
setCodeCountdown(60);
void regCaptcha.refresh();
} catch (err) {
setRegError(err instanceof Error ? err.message : '验证码发送失败');
void regCaptcha.refresh();
} finally {
setCodeSending(false);
}
};
const handleRegister = async (e: React.FormEvent) => {
e.preventDefault();
setRegError('');
setRegNotice('');
// 与后端同一套规则/文案(lib/authValidation.ts)
for (const [ok, reason] of [
validateUsername(regForm.username.trim()),
validateEmail(regForm.email.trim()),
validatePassword(regForm.password),
]) {
if (!ok) {
setRegError(reason);
return;
}
}
if (needEmailCode && !regForm.code.trim()) {
setRegError('请填写邮箱验证码');
return;
}
setRegLoading(true);
try {
const res = await register({
username: regForm.username.trim(),
email: regForm.email.trim(),
password: regForm.password,
...(needEmailCode ? { verification_code: regForm.code.trim() } : {}),
});
if (res?.success) {
// 注册成功后回到登录页,并把用户名带过去,少填一次
setUsername(regForm.username.trim());
setPassword('');
setRegForm({ username: '', email: '', password: '', code: '' });
setAuthMode('login');
setLoginError('');
setRegNotice('');
setLoginNotice('注册成功,请使用新账号登录');
} else {
setRegError(res?.message || '注册失败');
}
} catch (err) {
setRegError(err instanceof Error ? err.message : '注册失败,请稍后重试');
} finally {
setRegLoading(false);
}
};
// Check auth on mount
useEffect(() => {
const token = localStorage.getItem('auth_token');
if (token) {
verifyToken()
.then(result => {
if (!result.authenticated) {
localStorage.removeItem('auth_token');
return;
}
setIsAdmin(Boolean(result.is_admin));
setUsername(result.username || '');
setIsLoggedIn(true);
})
.catch(() => localStorage.removeItem('auth_token'))
.finally(() => setCheckingAuth(false));
} else {
setCheckingAuth(false);
}
const handleLogout = () => setIsLoggedIn(false);
window.addEventListener('auth:logout', handleLogout);
return () => window.removeEventListener('auth:logout', handleLogout);
}, []);
useEffect(() => {
localStorage.setItem('active_page', activeTab);
}, [activeTab]);
// 普通用户不能停留在系统级页面(入口已隐藏,这里兜底清掉本地记忆的 tab)
useEffect(() => {
if (!isAdmin && ADMIN_ONLY_TABS.includes(activeTab)) setActiveTab('dashboard');
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isAdmin]);
const handleLogin = async (e: React.FormEvent) => {
e.preventDefault();
setLoginLoading(true);
setLoginError('');
try {
// 连续失败被后端要求后,随请求带上图形验证码
const res = await login({
username,
password,
...(loginCaptcha.required ? {
captcha_session_id: loginCaptcha.sessionId,
captcha_code: loginCaptcha.code.trim(),
} : {}),
});
if (res.success && res.token) {
localStorage.setItem('auth_token', res.token);
setIsAdmin(Boolean(res.is_admin));
setUsername(res.username || username);
setIsLoggedIn(true);
} else {
setLoginError(res.message || '账号或密码错误');
if (res.captcha_required) {
// 触发防爆破:下一次登录必须先过图形验证
loginCaptcha.setRequired(true);
void loginCaptcha.refresh();
}
}
} catch (err) {
setLoginError(err instanceof Error ? err.message : '登录失败,请稍后重试');
} finally {
setLoginLoading(false);
}
};
if (checkingAuth) {
return (
<div className="min-h-screen flex items-center justify-center bg-[var(--app-bg)]">
<div className="flex items-center gap-3 text-sm font-semibold text-[var(--text-muted)]">
<Loader2 className="h-5 w-5 animate-spin text-[var(--brand-text)]" />
正在验证登录状态
</div>
</div>
);
}
// Login Screen Component
if (!isLoggedIn) {
return (
<div className="relative min-h-screen bg-[var(--app-bg)] p-4 font-sans text-[var(--text)] sm:p-6">
<ThemeToggle compact className="absolute right-4 top-4 z-10 sm:right-6 sm:top-6" />
<div className="mx-auto flex min-h-[calc(100vh-2rem)] max-w-5xl items-center justify-center sm:min-h-[calc(100vh-3rem)]">
<div className="grid w-full overflow-hidden rounded-3xl bg-[var(--surface)] lg:grid-cols-[1.05fr_0.95fr]"
style={{ border: '1px solid var(--border)', boxShadow: 'var(--shadow-lg)' }}>
{/* 品牌侧:黄色渐变作为整站第一印象 */}
<div
className="theme-brand-panel hidden min-h-[560px] flex-col justify-between p-10 lg:flex"
style={{ background: 'linear-gradient(155deg, #fff8d1 0%, #ffe566 55%, #ffe100 100%)' }}
>
<div>
<div className="flex h-14 w-14 items-center justify-center rounded-2xl bg-white/70 backdrop-blur">
<span className="text-2xl font-black text-[#2a2416]">躺</span>
</div>
<p className="mt-7 text-xs font-bold tracking-widest text-[#8a6300]">TANGZHUAN YU</p>
<h1 className="mt-2 max-w-md text-3xl font-extrabold leading-tight text-[#2a2416]">
躺赚鱼
</h1>
<p className="mt-4 max-w-md text-sm leading-7 text-[#6b5200]">
统一处理账号、商品、订单、消息、回复和自动发货。
</p>
</div>
<div className="grid grid-cols-2 gap-3">
{['账号与商品同步', '订单与发货处理', '消息与自动回复', '通知与运行日志'].map(item => (
<div
key={item}
className="rounded-2xl bg-white/70 px-4 py-3 text-xs font-bold text-[#544c39] backdrop-blur"
>
{item}
</div>
))}
</div>
</div>
<div className="flex min-h-[500px] items-center p-7 sm:p-10">
<div className="mx-auto w-full max-w-sm animate-fade-in">
<div className="mb-8">
<div
className="mb-5 flex h-14 w-14 items-center justify-center rounded-2xl lg:hidden"
style={{
background: 'linear-gradient(140deg, var(--brand-300), var(--brand))',
boxShadow: 'var(--shadow-brand)',
}}
>
<span className="text-xl font-black text-[#2a2416]">躺</span>
</div>
<h2 className="text-2xl font-extrabold text-gray-900">
{authMode === 'login' ? '登录管理后台' : '注册新账号'}
</h2>
<p className="mt-2 text-sm text-gray-500">
{authMode === 'login' ? '使用管理员账号进入工作台' : '创建账号后即可登录工作台'}
</p>
</div>
{authMode === 'login' && (
<form onSubmit={handleLogin} className="space-y-5">
<div className="space-y-4">
<label className="block">
<span className="mb-1.5 block text-xs font-bold text-gray-600">管理员账号</span>
<div className="relative group">
<User className="absolute left-3.5 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400 group-focus-within:text-gray-700" />
<input
type="text"
placeholder="请输入账号"
value={username}
onChange={e => setUsername(e.target.value)}
autoComplete="username"
required
className="ios-input h-11 w-full rounded-md py-2.5 pl-10 pr-4 text-sm"
/>
</div>
</label>
<label className="block">
<span className="mb-1.5 block text-xs font-bold text-gray-600">密码</span>
<div className="relative group">
<Lock className="absolute left-3.5 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400 group-focus-within:text-gray-700" />
<input
type="password"
placeholder="请输入密码"
value={password}
onChange={e => setPassword(e.target.value)}
autoComplete="current-password"
required
className="ios-input h-11 w-full rounded-md py-2.5 pl-10 pr-4 text-sm"
/>
</div>
</label>
{loginCaptcha.required && (
<CaptchaInput
image={loginCaptcha.image}
code={loginCaptcha.code}
onCodeChange={loginCaptcha.setCode}
onRefresh={() => void loginCaptcha.refresh()}
/>
)}
</div>
{loginNotice && (
<div role="status" className="flex items-center gap-2 rounded-md border border-green-200 bg-green-50 p-3 text-sm font-semibold text-green-700">
<CheckCircle2 className="h-4 w-4 shrink-0" /> {loginNotice}
</div>
)}
{loginError && (
<div role="alert" className="flex items-center gap-2 rounded-md border border-red-200 bg-red-50 p-3 text-sm font-semibold text-red-700">
<ShieldCheck className="h-4 w-4 shrink-0" /> {loginError}
</div>
)}
<button
type="submit"
disabled={loginLoading}
className="ios-btn-primary flex h-11 w-full items-center justify-center gap-2 rounded-md text-sm disabled:opacity-70"
>
{loginLoading ? <Loader2 className="h-4 w-4 animate-spin" /> : <>登录 <ArrowRight className="h-4 w-4" /></>}
</button>
</form>
)}
{authMode === 'register' && (
<form onSubmit={handleRegister} className="space-y-5">
<div className="space-y-4">
<label className="block">
<span className="mb-1.5 block text-xs font-bold text-gray-600">账号</span>
<div className="relative group">
<User className="absolute left-3.5 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400 group-focus-within:text-gray-700" />
<input
type="text"
placeholder="设置登录账号"
value={regForm.username}
onChange={e => setRegForm({ ...regForm, username: e.target.value })}
autoComplete="username"
required
className="ios-input h-11 w-full rounded-md py-2.5 pl-10 pr-4 text-sm"
/>
</div>
</label>
<label className="block">
<span className="mb-1.5 block text-xs font-bold text-gray-600">邮箱</span>
<div className="relative group">
<Mail className="absolute left-3.5 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400 group-focus-within:text-gray-700" />
<input
type="email"
placeholder="用于找回账号"
value={regForm.email}
onChange={e => setRegForm({ ...regForm, email: e.target.value })}
autoComplete="email"
required
className="ios-input h-11 w-full rounded-md py-2.5 pl-10 pr-4 text-sm"
/>
</div>
</label>
<label className="block">
<span className="mb-1.5 block text-xs font-bold text-gray-600">密码</span>
<div className="relative group">
<Lock className="absolute left-3.5 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400 group-focus-within:text-gray-700" />
<input
type="password"
placeholder="至少 8 位,含字母和数字"
value={regForm.password}
onChange={e => setRegForm({ ...regForm, password: e.target.value })}
autoComplete="new-password"
required
className="ios-input h-11 w-full rounded-md py-2.5 pl-10 pr-4 text-sm"
/>
</div>
</label>
{needEmailCode && (
<>
<CaptchaInput
image={regCaptcha.image}
code={regCaptcha.code}
onCodeChange={regCaptcha.setCode}
onRefresh={() => void regCaptcha.refresh()}
/>
<label className="block">
<span className="mb-1.5 block text-xs font-bold text-gray-600">邮箱验证码</span>
<div className="flex gap-2">
<div className="relative group flex-1">
<KeyRound className="absolute left-3.5 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400 group-focus-within:text-gray-700" />
<input
type="text"
placeholder="请输入验证码"
value={regForm.code}
onChange={e => setRegForm({ ...regForm, code: e.target.value })}
className="ios-input h-11 w-full rounded-md py-2.5 pl-10 pr-4 text-sm"
/>
</div>
<button
type="button"
onClick={() => void handleSendCode()}
disabled={codeSending || codeCountdown > 0}
className="ios-btn-secondary h-11 shrink-0 rounded-md px-3 text-xs font-bold disabled:opacity-60"
>
{codeCountdown > 0 ? `${codeCountdown}s` : codeSending ? '发送中' : '获取验证码'}
</button>
</div>
</label>
</>
)}
</div>
{regNotice && (
<div role="status" className="flex items-center gap-2 rounded-md border border-green-200 bg-green-50 p-3 text-sm font-semibold text-green-700">
<CheckCircle2 className="h-4 w-4 shrink-0" /> {regNotice}
</div>
)}
{regError && (
<div role="alert" className="flex items-center gap-2 rounded-md border border-red-200 bg-red-50 p-3 text-sm font-semibold text-red-700">
<ShieldCheck className="h-4 w-4 shrink-0" /> {regError}
</div>
)}
<button
type="submit"
disabled={regLoading}
className="ios-btn-primary flex h-11 w-full items-center justify-center gap-2 rounded-md text-sm disabled:opacity-70"
>
{regLoading ? <Loader2 className="h-4 w-4 animate-spin" /> : <>注册 <ArrowRight className="h-4 w-4" /></>}
</button>
</form>
)}
{allowRegister && (
<div className="mt-5 text-center text-xs text-gray-500">
{authMode === 'login' ? (
<>还没有账号?
<button
type="button"
onClick={() => { setAuthMode('register'); setLoginError(''); setLoginNotice(''); }}
className="ml-1 font-bold text-[var(--brand-text)] hover:underline"
>
注册新账号
</button>
</>
) : (
<>已有账号?
<button
type="button"
onClick={() => { setAuthMode('login'); setRegError(''); setRegNotice(''); }}
className="ml-1 font-bold text-[var(--brand-text)] hover:underline"
>
返回登录
</button>
</>
)}
</div>
)}
<p className="mt-7 border-t border-gray-100 pt-5 text-xs font-medium text-gray-400">
更多开源应用:
<a href="https://nav.88531.cn" target="_blank" rel="noopener noreferrer" className="text-[var(--brand-text)] hover:underline">
https://nav.88531.cn
</a>
</p>
</div>
</div>
</div>
</div>
</div>
);
}
return (
<div className="flex min-h-screen bg-[var(--app-bg)] text-[var(--text)]">
<GlobalFeedback />
<Sidebar
activeTab={activeTab}
setActiveTab={(tab) => {
setActiveTab(tab);
setMobileMenuOpen(false);
}}
mobileOpen={mobileMenuOpen}
onMobileClose={() => setMobileMenuOpen(false)}
isAdmin={isAdmin}
username={isLoggedIn ? username : ''}
onUsernameChange={setUsername}
onLogout={() => {
localStorage.removeItem('auth_token');
setIsAdmin(false);
setIsLoggedIn(false);
}}
/>
<main className="min-h-screen min-w-0 flex-1 lg:ml-[248px]">
<header className="sticky top-0 z-20 flex h-14 items-center gap-3 border-b border-[var(--border)] bg-[var(--surface)] px-4 lg:hidden">
<button
type="button"
onClick={() => setMobileMenuOpen(true)}
className="p-2 -ml-2 rounded-md hover:bg-gray-100"
title="打开导航"
aria-label="打开导航"
>
<Menu className="w-5 h-5" />
</button>
<div className="min-w-0">
<p className="truncate text-sm font-bold">{pageLabels[activeTab] || '躺赚鱼'}</p>
<p className="text-[11px] text-gray-400">躺赚鱼</p>
</div>
<ThemeToggle compact className="ml-auto" />
</header>
{activeTab !== 'messages' && <AnnouncementBanner />}
<div className={
activeTab === 'messages'
? 'h-[calc(100vh-3.5rem)] lg:h-screen overflow-hidden'
: activeTab === 'help'
// 使用说明页信息密度低、要按屏宽铺满阅读,不再锁 1320px
? 'w-full p-4 pb-10 sm:p-6 lg:p-8'
: 'mx-auto max-w-[1320px] p-4 pb-10 sm:p-6 lg:p-8'
}>
<section hidden={activeTab !== 'dashboard'}>
<Suspense fallback={activeTab === 'dashboard' ? <PageLoader /> : null}><Dashboard /></Suspense>
</section>
<section hidden={activeTab !== 'accounts'}>
<Suspense fallback={activeTab === 'accounts' ? <PageLoader /> : null}><AccountList /></Suspense>
</section>
<section hidden={activeTab !== 'items'}>
<Suspense fallback={activeTab === 'items' ? <PageLoader /> : null}><ItemList /></Suspense>
</section>
<section hidden={activeTab !== 'resell'}>
<Suspense fallback={activeTab === 'resell' ? <PageLoader /> : null}><Resell /></Suspense>
</section>
<section hidden={activeTab !== 'hotlist'}>
<Suspense fallback={activeTab === 'hotlist' ? <PageLoader /> : null}><HotList /></Suspense>
</section>
<section hidden={activeTab !== 'peershops'}>
<Suspense fallback={activeTab === 'peershops' ? <PageLoader /> : null}><PeerShops /></Suspense>
</section>
<section hidden={activeTab !== 'pricewatch'}>
<Suspense fallback={activeTab === 'pricewatch' ? <PageLoader /> : null}><PriceWatch /></Suspense>
</section>
<section hidden={activeTab !== 'product-automation'}>
<Suspense fallback={activeTab === 'product-automation' ? <PageLoader /> : null}><ProductAutomation /></Suspense>
</section>
<section hidden={activeTab !== 'orders'}>
<Suspense fallback={activeTab === 'orders' ? <PageLoader /> : null}><OrderList /></Suspense>
</section>
<section hidden={activeTab !== 'cards'}>
<Suspense fallback={activeTab === 'cards' ? <PageLoader /> : null}><CardList /></Suspense>
</section>
<section hidden={activeTab !== 'auto-reply'}>
<Suspense fallback={activeTab === 'auto-reply' ? <PageLoader /> : null}><Keywords mode="reply" /></Suspense>
</section>
<section hidden={activeTab !== 'ai-reply'}>
<Suspense fallback={activeTab === 'ai-reply' ? <PageLoader /> : null}><AIReply /></Suspense>
</section>
<section hidden={activeTab !== 'messages'} className="h-full min-h-0">
<Suspense fallback={activeTab === 'messages' ? <PageLoader /> : null}>
<MessageManagement isActive={activeTab === 'messages'} />
</Suspense>
</section>
<section hidden={activeTab !== 'notifications'}>
<Suspense fallback={activeTab === 'notifications' ? <PageLoader /> : null}>
<NotificationsAndLogs isAdmin={isAdmin} />
</Suspense>
</section>
{isAdmin && (
<section hidden={activeTab !== 'users'}>
<Suspense fallback={activeTab === 'users' ? <PageLoader /> : null}><UserManagement /></Suspense>
</section>
)}
{/* 系统设置页面含 SMTP/注册开关等系统级配置,普通用户不挂载(后端接口同样只放行业务白名单) */}
{isAdmin && (
<section hidden={activeTab !== 'settings'}>
<Suspense fallback={activeTab === 'settings' ? <PageLoader /> : null}><Settings /></Suspense>
</section>
)}
<section hidden={activeTab !== 'buyer-interaction'}>
<Suspense fallback={activeTab === 'buyer-interaction' ? <PageLoader /> : null}><BuyerInteraction /></Suspense>
</section>
<section hidden={activeTab !== 'about'}>
<Suspense fallback={activeTab === 'about' ? <PageLoader /> : null}><About /></Suspense>
</section>
<section hidden={activeTab !== 'help'}>
<Suspense fallback={activeTab === 'help' ? <PageLoader /> : null}><Help /></Suspense>
</section>
</div>
</main>
</div>
);
};
export default App;