第一次提交

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,134 @@
'use client';
import Link from 'next/link';
import { useSearchParams } from 'next/navigation';
import { useState } from 'react';
import { buildFrontendHandoffUrl, register, withNext } from '@/lib/auth-client';
export default function RegisterPage() {
const searchParams = useSearchParams();
const nextPath = searchParams?.get('next') || '/mcp';
const [username, setUsername] = useState('');
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const [confirmPassword, setConfirmPassword] = useState('');
const [loading, setLoading] = useState(false);
const [error, setError] = useState('');
const handleSubmit = async (event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault();
setLoading(true);
setError('');
try {
if (password !== confirmPassword) {
throw new Error('两次输入的密码不一致');
}
const response = await register(username, email, 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">Create Runtime</h1>
<p className="portal-copy">
backend URL
</p>
<div className="portal-notes">
<div className="portal-note">
<strong></strong>
deploy-control AuthZ backend 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> backend </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="email"></label>
<input
id="email"
type="email"
value={email}
onChange={(event) => setEmail(event.target.value)}
autoComplete="email"
placeholder="例如steven@example.com"
/>
</div>
<div className="field">
<label htmlFor="password"></label>
<input
id="password"
type="password"
value={password}
onChange={(event) => setPassword(event.target.value)}
autoComplete="new-password"
placeholder="设置密码"
required
/>
</div>
<div className="field">
<label htmlFor="confirmPassword"></label>
<input
id="confirmPassword"
type="password"
value={confirmPassword}
onChange={(event) => setConfirmPassword(event.target.value)}
autoComplete="new-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('/login', nextPath)}></Link>
</div>
<div className="status-panel">
Portal URL
</div>
</div>
</div>
</section>
</main>
);
}