前端添加中英文切换
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import React, { useState } from 'react';
|
||||
import { useLanguage } from '../i18n/LanguageContext';
|
||||
|
||||
interface LoginPageProps {
|
||||
onLogin: (email: string, password: string) => void;
|
||||
@@ -12,6 +13,7 @@ const AppIcon = () => (
|
||||
);
|
||||
|
||||
const LoginPage: React.FC<LoginPageProps> = ({ onLogin, onNavigateToSignUp }) => {
|
||||
const { t } = useLanguage();
|
||||
const [email, setEmail] = useState('');
|
||||
const [password, setPassword] = useState('');
|
||||
|
||||
@@ -25,11 +27,11 @@ const LoginPage: React.FC<LoginPageProps> = ({ onLogin, onNavigateToSignUp }) =>
|
||||
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">Welcome Back!</h2>
|
||||
<p className="text-slate-600 dark:text-slate-400 mb-6 text-center">Log in to access your plans.</p>
|
||||
<h2 className="text-2xl font-bold text-slate-800 dark:text-slate-100 mb-2 text-center">{t('welcomeTitle')}</h2>
|
||||
<p className="text-slate-600 dark:text-slate-400 mb-6 text-center">{t('loginSubtitle')}</p>
|
||||
<form onSubmit={handleSubmit} className="space-y-4">
|
||||
<div>
|
||||
<label htmlFor="email" className="block text-sm font-medium text-slate-700 dark:text-slate-300 mb-1">Email Address</label>
|
||||
<label htmlFor="email" className="block text-sm font-medium text-slate-700 dark:text-slate-300 mb-1">{t('email')}</label>
|
||||
<input
|
||||
type="email"
|
||||
id="email"
|
||||
@@ -41,7 +43,7 @@ const LoginPage: React.FC<LoginPageProps> = ({ onLogin, onNavigateToSignUp }) =>
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label htmlFor="password" className="block text-sm font-medium text-slate-700 dark:text-slate-300 mb-1">Password</label>
|
||||
<label htmlFor="password" className="block text-sm font-medium text-slate-700 dark:text-slate-300 mb-1">{t('password')}</label>
|
||||
<input
|
||||
type="password"
|
||||
id="password"
|
||||
@@ -57,13 +59,13 @@ const LoginPage: React.FC<LoginPageProps> = ({ onLogin, onNavigateToSignUp }) =>
|
||||
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={!email || !password}
|
||||
>
|
||||
Login
|
||||
{t('login')}
|
||||
</button>
|
||||
</form>
|
||||
<p className="text-sm text-center text-slate-500 dark:text-slate-400 mt-6">
|
||||
Don't have an account?{' '}
|
||||
{t('noAccount')}{' '}
|
||||
<button onClick={onNavigateToSignUp} className="font-semibold text-green-600 dark:text-green-400 hover:underline">
|
||||
Sign Up
|
||||
{t('signUp')}
|
||||
</button>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user