修改登录逻辑
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import type { FormEvent } from "react";
|
||||
import Image from "next/image";
|
||||
import Link from "next/link";
|
||||
import { Loader2, LogIn } from "lucide-react";
|
||||
import { pulseFeedback, revealChildren, runScopedMotion } from "@/lib/ui/motion";
|
||||
|
||||
@@ -10,12 +11,22 @@ export function AuthLoginPanel({
|
||||
next,
|
||||
configured,
|
||||
message,
|
||||
missing
|
||||
missing,
|
||||
title = "账户登录",
|
||||
submitLabel = "登录",
|
||||
authMode,
|
||||
alternateHref,
|
||||
alternateLabel
|
||||
}: {
|
||||
next: string;
|
||||
configured: boolean;
|
||||
message?: string | null;
|
||||
missing?: string[];
|
||||
title?: string;
|
||||
submitLabel?: string;
|
||||
authMode?: string;
|
||||
alternateHref?: string;
|
||||
alternateLabel?: string;
|
||||
}) {
|
||||
const [username, setUsername] = useState("");
|
||||
const [password, setPassword] = useState("");
|
||||
@@ -40,6 +51,7 @@ export function AuthLoginPanel({
|
||||
setError(null);
|
||||
try {
|
||||
const payload: Record<string, string> = { username, password, next };
|
||||
if (authMode) payload.authMode = authMode;
|
||||
const response = await fetch("/api/auth/password", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
@@ -63,7 +75,7 @@ export function AuthLoginPanel({
|
||||
</section>
|
||||
|
||||
<section className="panel auth-panel" data-animate>
|
||||
<h2>账户登录</h2>
|
||||
<h2>{title}</h2>
|
||||
|
||||
{message || hasMissingConfig || error ? (
|
||||
<div ref={feedbackRef}>
|
||||
@@ -101,9 +113,14 @@ export function AuthLoginPanel({
|
||||
</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} />}
|
||||
登录
|
||||
{submitLabel}
|
||||
</button>
|
||||
</form>
|
||||
{alternateHref && alternateLabel ? (
|
||||
<Link className="button auth-alternate-link" href={alternateHref}>
|
||||
{alternateLabel}
|
||||
</Link>
|
||||
) : null}
|
||||
</section>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user