fix(data): 清理旧数据并保护服务端写入
This commit is contained in:
@@ -3,12 +3,12 @@
|
||||
import { useState } from 'react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { useAuthStore } from '@/stores/useAuthStore';
|
||||
import { Eye, EyeOff, LayoutGrid, Lock, Phone } from 'lucide-react';
|
||||
import { Eye, EyeOff, LayoutGrid, Lock, User } from 'lucide-react';
|
||||
|
||||
export default function LoginPage() {
|
||||
const router = useRouter();
|
||||
const { login } = useAuthStore();
|
||||
const [phone, setPhone] = useState('');
|
||||
const [username, setUsername] = useState('');
|
||||
const [password, setPassword] = useState('');
|
||||
const [remember, setRemember] = useState(false);
|
||||
const [showPassword, setShowPassword] = useState(false);
|
||||
@@ -19,18 +19,18 @@ export default function LoginPage() {
|
||||
e.preventDefault();
|
||||
setError('');
|
||||
|
||||
if (!phone.trim() || !password.trim()) {
|
||||
setError('请输入手机号和密码');
|
||||
if (!username.trim() || !password.trim()) {
|
||||
setError('请输入用户名和密码');
|
||||
return;
|
||||
}
|
||||
|
||||
setLoading(true);
|
||||
try {
|
||||
const success = await login(phone.trim(), password, remember);
|
||||
const success = await login(username.trim(), password, remember);
|
||||
if (success) {
|
||||
router.push('/products');
|
||||
} else {
|
||||
setError('手机号或密码错误');
|
||||
setError('用户名或密码错误');
|
||||
}
|
||||
} finally {
|
||||
setLoading(false);
|
||||
@@ -51,15 +51,13 @@ export default function LoginPage() {
|
||||
<div className="rounded-2xl border border-[var(--line)] bg-[var(--bg-card)] p-6 shadow-[var(--shadow-md)]">
|
||||
<form onSubmit={handleSubmit} className="space-y-4">
|
||||
<div>
|
||||
<label className="mb-1.5 block text-[12px] font-medium text-[var(--ink-soft)]">手机号</label>
|
||||
<label className="mb-1.5 block text-[12px] font-medium text-[var(--ink-soft)]">用户名</label>
|
||||
<div className="relative">
|
||||
<Phone className="absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-[var(--ink-muted)]" />
|
||||
<User className="absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-[var(--ink-muted)]" />
|
||||
<input
|
||||
type="tel"
|
||||
value={phone}
|
||||
onChange={(e) => setPhone(e.target.value)}
|
||||
placeholder="请输入手机号"
|
||||
maxLength={11}
|
||||
value={username}
|
||||
onChange={(e) => setUsername(e.target.value)}
|
||||
placeholder="请输入用户名"
|
||||
className="h-10 w-full rounded-lg border border-[var(--line)] bg-[var(--bg)] pl-10 pr-3 text-[14px] text-[var(--ink)] transition-all placeholder:text-[var(--ink-muted)] focus:border-[var(--accent)] focus:outline-none focus:ring-2 focus:ring-[var(--accent-ring)]"
|
||||
/>
|
||||
</div>
|
||||
@@ -113,7 +111,7 @@ export default function LoginPage() {
|
||||
</form>
|
||||
|
||||
<p className="mt-4 text-center text-[11px] text-[var(--ink-muted)]">
|
||||
默认账号:13200132008 / Ftb@2024(超级管理员)
|
||||
默认账号:admin / Ftb@2024(超级管理员)
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user