前端添加中英文切换

This commit is contained in:
Dev
2026-11-02 16:43:15 +08:00
parent 41ca22f59e
commit 061fa9d029
22 changed files with 817 additions and 246 deletions
+11 -9
View File
@@ -1,4 +1,5 @@
import React, { useState } from 'react';
import { useLanguage } from '../i18n/LanguageContext';
interface SignUpPageProps {
onSignUp: (name: string, email: string, password: string) => void;
@@ -12,6 +13,7 @@ const AppIcon = () => (
);
const SignUpPage: React.FC<SignUpPageProps> = ({ onSignUp, onNavigateToLogin }) => {
const { t } = useLanguage();
const [name, setName] = useState('');
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
@@ -26,23 +28,23 @@ const SignUpPage: React.FC<SignUpPageProps> = ({ onSignUp, onNavigateToLogin })
return (
<div className="bg-white dark:bg-slate-800 p-8 rounded-xl shadow-lg border border-slate-200 dark:border-slate-700 w-full max-w-md">
<AppIcon />
<h2 className="text-2xl font-bold text-slate-800 dark:text-slate-100 mb-2 text-center">Create Your Account</h2>
<p className="text-slate-600 dark:text-slate-400 mb-6 text-center">Start planning your goals today.</p>
<h2 className="text-2xl font-bold text-slate-800 dark:text-slate-100 mb-2 text-center">{t('createAccount')}</h2>
<p className="text-slate-600 dark:text-slate-400 mb-6 text-center">{t('signupSubtitle')}</p>
<form onSubmit={handleSubmit} className="space-y-4">
<div>
<label htmlFor="name" className="block text-sm font-medium text-slate-700 dark:text-slate-300 mb-1">Full Name</label>
<label htmlFor="name" className="block text-sm font-medium text-slate-700 dark:text-slate-300 mb-1">{t('fullName')}</label>
<input
type="text"
id="name"
value={name}
onChange={(e) => setName(e.target.value)}
className="w-full p-3 bg-white dark:bg-slate-700 text-slate-900 dark:text-slate-100 border border-slate-300 dark:border-slate-600 rounded-lg focus:ring-2 focus:ring-green-500 focus:border-green-500 transition-shadow placeholder:text-slate-400 dark:placeholder:text-slate-500"
placeholder="Ada Lovelace"
placeholder={t('namePlaceholder')}
required
/>
</div>
<div>
<label htmlFor="signup-email" className="block text-sm font-medium text-slate-700 dark:text-slate-300 mb-1">Email Address</label>
<label htmlFor="signup-email" className="block text-sm font-medium text-slate-700 dark:text-slate-300 mb-1">{t('email')}</label>
<input
type="email"
id="signup-email"
@@ -54,7 +56,7 @@ const SignUpPage: React.FC<SignUpPageProps> = ({ onSignUp, onNavigateToLogin })
/>
</div>
<div>
<label htmlFor="signup-password" className="block text-sm font-medium text-slate-700 dark:text-slate-300 mb-1">Password</label>
<label htmlFor="signup-password" className="block text-sm font-medium text-slate-700 dark:text-slate-300 mb-1">{t('password')}</label>
<input
type="password"
id="signup-password"
@@ -70,13 +72,13 @@ const SignUpPage: React.FC<SignUpPageProps> = ({ onSignUp, onNavigateToLogin })
className="w-full bg-green-600 text-white font-semibold px-6 py-3 rounded-lg hover:bg-green-700 transition-colors disabled:bg-slate-400 dark:disabled:bg-slate-600 disabled:cursor-not-allowed"
disabled={!name || !email || !password}
>
Create Account
{t('createAccount')}
</button>
</form>
<p className="text-sm text-center text-slate-500 dark:text-slate-400 mt-6">
Already have an account?{' '}
{t('hasAccount')}{' '}
<button onClick={onNavigateToLogin} className="font-semibold text-green-600 dark:text-green-400 hover:underline">
Log In
{t('logIn')}
</button>
</p>
</div>