Skip to content

Commit aa40937

Browse files
committed
优化登录页面错误提示,简化密码错误信息并强制重渲染以更新倒计时显示
1 parent 24632f0 commit aa40937

2 files changed

Lines changed: 7 additions & 13 deletions

File tree

app/api/auth/verify/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ export async function POST(request: NextRequest) {
133133
error: "密码错误",
134134
remainingAttempts: attemptsUntilLockout,
135135
totalAttempts: record.totalAttempts,
136-
message: `密码错误,还剩 ${attemptsUntilLockout} 次尝试机会`
136+
message: "密码错误"
137137
},
138138
{ status: 401 }
139139
);

app/login/page.tsx

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ function LoginPageContent() {
1111
const [lockoutUntil, setLockoutUntil] = useState(0);
1212
const [remainingAttempts, setRemainingAttempts] = useState<number | null>(null);
1313
const [totalAttempts, setTotalAttempts] = useState(0);
14+
// 用于触发每秒重渲染
15+
const [, setTick] = useState(0);
1416
const router = useRouter();
1517
const searchParams = useSearchParams();
1618
const from = searchParams.get("from") || "/";
@@ -31,6 +33,8 @@ function LoginPageContent() {
3133
setLoading(false);
3234
setError("");
3335
}
36+
// 强制重渲染以更新倒计时显示
37+
setTick(t => t + 1);
3438
}, 1000);
3539

3640
return () => clearInterval(timer);
@@ -100,7 +104,7 @@ function LoginPageContent() {
100104
<div className="w-16 h-16 bg-gradient-to-br from-blue-500 to-purple-600 rounded-2xl flex items-center justify-center mb-4 shadow-lg">
101105
<LockKeyhole className="w-8 h-8 text-white" />
102106
</div>
103-
<h1 className="text-2xl font-bold text-slate-100">CLIProxy Dashboard</h1>
107+
<h1 className="text-2xl font-bold text-slate-100">CLIProxyAPI Dashboard</h1>
104108
<p className="text-slate-400 mt-2">请输入密码以继续</p>
105109
</div>
106110

@@ -122,23 +126,13 @@ function LoginPageContent() {
122126
/>
123127
</div>
124128

125-
{error && (
129+
{error && !isLocked && (
126130
<div className={`rounded-lg p-3 text-sm ${
127131
isLocked
128132
? "bg-red-500/10 border border-red-500/50 text-red-400"
129133
: "bg-orange-500/10 border border-orange-500/50 text-orange-400"
130134
}`}>
131135
<p className="font-medium">{error}</p>
132-
{remainingAttempts !== null && remainingAttempts > 0 && !isLocked && (
133-
<p className="text-xs mt-1.5 opacity-80">
134-
还剩 <span className="font-semibold">{remainingAttempts}</span> 次尝试机会
135-
</p>
136-
)}
137-
{totalAttempts > 0 && !isLocked && (
138-
<p className="text-xs mt-1 opacity-70">
139-
累计错误 {totalAttempts}
140-
</p>
141-
)}
142136
</div>
143137
)}
144138

0 commit comments

Comments
 (0)