第一次提交

This commit is contained in:
2026-03-13 16:40:08 +08:00
commit 0a49bcfb2d
277 changed files with 61890 additions and 0 deletions

View File

@ -0,0 +1,100 @@
'use client';
import Link from 'next/link';
import { useSearchParams } from 'next/navigation';
import { useState } from 'react';
import { buildFrontendHandoffUrl, login, withNext } from '@/lib/auth-client';
export default function LoginPage() {
const searchParams = useSearchParams();
const nextPath = searchParams?.get('next') || '/';
const [username, setUsername] = useState('');
const [password, setPassword] = useState('');
const [loading, setLoading] = useState(false);
const [error, setError] = useState('');
const handleSubmit = async (event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault();
setLoading(true);
setError('');
try {
const response = await login(username, password);
window.location.replace(buildFrontendHandoffUrl(response, nextPath));
} catch (err) {
setError(err instanceof Error ? err.message : '登录失败,请稍后重试');
} finally {
setLoading(false);
}
};
return (
<main className="portal-page">
<section className="portal-shell">
<div className="portal-brand">
<div className="portal-kicker">Auth Portal</div>
<h1 className="portal-title">Boardware Genius</h1>
<p className="portal-copy">
URL
</p>
<div className="portal-notes">
<div className="portal-note">
<strong></strong>
auth portal
</div>
<div className="portal-note">
<strong></strong>
<code>{nextPath}</code>
</div>
</div>
</div>
<div className="portal-panel">
<div className="auth-card">
<h1></h1>
<p></p>
<form className="auth-form" onSubmit={handleSubmit}>
<div className="field">
<label htmlFor="username"></label>
<input
id="username"
value={username}
onChange={(event) => setUsername(event.target.value)}
autoComplete="username"
placeholder="例如bwgdi"
required
/>
</div>
<div className="field">
<label htmlFor="password"></label>
<input
id="password"
type="password"
value={password}
onChange={(event) => setPassword(event.target.value)}
autoComplete="current-password"
placeholder="输入密码"
required
/>
</div>
<div className="error-text">{error}</div>
<button className="primary-button" type="submit" disabled={loading}>
{loading ? '登录中...' : '登录并进入容器'}
</button>
</form>
<div className="auth-footer">
<Link href={withNext('/register', nextPath)}></Link>
</div>
</div>
</div>
</section>
</main>
);
}