From 23cf1d268c25e2a0a4c0e21ba6f0a6cd077f590d Mon Sep 17 00:00:00 2001 From: "Apple\\Apple" Date: Tue, 20 May 2025 10:38:31 +0800 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8FRefactor:=20RegisterForm?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/components/LoginForm.js | 4 +- web/src/components/OIDCIcon.js | 4 +- web/src/components/RegisterForm.js | 528 ++++++++++++++++------------- web/src/i18n/locales/en.json | 5 +- 4 files changed, 301 insertions(+), 240 deletions(-) diff --git a/web/src/components/LoginForm.js b/web/src/components/LoginForm.js index cf29fecd..84a0082c 100644 --- a/web/src/components/LoginForm.js +++ b/web/src/components/LoginForm.js @@ -223,7 +223,7 @@ const LoginForm = () => { theme='outline' className="w-full h-12 flex items-center justify-center !rounded-full border border-gray-200 hover:bg-gray-50 transition-colors" type="tertiary" - icon={} + icon={} size="large" onClick={() => onOIDCClicked( @@ -358,7 +358,7 @@ const LoginForm = () => { {t('或')} - +
- } - /> - - handleChange('verification_code', value) - } - name='verification_code' - /> - - ) : ( - <> - )} + const renderOAuthOptions = () => { + return ( +
+
+
+ Logo + {systemName} +
+ + +
+ {t('注 册')} +
+
+
+ {status.wechat_login && ( + )} + + {status.github_oauth && ( + + )} + + {status.oidc_enabled && ( + + )} + + {status.linuxdo_oauth && ( + + )} + + {status.telegram_oauth && ( +
+ +
+ )} + + + {t('或')} + + + +
+ +
+ {t('已有账户?')} {t('登录')} +
+
+
+ + {turnstileEnabled && ( +
+ { + setTurnstileToken(token); + }} + /> +
+ )} +
+
+ ); + }; + + const renderEmailRegisterForm = () => { + return ( +
+
+
+ Logo + {systemName} +
+ + +
+ {t('注 册')} +
+
+ + handleChange('username', value)} + /> + + handleChange('password', value)} + /> + + handleChange('password2', value)} + /> + + {showEmailVerification && ( + <> + handleChange('email', value)} + suffix={ + + } + /> + handleChange('verification_code', value)} + /> + + )} + +
+ - -
+ + + + {t('或')} + + +
+
- {status.github_oauth || - status.oidc_enabled || - status.wechat_login || - status.telegram_oauth || - status.linuxdo_oauth ? ( - <> - - {t('第三方登录')} - -
- {status.github_oauth ? ( -
- {status.telegram_oauth ? ( - <> -
- -
- - ) : ( - <> - )} - - ) : ( - <> - )} - - setShowWeChatLoginModal(false)} - okText={t('登录')} - size={'small'} - centered={true} - > -
- -
-
-

- {t( - '微信扫码关注公众号,输入「验证码」获取验证码(三分钟内有效)', - )} -

-
-
- - handleChange('wechat_verification_code', value) - } - /> - -
- {turnstileEnabled ? ( -
- { - setTurnstileToken(token); - }} - /> -
- ) : ( - <> - )} + {t('其他注册选项')} + +
+ +
+ {t('已有账户?')} {t('登录')} +
-
- - +
+
+
+ ); + }; + + // 微信登录模态框 + const renderWeChatLoginModal = () => { + return ( + setShowWeChatLoginModal(false)} + okText={t('登录')} + size="small" + centered={true} + > +
+ 微信二维码 +
+ +
+

{t('微信扫码关注公众号,输入「验证码」获取验证码(三分钟内有效)')}

+
+ +
+ handleChange('wechat_verification_code', value)} + /> + +
+ ); + }; + + return ( +
+ {/* 背景图片容器 - 放大并保持居中 */} +
+ + {/* 半透明遮罩层 */} +
+ +
+ {showEmailRegister || !(status.github_oauth || status.oidc_enabled || status.wechat_login || status.linuxdo_oauth || status.telegram_oauth) + ? renderEmailRegisterForm() + : renderOAuthOptions()} + {renderWeChatLoginModal()} +
); }; diff --git a/web/src/i18n/locales/en.json b/web/src/i18n/locales/en.json index 1a0fc54c..efe58d9e 100644 --- a/web/src/i18n/locales/en.json +++ b/web/src/i18n/locales/en.json @@ -5,12 +5,15 @@ "$%.6f 额度": "$%.6f quota", "或": "or", "登 录": "Log In", + "注 册": "Sign Up", "使用 邮箱 登录": "Sign in with Email", "使用 GitHub 继续": "Continue with GitHub", "使用 OIDC 继续": "Continue with OIDC", "使用 微信 继续": "Continue with WeChat", "使用 LinuxDO 继续": "Continue with LinuxDO", + "使用 邮箱 注册": "Sign up with Email", "其他登录选项": "Other login options", + "其他注册选项": "Other registration options", "请输入您的邮箱地址": "Please enter your email address", "请输入您的密码": "Please enter your password", "继续": "Continue", @@ -775,7 +778,7 @@ "邀请码": "Invitation code", "输入邀请码": "Enter invitation code", "账户": "Account", - "邮箱": "Mail", + "邮箱": "Email", "已有账户?": "Already have an account?", "创意任务": "Tasks", "用户管理": "User Management",