合并login
Change-Id: Ie06ed019cbb00d52e0b9e1f3c7a56c947b57a42c
diff --git a/Merge/front/src/pages/RegisterPage/RegisterPage.css b/Merge/front/src/pages/RegisterPage/RegisterPage.css
new file mode 100644
index 0000000..fc03361
--- /dev/null
+++ b/Merge/front/src/pages/RegisterPage/RegisterPage.css
@@ -0,0 +1,1027 @@
+/* 注册页面容器 */
+.register-container {
+ min-height: 100vh;
+ min-height: 100dvh; /* 动态视口高度,避免移动端地址栏影响 */
+ height: 100vh;
+ height: 100dvh;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ position: relative;
+ overflow: hidden;
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
+ 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
+ sans-serif;
+ /* 确保容器稳定定位 */
+ box-sizing: border-box;
+ margin: 0;
+ padding: 0;
+ /* 重置文本对齐 */
+ text-align: initial;
+}
+
+/* 小红书风格背景 */
+.register-background {
+ position: absolute;
+ top: 0;
+ left: 0;
+ right: 0;
+ bottom: 0;
+ background: #f8f8f8;
+ z-index: -1;
+}
+
+/* 注册内容区域 */
+.register-content {
+ width: 100%;
+ max-width: 500px; /* 增加桌面端最大宽度 */
+ padding: 0;
+ z-index: 1;
+ /* 确保内容稳定定位 */
+ box-sizing: border-box;
+ position: relative;
+ display: flex;
+ justify-content: center;
+}
+
+/* 小红书风格注册卡片 */
+.register-card {
+ background: #fff;
+ border-radius: 8px;
+ padding: 40px; /* 增加桌面端内边距 */
+ box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
+ border: 1px solid #e1e1e1;
+ width: 100%;
+ max-width: 450px; /* 增加桌面端卡片最大宽度 */
+ transition: none;
+}
+
+/* 注册头部 */
+.register-header {
+ text-align: center;
+ margin-bottom: 40px;
+}
+
+/* Logo样式 */
+.logo-section {
+ margin-bottom: 24px;
+}
+
+.logo-icon {
+ width: 60px;
+ height: 60px;
+ background: #ff2442;
+ border-radius: 12px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ font-size: 28px;
+ margin: 0 auto 16px;
+ box-shadow: 0 4px 12px rgba(255, 36, 66, 0.2);
+}
+
+.register-title {
+ font-size: 24px;
+ font-weight: 600;
+ color: #333;
+ margin: 0 0 12px 0;
+ text-align: center;
+}
+
+.register-title::after {
+ display: none;
+}
+
+.register-subtitle {
+ font-size: 14px;
+ color: #999;
+ margin: 0 0 32px 0;
+ font-weight: 400;
+ text-align: center;
+}
+
+/* 表单样式 */
+.register-form {
+ display: flex;
+ flex-direction: column;
+ gap: 20px;
+ width: 100%;
+}
+
+.form-group {
+ display: flex;
+ flex-direction: column;
+ gap: 6px;
+ width: 100%;
+ box-sizing: border-box;
+ margin-bottom: 2px;
+ position: relative; /* 为绝对定位的错误提示提供参考点 */
+}
+
+.form-group .input-wrapper {
+ width: 100%;
+ box-sizing: border-box;
+}
+
+.form-label {
+ font-size: 14px;
+ font-weight: 500;
+ color: #333;
+ margin-bottom: 8px;
+}
+
+.input-wrapper {
+ position: relative;
+ display: flex;
+ align-items: center;
+ width: 100%;
+ box-sizing: border-box;
+}
+
+.form-input {
+ width: 100% !important;
+ height: 44px;
+ padding: 12px 16px 12px 48px;
+ border: 1px solid #e1e1e1;
+ border-radius: 6px;
+ font-size: 14px;
+ transition: border-color 0.2s ease;
+ background: #fff;
+ color: #333;
+ box-sizing: border-box !important;
+ flex: 1;
+ min-width: 0;
+}
+
+/* 针对 Antd Input 组件的特定样式 */
+.form-input.ant-input,
+.form-input.ant-input-affix-wrapper {
+ width: 100% !important;
+ height: 44px !important;
+ border: 1px solid #e1e1e1 !important;
+ border-radius: 6px !important;
+ padding: 12px 48px 12px 48px !important;
+ font-size: 14px !important;
+ background: #fff !important;
+ color: #333 !important;
+ box-sizing: border-box !important;
+ flex: 1 !important;
+ min-width: 0 !important;
+ display: flex !important;
+ align-items: center !important;
+}
+
+.form-input.ant-input-affix-wrapper .ant-input {
+ width: 100% !important;
+ height: 100% !important;
+ padding: 0 !important;
+ border: none !important;
+ background: transparent !important;
+ flex: 1 !important;
+ min-width: 0 !important;
+ box-sizing: border-box !important;
+}
+
+.form-input:focus {
+ outline: none;
+ border-color: #ff2442;
+ box-shadow: none;
+ transform: none;
+}
+
+/* Antd Input focus 样式 */
+.form-input.ant-input:focus,
+.form-input.ant-input-affix-wrapper:focus,
+.form-input.ant-input-affix-wrapper-focused {
+ outline: none !important;
+ border-color: #ff2442 !important;
+ box-shadow: none !important;
+ transform: none !important;
+}
+
+.form-input::placeholder {
+ color: #9ca3af;
+}
+
+.input-icon {
+ position: absolute;
+ left: 16px;
+ top: 50%;
+ transform: translateY(-50%);
+ color: #9ca3af;
+ pointer-events: none;
+ transition: color 0.3s ease;
+ z-index: 2;
+}
+
+.form-input:focus + .input-icon {
+ color: #ff2442;
+}
+
+.password-toggle {
+ position: absolute;
+ right: 12px;
+ top: 50%;
+ transform: translateY(-50%);
+ background: none;
+ border: none;
+ color: #9ca3af;
+ cursor: pointer;
+ padding: 4px;
+ border-radius: 4px;
+ transition: all 0.3s ease;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ z-index: 2;
+ width: 24px;
+ height: 24px;
+}
+
+.password-toggle:hover {
+ color: #ff2442;
+ background-color: rgba(255, 36, 66, 0.1);
+}
+
+/* 邮箱验证码输入框容器 */
+.email-code-wrapper {
+ display: flex;
+ gap: 8px;
+ width: 100%;
+ box-sizing: border-box;
+ align-items: flex-start;
+}
+
+.email-code-input {
+ flex: 1;
+ min-width: 0;
+}
+
+.send-code-button {
+ height: 44px !important;
+ padding: 0 16px !important;
+ background: #ff2442 !important;
+ border-color: #ff2442 !important;
+ border-radius: 6px !important;
+ font-size: 14px !important;
+ font-weight: 500 !important;
+ white-space: nowrap !important;
+ flex-shrink: 0 !important;
+ min-width: 100px !important;
+ display: flex !important;
+ align-items: center !important;
+ justify-content: center !important;
+ transition: all 0.2s ease !important;
+ box-sizing: border-box !important;
+}
+
+.send-code-button:hover:not(:disabled) {
+ background: #d91e3a !important;
+ border-color: #d91e3a !important;
+ transform: none !important;
+ box-shadow: none !important;
+}
+
+.send-code-button:disabled {
+ background: #f5f5f5 !important;
+ border-color: #d9d9d9 !important;
+ color: #bfbfbf !important;
+ cursor: not-allowed !important;
+}
+
+.send-code-button.ant-btn-loading {
+ background: #ff2442 !important;
+ border-color: #ff2442 !important;
+ color: white !important;
+}
+
+/* 小红书风格注册按钮 */
+.register-button {
+ width: 100%;
+ height: 48px; /* 固定高度,防止布局变化 */
+ padding: 12px;
+ background: #ff2442;
+ color: white;
+ border: none;
+ border-radius: 6px;
+ font-size: 14px;
+ font-weight: 500;
+ cursor: pointer;
+ transition: background-color 0.2s ease;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ gap: 8px;
+ margin-top: 8px;
+ position: relative; /* 为绝对定位的加载状态做准备 */
+ box-sizing: border-box; /* 确保padding包含在总尺寸内 */
+ min-width: 0; /* 防止flex子元素造成宽度变化 */
+}
+
+.register-button:hover:not(:disabled) {
+ background: #d91e3a;
+ transform: none;
+ box-shadow: none;
+}
+
+.register-button:active:not(:disabled) {
+ transform: none;
+}
+
+.register-button:disabled {
+ background: #ccc;
+ cursor: not-allowed;
+ opacity: 0.8;
+}
+
+.register-button.loading {
+ background: #ff7b8a;
+ cursor: not-allowed;
+}
+
+.loading-spinner {
+ width: 16px;
+ height: 16px;
+ border: 2px solid rgba(255, 255, 255, 0.3);
+ border-radius: 50%;
+ border-top-color: #fff;
+ animation: spin 1s ease-in-out infinite;
+}
+
+@keyframes spin {
+ to { transform: rotate(360deg); }
+}
+
+/* 加载遮罩层 */
+.loading-overlay {
+ position: fixed;
+ top: 0;
+ left: 0;
+ right: 0;
+ bottom: 0;
+ background: rgba(0, 0, 0, 0.5);
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ z-index: 1000;
+ backdrop-filter: blur(4px);
+}
+
+.loading-content {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ gap: 16px;
+ background: white;
+ padding: 32px;
+ border-radius: 12px;
+ box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
+}
+
+.loading-spinner-large {
+ width: 40px;
+ height: 40px;
+ border: 4px solid rgba(255, 36, 66, 0.2);
+ border-radius: 50%;
+ border-top-color: #ff2442;
+ animation: spin 1s ease-in-out infinite;
+}
+
+.loading-text {
+ margin: 0;
+ color: #333;
+ font-size: 16px;
+ font-weight: 500;
+}
+
+/* 分隔线 */
+.register-divider {
+ position: relative;
+ text-align: center;
+ margin: 32px 0;
+ color: #9ca3af;
+ font-size: 14px;
+}
+
+.register-divider::before {
+ content: '';
+ position: absolute;
+ top: 50%;
+ left: 0;
+ right: 0;
+ height: 1px;
+ background: linear-gradient(to right, transparent, #e5e7eb, transparent);
+}
+
+.register-divider span {
+ background: rgba(255, 255, 255, 0.95);
+ padding: 0 16px;
+ position: relative;
+ z-index: 1;
+}
+
+/* 社交登录 */
+.social-login {
+ display: flex;
+ flex-direction: column;
+ gap: 12px;
+}
+
+.social-button {
+ width: 100%;
+ padding: 12px 16px;
+ border: 1px solid #e1e1e1;
+ border-radius: 6px;
+ background: white;
+ color: #333;
+ font-size: 14px;
+ font-weight: 400;
+ cursor: pointer;
+ transition: border-color 0.2s ease;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ gap: 8px;
+}
+
+.social-button:hover {
+ border-color: #ccc;
+}
+
+.social-button.google:hover {
+ border-color: #4285f4;
+ box-shadow: 0 4px 12px rgba(66, 133, 244, 0.2);
+}
+
+.social-button.github:hover {
+ border-color: #333;
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
+}
+
+.social-button.xiaohongshu:hover {
+ border-color: #ff2442;
+ box-shadow: 0 4px 12px rgba(255, 36, 66, 0.2);
+}
+
+/* 登录链接 */
+.login-link {
+ text-align: center;
+ margin-top: 20px;
+ padding-top: 20px;
+ border-top: 1px solid #e5e7eb;
+}
+
+.login-link p {
+ margin: 0;
+ font-size: 14px;
+ color: #64748b;
+}
+
+.login-link a {
+ color: #ff2442;
+ text-decoration: none;
+ font-weight: 500;
+ transition: color 0.2s ease;
+}
+
+.login-link a:hover {
+ color: #d91e3a;
+ text-decoration: underline;
+}
+
+/* 有左侧图标时的内边距调整 */
+.input-wrapper.has-icon .form-input {
+ padding-left: 48px !important;
+}
+
+.input-wrapper.has-icon .form-input.ant-input,
+.input-wrapper.has-icon .form-input.ant-input-affix-wrapper {
+ padding-left: 48px !important;
+}
+
+/* 有右侧切换按钮时的内边距调整 */
+.input-wrapper.has-toggle .form-input {
+ padding-right: 48px !important;
+}
+
+.input-wrapper.has-toggle .form-input.ant-input,
+.input-wrapper.has-toggle .form-input.ant-input-affix-wrapper {
+ padding-right: 48px !important;
+}
+
+/* 没有图标时的内边距调整 */
+.input-wrapper:not(.has-icon) .form-input {
+ padding-left: 16px !important;
+}
+
+.input-wrapper:not(.has-icon) .form-input.ant-input,
+.input-wrapper:not(.has-icon) .form-input.ant-input-affix-wrapper {
+ padding-left: 16px !important;
+}
+
+/* 没有切换按钮时的内边距调整 */
+.input-wrapper:not(.has-toggle) .form-input {
+ padding-right: 16px !important;
+}
+
+.input-wrapper:not(.has-toggle) .form-input.ant-input,
+.input-wrapper:not(.has-toggle) .form-input.ant-input-affix-wrapper {
+ padding-right: 16px !important;
+}
+
+/* 确保输入框内容完全填充 */
+.form-input.ant-input-affix-wrapper .ant-input-suffix {
+ position: absolute !important;
+ right: 12px !important;
+ top: 50% !important;
+ transform: translateY(-50%) !important;
+ margin: 0 !important;
+ padding: 0 !important;
+}
+
+.form-input.ant-input-affix-wrapper .ant-input-prefix {
+ position: absolute !important;
+ left: 16px !important;
+ top: 50% !important;
+ transform: translateY(-50%) !important;
+ margin: 0 !important;
+ padding: 0 !important;
+}
+
+/* 确保所有输入框完全填充其容器 */
+.form-group {
+ display: flex;
+ flex-direction: column;
+ gap: 8px;
+ width: 100%;
+ box-sizing: border-box;
+}
+
+.form-group .input-wrapper {
+ width: 100%;
+ box-sizing: border-box;
+}
+
+/* 防止输入框溢出容器 */
+.form-input,
+.form-input.ant-input,
+.form-input.ant-input-affix-wrapper {
+ max-width: 100% !important;
+ overflow: hidden !important;
+}
+
+/* 确保内部输入元素不会超出边界 */
+.form-input.ant-input-affix-wrapper .ant-input {
+ max-width: 100% !important;
+ overflow: hidden !important;
+ text-overflow: ellipsis !important;
+}
+
+/* 精细间距控制 */
+.register-header + .register-form {
+ margin-top: -4px;
+}
+
+.register-form .form-group:not(:last-child) {
+ margin-bottom: 2px;
+}
+
+.register-form .form-group:last-of-type {
+ margin-bottom: 6px;
+}
+
+.register-button + .login-link {
+ margin-top: 14px;
+}
+
+/* 响应式设计 */
+@media (max-width: 768px) {
+ /* 重置body和html确保一致性 */
+ html, body {
+ height: 100%;
+ height: 100dvh;
+ margin: 0;
+ padding: 0;
+ overflow-x: hidden;
+ box-sizing: border-box;
+ }
+
+ .register-container {
+ padding: 16px;
+ align-items: center;
+ justify-content: center;
+ min-height: 100vh;
+ min-height: 100dvh; /* 动态视口高度 */
+ /* 强制重置可能影响定位的样式 */
+ margin: 0;
+ box-sizing: border-box;
+ /* 防止内容溢出影响布局 */
+ overflow-x: hidden;
+ overflow-y: auto;
+ /* 确保flexbox在所有移动设备上表现一致 */
+ -webkit-box-align: center;
+ -webkit-box-pack: center;
+ display: flex !important;
+ position: relative;
+ }
+
+ .register-content {
+ max-width: 100%;
+ padding: 20px;
+ /* 确保内容区域稳定 */
+ margin: 0 auto;
+ box-sizing: border-box;
+ /* 防止宽度计算问题 */
+ width: calc(100% - 40px);
+ max-width: 480px; /* 增加最大宽度 */
+ position: relative;
+ display: flex;
+ justify-content: center;
+ }
+
+ .register-card {
+ padding: 32px 28px; /* 增加内边距 */
+ border-radius: 16px;
+ /* 确保卡片稳定定位 */
+ margin: 0;
+ box-sizing: border-box;
+ width: 100%;
+ max-width: 450px; /* 增加卡片最大宽度 */
+ /* 防止backdrop-filter导致的渲染差异 */
+ will-change: auto;
+ position: relative;
+ /* 防止触摸操作影响布局 */
+ -webkit-touch-callout: none;
+ -webkit-user-select: none;
+ -moz-user-select: none;
+ -ms-user-select: none;
+ user-select: none;
+ -webkit-tap-highlight-color: transparent;
+ }
+
+ .register-title {
+ font-size: 24px;
+ }
+
+ .form-input {
+ width: 100% !important;
+ height: 44px !important;
+ padding: 12px 48px 12px 48px;
+ font-size: 16px; /* 防止iOS Safari缩放 */
+ box-sizing: border-box !important;
+ flex: 1 !important;
+ min-width: 0 !important;
+ }
+
+ .form-input.ant-input,
+ .form-input.ant-input-affix-wrapper {
+ width: 100% !important;
+ height: 44px !important;
+ padding: 12px 48px 12px 48px !important;
+ font-size: 16px !important;
+ box-sizing: border-box !important;
+ flex: 1 !important;
+ min-width: 0 !important;
+ }
+
+ .form-input.ant-input-affix-wrapper .ant-input {
+ width: 100% !important;
+ height: 100% !important;
+ padding: 0 !important;
+ border: none !important;
+ background: transparent !important;
+ flex: 1 !important;
+ min-width: 0 !important;
+ box-sizing: border-box !important;
+ }
+
+ .social-login {
+ gap: 10px;
+ }
+
+ .social-button {
+ padding: 12px 16px;
+ font-size: 14px;
+ }
+}
+
+@media (max-width: 480px) {
+ .register-container {
+ padding: 16px;
+ align-items: center;
+ justify-content: center;
+ min-height: 100vh;
+ min-height: 100dvh; /* 动态视口高度 */
+ /* 强制重置样式 */
+ margin: 0;
+ box-sizing: border-box;
+ position: relative;
+ /* 确保垂直居中 */
+ display: flex !important;
+ }
+
+ .register-content {
+ /* 更严格的尺寸控制 */
+ width: calc(100vw - 32px);
+ max-width: 420px; /* 增加最大宽度 */
+ padding: 16px;
+ margin: 0 auto;
+ box-sizing: border-box;
+ display: flex;
+ justify-content: center;
+ }
+
+ .register-card {
+ padding: 28px 24px; /* 增加内边距 */
+ border-radius: 12px;
+ /* 确保卡片完全稳定 */
+ margin: 0;
+ box-sizing: border-box;
+ width: 100%;
+ position: relative;
+ /* 防止变换导致的位置偏移 */
+ transform: none !important;
+ /* 防止触摸操作影响布局 */
+ -webkit-touch-callout: none;
+ -webkit-user-select: none;
+ -khtml-user-select: none;
+ -moz-user-select: none;
+ -ms-user-select: none;
+ user-select: none;
+ /* 防止点击时的高亮效果影响布局 */
+ -webkit-tap-highlight-color: transparent;
+ }
+
+ .register-title {
+ font-size: 22px;
+ }
+
+ .form-input {
+ width: 100% !important;
+ height: 44px !important;
+ padding: 12px 48px 12px 48px;
+ font-size: 16px; /* 防止iOS Safari缩放 */
+ box-sizing: border-box !important;
+ flex: 1 !important;
+ min-width: 0 !important;
+ }
+
+ .form-input.ant-input,
+ .form-input.ant-input-affix-wrapper {
+ width: 100% !important;
+ height: 44px !important;
+ padding: 12px 48px 12px 48px !important;
+ font-size: 16px !important;
+ box-sizing: border-box !important;
+ flex: 1 !important;
+ min-width: 0 !important;
+ }
+
+ .form-input.ant-input-affix-wrapper .ant-input {
+ width: 100% !important;
+ height: 100% !important;
+ padding: 0 !important;
+ border: none !important;
+ background: transparent !important;
+ flex: 1 !important;
+ min-width: 0 !important;
+ box-sizing: border-box !important;
+ }
+
+ .social-login {
+ gap: 10px;
+ }
+
+ .social-button {
+ padding: 12px 16px;
+ font-size: 14px;
+ }
+
+ /* 移动端优化 */
+ .background-pattern {
+ display: none;
+ }
+
+ /* 禁用可能影响位置的悬停效果 */
+ .register-card:hover {
+ transform: none !important;
+ }
+}
+
+/* 高对比度模式支持 */
+@media (prefers-contrast: high) {
+ .register-card {
+ background: white;
+ border: 2px solid #000;
+ }
+
+ .form-input {
+ border-color: #000;
+ }
+
+ .form-input:focus {
+ border-color: #0066cc;
+ box-shadow: 0 0 0 2px #0066cc;
+ }
+}
+
+/* 减少动画模式 */
+@media (prefers-reduced-motion: reduce) {
+ .background-pattern {
+ animation: none;
+ }
+
+ .register-card,
+ .form-input,
+ .register-button,
+ .social-button {
+ transition: none;
+ }
+}
+
+/* 深色模式支持 */
+@media (prefers-color-scheme: dark) {
+ .register-background {
+ background: linear-gradient(135deg, #1a202c 0%, #2d3748 100%);
+ }
+
+ .register-card {
+ background: rgba(26, 32, 44, 0.95);
+ border-color: rgba(255, 255, 255, 0.1);
+ }
+
+ .register-title {
+ color: #f7fafc;
+ }
+
+ .register-subtitle {
+ color: #a0aec0;
+ }
+
+ .form-label {
+ color: #e2e8f0;
+ }
+
+ .form-input {
+ background: #2d3748;
+ border-color: #4a5568;
+ color: #f7fafc;
+ }
+
+ .form-input:focus {
+ border-color: #ff2442;
+ }
+
+ .social-button {
+ background: #2d3748;
+ border-color: #4a5568;
+ color: #f7fafc;
+ }
+
+ .login-link {
+ border-color: #4a5568;
+ }
+
+ .login-link p {
+ color: #a0aec0;
+ }
+
+ /* 深色模式下的错误提示样式 */
+ .error-message {
+ background: rgba(26, 32, 44, 0.95);
+ color: #ff6b6b;
+ }
+}
+
+/* 错误提示样式 - 使用绝对定位避免影响布局 */
+.error-message {
+ position: absolute;
+ top: 95%;
+ left: 4px;
+ right: 4px;
+ font-size: 12px;
+ color: #ff4d4f;
+ margin-top: 4px;
+ display: flex;
+ align-items: center;
+ min-height: 16px;
+ animation: fadeInDown 0.3s ease-out;
+ font-weight: 400;
+ line-height: 1.2;
+ background: rgba(255, 255, 255, 0.95);
+ backdrop-filter: blur(4px);
+ padding: 2px 4px;
+ border-radius: 4px;
+ z-index: 10;
+ pointer-events: none; /* 避免干扰用户交互 */
+}
+
+@keyframes fadeInDown {
+ from {
+ opacity: 0;
+ transform: translateY(-8px);
+ }
+ to {
+ opacity: 1;
+ transform: translateY(0);
+ }
+}
+
+/* 输入框错误状态样式 */
+.form-input.input-error,
+.form-input.input-error.ant-input,
+.form-input.input-error.ant-input-affix-wrapper {
+ border-color: #ff4d4f !important;
+ box-shadow: 0 0 0 2px rgba(255, 77, 79, 0.1) !important;
+ transition: all 0.3s ease !important;
+}
+
+.form-input.input-error:focus,
+.form-input.input-error.ant-input:focus,
+.form-input.input-error.ant-input-affix-wrapper:focus,
+.form-input.input-error.ant-input-affix-wrapper-focused {
+ border-color: #ff4d4f !important;
+ box-shadow: 0 0 0 2px rgba(255, 77, 79, 0.2) !important;
+}
+
+/* 错误状态下的图标颜色 */
+.form-input.input-error .anticon {
+ color: #ff4d4f !important;
+}
+
+/* 确保表单组间距一致 */
+.form-group {
+ margin-bottom: 0px;
+}
+
+.form-group:last-of-type {
+ margin-bottom: 0px;
+}
+
+/* 错误弹窗样式 */
+.error-modal .ant-modal-header {
+ background: #fff;
+ border-bottom: 1px solid #f0f0f0;
+ padding: 16px 24px;
+}
+
+.error-modal .ant-modal-title {
+ color: #333;
+ font-weight: 600;
+ font-size: 16px;
+}
+
+.error-modal .ant-modal-body {
+ padding: 16px 24px 24px;
+}
+
+.error-modal .ant-modal-footer {
+ padding: 12px 24px 24px;
+ border-top: none;
+ text-align: center;
+}
+
+.error-modal .ant-btn-primary {
+ background: #ff2442;
+ border-color: #ff2442;
+ font-weight: 500;
+ height: 40px;
+ padding: 0 24px;
+ border-radius: 6px;
+ transition: all 0.2s ease;
+}
+
+.error-modal .ant-btn-primary:hover {
+ background: #d91e3a;
+ border-color: #d91e3a;
+ transform: translateY(-1px);
+ box-shadow: 0 4px 12px rgba(255, 36, 66, 0.3);
+}
+
+.error-modal .ant-modal-content {
+ border-radius: 12px;
+ overflow: hidden;
+ box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
+}
+
+/* 错误弹窗遮罩层 */
+.error-modal .ant-modal-mask {
+ background: rgba(0, 0, 0, 0.6);
+ backdrop-filter: blur(4px);
+}
+
+/* 错误弹窗动画 */
+.error-modal .ant-modal {
+ animation: errorModalSlideIn 0.3s ease-out;
+}
+
+@keyframes errorModalSlideIn {
+ from {
+ opacity: 0;
+ transform: translateY(-20px) scale(0.95);
+ }
+ to {
+ opacity: 1;
+ transform: translateY(0) scale(1);
+ }
+}
diff --git a/Merge/front/src/pages/RegisterPage/RegisterPage.js b/Merge/front/src/pages/RegisterPage/RegisterPage.js
new file mode 100644
index 0000000..836e1cf
--- /dev/null
+++ b/Merge/front/src/pages/RegisterPage/RegisterPage.js
@@ -0,0 +1,625 @@
+import React, { useState } from 'react';
+import { Link, useNavigate } from 'react-router-dom';
+import { Input, Button, message, Modal, Alert } from 'antd';
+import { MailOutlined, LockOutlined, UserOutlined, SafetyOutlined, ExclamationCircleOutlined, CheckCircleOutlined } from '@ant-design/icons';
+import { hashPassword } from '../../utils/crypto';
+import './RegisterPage.css';
+
+const baseURL = 'http://10.126.59.25:8082';
+
+const RegisterPage = () => {
+ const [formData, setFormData] = useState({
+ username: '',
+ email: '',
+ emailCode: '',
+ password: '',
+ confirmPassword: ''
+ });
+
+ const [errors, setErrors] = useState({
+ username: '',
+ email: '',
+ emailCode: '',
+ password: '',
+ confirmPassword: ''
+ });
+
+ const [emailCodeSent, setEmailCodeSent] = useState(false);
+ const [countdown, setCountdown] = useState(0);
+ const [sendingCode, setSendingCode] = useState(false);
+ const [isLoading, setIsLoading] = useState(false);
+ const [errorModal, setErrorModal] = useState({
+ visible: false,
+ title: '',
+ content: ''
+ });
+ const [successAlert, setSuccessAlert] = useState({
+ visible: false,
+ message: ''
+ });
+ const [emailCodeSuccessAlert, setEmailCodeSuccessAlert] = useState({
+ visible: false,
+ message: ''
+ });
+
+ const navigate = useNavigate();
+
+ // 显示错误弹窗
+ const showErrorModal = (title, content) => {
+ setErrorModal({
+ visible: true,
+ title: title,
+ content: content
+ });
+ };
+
+ // 关闭错误弹窗
+ const closeErrorModal = () => {
+ setErrorModal({
+ visible: false,
+ title: '',
+ content: ''
+ });
+ };
+
+ // 显示成功提示
+ const showSuccessAlert = (message) => {
+ setSuccessAlert({
+ visible: true,
+ message: message
+ });
+
+ // 3秒后自动隐藏
+ setTimeout(() => {
+ setSuccessAlert({
+ visible: false,
+ message: ''
+ });
+ }, 3000);
+ };
+
+ // 显示邮件验证码发送成功提示
+ const showEmailCodeSuccessAlert = (message) => {
+ setEmailCodeSuccessAlert({
+ visible: true,
+ message: message
+ });
+
+ // 5秒后自动隐藏
+ setTimeout(() => {
+ setEmailCodeSuccessAlert({
+ visible: false,
+ message: ''
+ });
+ }, 5000);
+ };
+
+ // 倒计时效果
+ React.useEffect(() => {
+ let timer;
+ if (countdown > 0) {
+ timer = setTimeout(() => {
+ setCountdown(countdown - 1);
+ }, 1000);
+ }
+ return () => clearTimeout(timer);
+ }, [countdown]);
+
+ // 发送邮箱验证码
+ const sendEmailCode = async () => {
+ // 验证邮箱格式
+ if (!formData.email || typeof formData.email !== 'string' || !formData.email.trim()) {
+ setErrors(prev => ({
+ ...prev,
+ email: '请先输入邮箱地址'
+ }));
+ return;
+ }
+
+ if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(formData.email)) {
+ setErrors(prev => ({
+ ...prev,
+ email: '请输入有效的邮箱地址'
+ }));
+ return;
+ }
+
+ setSendingCode(true);
+
+ try {
+ // 调用后端API发送验证码
+ const response = await fetch(baseURL + '/send-verification-code', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ body: JSON.stringify({
+ email: formData.email,
+ verification_type: 'register'
+ })
+ });
+
+ if (!response.ok) {
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
+ }
+
+ const result = await response.json();
+
+ if (result.success) {
+ showEmailCodeSuccessAlert('验证码已发送到您的邮箱');
+ setEmailCodeSent(true);
+ setCountdown(60); // 60秒倒计时
+
+ // 清除邮箱错误提示
+ setErrors(prev => ({
+ ...prev,
+ email: ''
+ }));
+ } else {
+ // 根据具体错误信息进行处理
+ const errorMessage = result.message || '发送验证码失败,请稍后再试';
+
+ if (errorMessage.includes('邮箱') && (errorMessage.includes('已注册') || errorMessage.includes('已存在'))) {
+ setErrors(prev => ({
+ ...prev,
+ email: errorMessage
+ }));
+ } else {
+ showErrorModal('发送验证码失败', errorMessage);
+ }
+ }
+
+ } catch (error) {
+ console.error('发送验证码失败:', error);
+
+ // 根据错误类型显示不同的错误信息
+ if (error.name === 'TypeError' && error.message.includes('Failed to fetch')) {
+ showErrorModal('网络连接失败', '无法连接到服务器,请检查您的网络连接后重试。如果问题持续存在,请联系客服。');
+ } else if (error.message.includes('HTTP 500')) {
+ showErrorModal('服务器错误', '服务器出现了内部错误,请稍后重试。如果问题持续存在,请联系客服。');
+ } else if (error.message.includes('HTTP 429')) {
+ showErrorModal('发送频率限制', '验证码发送过于频繁,请稍后再试。为了防止垃圾邮件,系统限制了发送频率。');
+ } else if (error.message.includes('HTTP 400')) {
+ showErrorModal('请求错误', '邮箱格式错误,请检查邮箱地址是否正确。');
+ } else {
+ showErrorModal('发送失败', '发送验证码失败,请稍后重试。如果问题持续存在,请联系客服。');
+ }
+ } finally {
+ setSendingCode(false);
+ }
+ };
+
+ const handleInputChange = (field) => (e) => {
+ const value = e.target.value;
+ setFormData(prev => ({
+ ...prev,
+ [field]: value
+ }));
+
+ // 清除对应字段的错误提示
+ if (errors[field]) {
+ setErrors(prev => ({
+ ...prev,
+ [field]: ''
+ }));
+ }
+ };
+
+ const handlePasswordChange = (e) => {
+ const value = e.target.value;
+ setFormData(prev => ({
+ ...prev,
+ password: value
+ }));
+
+ // 清除密码错误提示
+ if (errors.password) {
+ setErrors(prev => ({
+ ...prev,
+ password: ''
+ }));
+ }
+ };
+
+ const handleConfirmPasswordChange = (e) => {
+ const value = e.target.value;
+ setFormData(prev => ({
+ ...prev,
+ confirmPassword: value
+ }));
+
+ // 清除确认密码错误提示
+ if (errors.confirmPassword) {
+ setErrors(prev => ({
+ ...prev,
+ confirmPassword: ''
+ }));
+ }
+ };
+
+ const validateForm = () => {
+ const newErrors = {
+ username: '',
+ email: '',
+ emailCode: '',
+ password: '',
+ confirmPassword: ''
+ };
+
+ let hasError = false;
+
+ // 验证用户名
+ if (!formData.username || typeof formData.username !== 'string' || !formData.username.trim()) {
+ newErrors.username = '请输入用户名';
+ hasError = true;
+ } else if (formData.username.length < 2) {
+ newErrors.username = '用户名至少2个字符';
+ hasError = true;
+ } else if (formData.username.length > 20) {
+ newErrors.username = '用户名不能超过20个字符';
+ hasError = true;
+ }
+
+ // 验证邮箱
+ if (!formData.email || typeof formData.email !== 'string' || !formData.email.trim()) {
+ newErrors.email = '请输入邮箱地址';
+ hasError = true;
+ } else if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(formData.email)) {
+ newErrors.email = '请输入有效的邮箱地址';
+ hasError = true;
+ }
+
+ // 验证邮箱验证码
+ if (!formData.emailCode || typeof formData.emailCode !== 'string' || !formData.emailCode.trim()) {
+ newErrors.emailCode = '请输入邮箱验证码';
+ hasError = true;
+ } else if (formData.emailCode.length !== 6 || !/^\d{6}$/.test(formData.emailCode)) {
+ newErrors.emailCode = '请输入6位数字验证码';
+ hasError = true;
+ }
+
+ // 验证密码
+ if (!formData.password || typeof formData.password !== 'string' || !formData.password.trim()) {
+ newErrors.password = '请输入密码';
+ hasError = true;
+ } else if (formData.password.length < 6) {
+ newErrors.password = '密码长度至少6位';
+ hasError = true;
+ } else if (formData.password.length > 20) {
+ newErrors.password = '密码长度不能超过20位';
+ hasError = true;
+ }
+
+ // 验证确认密码
+ if (!formData.confirmPassword || typeof formData.confirmPassword !== 'string' || !formData.confirmPassword.trim()) {
+ newErrors.confirmPassword = '请确认密码';
+ hasError = true;
+ } else if (formData.password !== formData.confirmPassword) {
+ newErrors.confirmPassword = '两次输入的密码不一致';
+ hasError = true;
+ }
+
+ setErrors(newErrors);
+ return !hasError;
+ };
+
+ const handleSubmit = async (e) => {
+ e.preventDefault();
+
+ // 验证表单
+ if (!validateForm()) {
+ return;
+ }
+
+ setIsLoading(true);
+
+ try {
+ // 调用后端API进行注册
+ const registerResponse = await fetch(baseURL + '/register', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ body: JSON.stringify({
+ username: formData.username,
+ email: formData.email,
+ password: hashPassword(formData.password), // 前端加密密码
+ verification_code: hashPassword(formData.emailCode) // 前端加密验证码
+ })
+ });
+
+ if (!registerResponse.ok) {
+ throw new Error(`HTTP ${registerResponse.status}: ${registerResponse.statusText}`);
+ }
+
+ const registerResult = await registerResponse.json();
+
+ if (registerResult.success) {
+ showSuccessAlert('注册成功!欢迎加入小红书,正在跳转到登录页面...');
+ // 清空表单数据
+ setFormData({
+ username: '',
+ email: '',
+ emailCode: '',
+ password: '',
+ confirmPassword: ''
+ });
+ setErrors({
+ username: '',
+ email: '',
+ emailCode: '',
+ password: '',
+ confirmPassword: ''
+ });
+ // 延迟跳转到登录页面,让用户看到成功提示
+ setTimeout(() => {
+ navigate('/login');
+ }, 2000);
+ } else {
+ // 处理不同的注册失败情况
+ const errorMessage = registerResult.message || '注册失败,请稍后再试';
+
+ // 如果是邮箱已存在的错误,将错误显示在邮箱字段下方
+ if (errorMessage.includes('邮箱') && (errorMessage.includes('已存在') || errorMessage.includes('已注册'))) {
+ setErrors(prev => ({
+ ...prev,
+ email: errorMessage
+ }));
+ }
+ // 如果是用户名已存在的错误,将错误显示在用户名字段下方
+ else if (errorMessage.includes('用户名') && (errorMessage.includes('已存在') || errorMessage.includes('已被使用'))) {
+ setErrors(prev => ({
+ ...prev,
+ username: errorMessage
+ }));
+ }
+ else {
+ // 其他错误显示在消息框中
+ message.error(errorMessage);
+ }
+ }
+
+ } catch (error) {
+ console.error('注册失败:', error);
+
+ // 根据错误类型显示不同的错误信息
+ if (error.name === 'TypeError' && error.message.includes('Failed to fetch')) {
+ showErrorModal('网络连接失败', '无法连接到服务器,请检查您的网络连接后重试。如果问题持续存在,请联系客服。');
+ } else if (error.message.includes('HTTP 500')) {
+ showErrorModal('服务器内部错误', '服务器出现了内部错误,请稍后重试或联系客服。技术团队已收到通知。');
+ } else if (error.message.includes('HTTP 400')) {
+ showErrorModal('请求参数错误', '请求参数有误,请检查您输入的信息是否正确。');
+ } else if (error.message.includes('HTTP 409')) {
+ showErrorModal('用户信息冲突', '您输入的邮箱或用户名可能已被其他用户使用,请尝试使用其他邮箱或用户名。');
+ } else if (error.message.includes('HTTP')) {
+ showErrorModal('请求失败', `请求失败 (${error.message}),请稍后重试。如果问题持续存在,请联系客服。`);
+ } else {
+ showErrorModal('注册失败', '注册过程中发生未知错误,请稍后重试。如果问题持续存在,请联系客服。');
+ }
+ } finally {
+ setIsLoading(false);
+ }
+ };
+
+ return (
+ <div className="register-container">
+ <div className="register-background"></div>
+
+ {isLoading && (
+ <div className="loading-overlay">
+ <div className="loading-content">
+ <div className="loading-spinner-large"></div>
+ <p className="loading-text">正在注册...</p>
+ </div>
+ </div>
+ )}
+
+ <div className="register-content">
+ <div className="register-card">
+ {/* 成功提示 */}
+ {successAlert.visible && (
+ <div style={{ marginBottom: '16px' }}>
+ <Alert
+ message={successAlert.message}
+ type="success"
+ icon={<CheckCircleOutlined />}
+ showIcon
+ closable
+ onClose={() => setSuccessAlert({ visible: false, message: '' })}
+ style={{
+ borderRadius: '8px',
+ border: '1px solid #b7eb8f',
+ backgroundColor: '#f6ffed'
+ }}
+ />
+ </div>
+ )}
+
+ {/* 邮件验证码发送成功提示 */}
+ {emailCodeSuccessAlert.visible && (
+ <div style={{ marginBottom: '16px' }}>
+ <Alert
+ message={emailCodeSuccessAlert.message}
+ type="success"
+ icon={<CheckCircleOutlined />}
+ showIcon
+ closable
+ onClose={() => setEmailCodeSuccessAlert({ visible: false, message: '' })}
+ style={{
+ borderRadius: '8px',
+ border: '1px solid #b7eb8f',
+ backgroundColor: '#f6ffed'
+ }}
+ />
+ </div>
+ )}
+
+ <div className="register-header">
+ <h1 className="register-title">加入小红书</h1>
+ <p className="register-subtitle">发现美好生活,分享精彩瞬间</p>
+ </div>
+
+ <form className="register-form" onSubmit={handleSubmit}>
+ <div className="form-group">
+ <Input
+ type="text"
+ id="username"
+ name="username"
+ className={`form-input ${errors.username ? 'input-error' : ''}`}
+ placeholder="请输入用户名"
+ value={formData.username}
+ onChange={handleInputChange('username')}
+ prefix={<UserOutlined />}
+ size="large"
+ title=""
+ status={errors.username ? 'error' : ''}
+ />
+ {errors.username && (
+ <div className="error-message">
+ {errors.username}
+ </div>
+ )}
+ </div>
+
+ <div className="form-group">
+ <Input
+ type="email"
+ id="email"
+ name="email"
+ className={`form-input ${errors.email ? 'input-error' : ''}`}
+ placeholder="请输入邮箱地址"
+ value={formData.email}
+ onChange={handleInputChange('email')}
+ prefix={<MailOutlined />}
+ size="large"
+ title=""
+ status={errors.email ? 'error' : ''}
+ />
+ {errors.email && (
+ <div className="error-message">
+ {errors.email}
+ </div>
+ )}
+ </div>
+
+ <div className="form-group">
+ <div className="email-code-wrapper">
+ <Input
+ type="text"
+ id="emailCode"
+ name="emailCode"
+ className={`form-input email-code-input ${errors.emailCode ? 'input-error' : ''}`}
+ placeholder="请输入6位验证码"
+ value={formData.emailCode}
+ onChange={handleInputChange('emailCode')}
+ prefix={<SafetyOutlined />}
+ maxLength={6}
+ size="large"
+ title=""
+ status={errors.emailCode ? 'error' : ''}
+ />
+ <Button
+ type="primary"
+ className="send-code-button"
+ onClick={sendEmailCode}
+ loading={sendingCode}
+ disabled={countdown > 0 || !formData.email || sendingCode}
+ size="large"
+ >
+ {countdown > 0 ? `${countdown}s后重发` : (emailCodeSent ? '重新发送' : '发送验证码')}
+ </Button>
+ </div>
+ {errors.emailCode && (
+ <div className="error-message">
+ {errors.emailCode}
+ </div>
+ )}
+ </div>
+
+ <div className="form-group">
+ <Input.Password
+ id="password"
+ name="password"
+ className={`form-input ${errors.password ? 'input-error' : ''}`}
+ placeholder="请输入密码"
+ value={formData.password}
+ onChange={handlePasswordChange}
+ prefix={<LockOutlined />}
+ size="large"
+ title=""
+ status={errors.password ? 'error' : ''}
+ />
+ {errors.password && (
+ <div className="error-message">
+ {errors.password}
+ </div>
+ )}
+ </div>
+
+ <div className="form-group">
+ <Input.Password
+ id="confirmPassword"
+ name="confirmPassword"
+ className={`form-input ${errors.confirmPassword ? 'input-error' : ''}`}
+ placeholder="请确认密码"
+ value={formData.confirmPassword}
+ onChange={handleConfirmPasswordChange}
+ prefix={<LockOutlined />}
+ size="large"
+ title=""
+ status={errors.confirmPassword ? 'error' : ''}
+ />
+ {errors.confirmPassword && (
+ <div className="error-message">
+ {errors.confirmPassword}
+ </div>
+ )}
+ </div>
+
+ <button
+ type="submit"
+ className={`register-button ${isLoading ? 'loading' : ''}`}
+ disabled={isLoading}
+ >
+ {isLoading ? (
+ <>
+ <div className="loading-spinner"></div>
+ 注册中...
+ </>
+ ) : (
+ '立即注册'
+ )}
+ </button>
+ </form>
+
+ <div className="login-link">
+ <p>已有账户? <Link to="/login">立即登录</Link></p>
+ </div>
+ </div>
+ </div>
+
+ {/* 错误弹窗 */}
+ <Modal
+ title={
+ <div style={{ display: 'flex', alignItems: 'center', gap: '8px' }}>
+ <ExclamationCircleOutlined style={{ color: '#ff4d4f', fontSize: '18px' }} />
+ {errorModal.title}
+ </div>
+ }
+ open={errorModal.visible}
+ onOk={closeErrorModal}
+ onCancel={closeErrorModal}
+ okText="我知道了"
+ cancelButtonProps={{ style: { display: 'none' } }}
+ centered
+ className="error-modal"
+ >
+ <div style={{ padding: '16px 0', fontSize: '14px', lineHeight: '1.6' }}>
+ {errorModal.content}
+ </div>
+ </Modal>
+ </div>
+ );
+};
+
+export default RegisterPage;