移除验证码输入框

This commit is contained in:
2026-06-04 12:14:13 +08:00
parent ce358df201
commit 288e31d641
3 changed files with 16 additions and 72 deletions

View File

@@ -2800,32 +2800,6 @@ button:active:not(:disabled),
margin-bottom: 0;
}
.auth-captcha-row {
display: grid;
grid-template-columns: minmax(0, 1fr) 118px;
gap: 8px;
align-items: center;
}
.auth-captcha-button {
height: 44px;
border: 1px solid var(--line);
border-radius: 8px;
background: #ffffff;
display: inline-flex;
align-items: center;
justify-content: center;
padding: 0;
overflow: hidden;
}
.auth-captcha-button img {
width: 100%;
height: 100%;
display: block;
object-fit: cover;
}
.auth-submit,
.auth-submit.button {
width: 100%;
@@ -2899,8 +2873,4 @@ button:active:not(:disabled),
width: 34px;
min-height: 34px;
}
.auth-captcha-row {
grid-template-columns: minmax(0, 1fr) 104px;
}
}

View File

@@ -1,9 +1,9 @@
"use client";
import { useEffect, useMemo, useRef, useState } from "react";
import { useEffect, useRef, useState } from "react";
import type { FormEvent } from "react";
import Image from "next/image";
import { Loader2, LogIn, RefreshCw } from "lucide-react";
import { Loader2, LogIn } from "lucide-react";
import { pulseFeedback, revealChildren, runScopedMotion } from "@/lib/ui/motion";
export function AuthLoginPanel({
@@ -19,8 +19,6 @@ export function AuthLoginPanel({
}) {
const [username, setUsername] = useState("");
const [password, setPassword] = useState("");
const [code, setCode] = useState("");
const [randomStr, setRandomStr] = useState("");
const [submitting, setSubmitting] = useState(false);
const [error, setError] = useState<string | null>(null);
const screenRef = useRef<HTMLDivElement | null>(null);
@@ -35,16 +33,6 @@ export function AuthLoginPanel({
pulseFeedback(feedbackRef.current);
}, [error, message, missing?.join(",")]);
const captchaSrc = useMemo(() => {
if (!randomStr) return "";
return `/api/auth/captcha?randomStr=${encodeURIComponent(randomStr)}`;
}, [randomStr]);
function refreshCaptcha() {
setCode("");
setRandomStr(crypto.randomUUID());
}
async function submit(event: FormEvent<HTMLFormElement>) {
event.preventDefault();
if (!configured || submitting) return;
@@ -52,10 +40,6 @@ export function AuthLoginPanel({
setError(null);
try {
const payload: Record<string, string> = { username, password, next };
if (code.trim() && randomStr) {
payload.code = code.trim();
payload.randomStr = randomStr;
}
const response = await fetch("/api/auth/password", {
method: "POST",
headers: { "Content-Type": "application/json" },
@@ -66,7 +50,6 @@ export function AuthLoginPanel({
window.location.assign(result.redirectTo || next || "/create");
} catch (err) {
setError(err instanceof Error ? err.message : String(err));
refreshCaptcha();
} finally {
setSubmitting(false);
}
@@ -116,29 +99,6 @@ export function AuthLoginPanel({
placeholder="请输入密码"
/>
</label>
<label className="field" data-animate>
<span></span>
<div className="auth-captcha-row">
<input
autoComplete="off"
value={code}
onChange={(event) => setCode(event.target.value)}
disabled={!configured || submitting}
placeholder="需要时填写"
/>
<button
className="auth-captcha-button"
type="button"
onClick={refreshCaptcha}
disabled={!configured || submitting}
aria-label="刷新验证码"
title="刷新验证码"
>
{captchaSrc ? <img src={captchaSrc} alt="验证码" /> : <RefreshCw size={18} />}
</button>
</div>
</label>
<button className="button primary auth-submit" type="submit" disabled={!configured || submitting || !username.trim() || !password} data-animate>
{submitting ? <Loader2 className="spin" size={18} /> : <LogIn size={18} />}

View File

@@ -0,0 +1,14 @@
import { readFile } from "node:fs/promises";
import { join } from "node:path";
import { describe, expect, it } from "vitest";
describe("AuthLoginPanel", () => {
it("does not render captcha controls", async () => {
const source = await readFile(join(process.cwd(), "components", "auth-login-panel.tsx"), "utf8");
expect(source).not.toContain("auth-captcha-row");
expect(source).not.toContain("auth-captcha-button");
expect(source).not.toContain("/api/auth/captcha");
expect(source).not.toContain("randomStr");
});
});