import { type FormEvent, useState } from "react"; import type { Route } from "./+types/login"; import { useAuth } from "../context/AuthContext"; export function meta({}: Route.MetaArgs) { return [ { title: "登录 · 模型实验开发平台" }, { name: "description", content: "登录模型实验开发平台" }, ]; } export default function LoginRoute() { const { login } = useAuth(); const [username, setUsername] = useState(""); const [password, setPassword] = useState(""); const [busy, setBusy] = useState(false); const [error, setError] = useState(null); const submit = async (event: FormEvent) => { event.preventDefault(); if (!username.trim() || !password) { setError("请输入用户名和密码"); return; } setBusy(true); setError(null); try { await login(username.trim(), password); } catch (cause) { setError(cause instanceof Error ? cause.message : "登录失败,请稍后重试"); } finally { setBusy(false); } }; return (

MODEL EXPERIMENT PLATFORM

模型实验开发平台

使用平台账号登录并选择你的 Workspace。

void submit(event)} className="grid gap-[18px]"> {error && (

{error}

)}
); }