From 433a982a203d173ab9ee899905a6cecf68191c5f Mon Sep 17 00:00:00 2001 From: zdl <3489966805@qq.com> Date: Wed, 22 Oct 2025 12:18:53 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=88=90=E5=8A=9F=E5=92=8C=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E5=BC=B9=E7=AA=97=E4=BB=8E=E9=A1=B6=E9=83=A8=E5=BC=B9?= =?UTF-8?q?=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.js | 11 +++++- src/components/Auth/AuthFormContent.js | 48 ++++++++++++++++++++++---- 2 files changed, 52 insertions(+), 7 deletions(-) diff --git a/src/App.js b/src/App.js index 94833388..718c171a 100755 --- a/src/App.js +++ b/src/App.js @@ -238,7 +238,16 @@ export default function App() { }, []); return ( - + diff --git a/src/components/Auth/AuthFormContent.js b/src/components/Auth/AuthFormContent.js index 562cdb9a..085fc3c9 100644 --- a/src/components/Auth/AuthFormContent.js +++ b/src/components/Auth/AuthFormContent.js @@ -30,6 +30,7 @@ import { import { FaLock, FaWeixin } from "react-icons/fa"; import { useAuth } from "../../contexts/AuthContext"; import { useAuthModal } from "../../contexts/AuthModalContext"; +import { useNotification } from "../../contexts/NotificationContext"; import { authService } from "../../services/authService"; import AuthHeader from './AuthHeader'; import VerificationCodeInput from './VerificationCodeInput'; @@ -66,6 +67,7 @@ export default function AuthFormContent() { const navigate = useNavigate(); const { checkSession } = useAuth(); const { handleLoginSuccess } = useAuthModal(); + const { showWelcomeGuide } = useNotification(); // 使用统一配置 const config = AUTH_CONFIG; @@ -85,7 +87,7 @@ export default function AuthFormContent() { // 响应式布局配置 const isMobile = useBreakpointValue({ base: true, md: false }); const stackDirection = useBreakpointValue({ base: "column", md: "row" }); - const stackSpacing = useBreakpointValue({ base: 4, md: 8 }); + const stackSpacing = useBreakpointValue({ base: 4, md: 2 }); // ✅ 桌面端从32px减至8px,更紧凑 // 表单数据 const [formData, setFormData] = useState({ @@ -202,10 +204,23 @@ export default function AuthFormContent() { throw new Error(data.error || '发送验证码失败'); } } catch (error) { - // ❌ 移除错误 toast,仅 console 输出 logger.api.error('POST', '/api/auth/send-verification-code', error, { credential: credential.substring(0, 3) + '****' + credential.substring(7) }); + + // ✅ 显示错误提示给用户 + toast({ + id: 'send-code-error', + title: "发送验证码失败", + description: error.message || "请稍后重试", + status: "error", + duration: 3000, + isClosable: true, + position: 'top', + containerStyle: { + zIndex: 10000, + } + }); } finally { if (isMountedRef.current) { setSendingCode(false); @@ -219,7 +234,7 @@ export default function AuthFormContent() { setIsLoading(true); try { - const { phone, verificationCode, nickname } = formData; + const { phone, verificationCode } = formData; // 表单验证 if (!phone || !verificationCode) { @@ -321,16 +336,37 @@ export default function AuthFormContent() { handleLoginSuccess({ phone }); }, config.features.successDelay); } + + // ⚡ 延迟 10 秒显示权限引导(温和、非侵入) + setTimeout(() => { + if (showWelcomeGuide) { + logger.info('AuthFormContent', '显示欢迎引导'); + showWelcomeGuide(); + } + }, 10000); } else { throw new Error(data.error || `${config.errorTitle}`); } } catch (error) { - // ❌ 移除错误 toast,仅 console 输出 const { phone, verificationCode } = formData; logger.error('AuthFormContent', 'handleSubmit', error, { phone: phone ? phone.substring(0, 3) + '****' + phone.substring(7) : 'N/A', hasVerificationCode: !!verificationCode }); + + // ✅ 显示错误提示给用户 + toast({ + id: 'auth-verification-error', + title: config.errorTitle, + description: error.message || "请检查验证码是否正确", + status: "error", + duration: 3000, + isClosable: true, + position: 'top', + containerStyle: { + zIndex: 10000, + } + }); } finally { if (isMountedRef.current) { setIsLoading(false); @@ -465,8 +501,8 @@ export default function AuthFormContent() { {/* 桌面端:右侧二维码扫描 */} {!isMobile && ( - -
+ {/* ✅ 桌面端让右侧自适应宽度 */} +
{/* ✅ 完全移除padding,最大化空间利用 */}