feat: add translate
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { useState } from 'react';
|
||||
import { X } from 'lucide-react';
|
||||
import { useAuth } from '../contexts/AuthContext';
|
||||
import { useLanguage } from '../contexts/LanguageContext';
|
||||
|
||||
interface AuthModalProps {
|
||||
onClose: () => void;
|
||||
@@ -8,6 +9,7 @@ interface AuthModalProps {
|
||||
|
||||
export default function AuthModal({ onClose }: AuthModalProps) {
|
||||
const { signIn, signUp } = useAuth();
|
||||
const { t } = useLanguage();
|
||||
const [isSignUp, setIsSignUp] = useState(false);
|
||||
const [email, setEmail] = useState('');
|
||||
const [password, setPassword] = useState('');
|
||||
@@ -41,7 +43,7 @@ export default function AuthModal({ onClose }: AuthModalProps) {
|
||||
<div className="bg-white rounded-xl shadow-xl max-w-md w-full p-6">
|
||||
<div className="flex justify-between items-center mb-6">
|
||||
<h2 className="text-2xl font-bold text-gray-900">
|
||||
{isSignUp ? '注册账号' : '登录账号'}
|
||||
{isSignUp ? t.auth.signUpTitle : t.auth.signInTitle}
|
||||
</h2>
|
||||
<button
|
||||
onClick={onClose}
|
||||
@@ -54,7 +56,7 @@ export default function AuthModal({ onClose }: AuthModalProps) {
|
||||
<form onSubmit={handleSubmit} className="space-y-4">
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-700 mb-1">
|
||||
邮箱
|
||||
{t.auth.email}
|
||||
</label>
|
||||
<input
|
||||
type="email"
|
||||
@@ -68,7 +70,7 @@ export default function AuthModal({ onClose }: AuthModalProps) {
|
||||
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-700 mb-1">
|
||||
密码
|
||||
{t.auth.password}
|
||||
</label>
|
||||
<input
|
||||
type="password"
|
||||
@@ -83,7 +85,7 @@ export default function AuthModal({ onClose }: AuthModalProps) {
|
||||
|
||||
{error && (
|
||||
<div className="p-3 bg-red-100 border border-red-400 text-red-700 rounded-lg text-sm font-medium animate-pulse">
|
||||
错误: {error}
|
||||
{t.auth.error}: {error}
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -92,7 +94,7 @@ export default function AuthModal({ onClose }: AuthModalProps) {
|
||||
disabled={loading}
|
||||
className="w-full py-3 px-4 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors font-medium disabled:opacity-80 disabled:cursor-wait"
|
||||
>
|
||||
{isSignUp ? '注册' : '登录'}
|
||||
{isSignUp ? t.auth.signUp : t.auth.signIn}
|
||||
</button>
|
||||
</form>
|
||||
|
||||
@@ -101,7 +103,7 @@ export default function AuthModal({ onClose }: AuthModalProps) {
|
||||
onClick={() => setIsSignUp(!isSignUp)}
|
||||
className="text-sm text-blue-600 hover:text-blue-700"
|
||||
>
|
||||
{isSignUp ? '已有账号?去登录' : '没有账号?去注册'}
|
||||
{isSignUp ? t.auth.hasAccount : t.auth.noAccount}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user