Download agy2api/frontend/src/pages/Login.jsx from a3216/ds2api: direct link, hf CLI and curl.
- Browser
- Download file 3.16 kB
-
https://huggingface.co/spaces/a3216/ds2api/resolve/main/agy2api/frontend/src/pages/Login.jsx
- Command line
-
hf download hf://spaces/a3216/ds2api/agy2api/frontend/src/pages/Login.jsx
-
curl -L -o Login.jsx https://huggingface.co/spaces/a3216/ds2api/resolve/main/agy2api/frontend/src/pages/Login.jsx
3.16 kB
| import { Eye, EyeOff, Rocket } from "lucide-react"; | |
| import { useState } from "react"; | |
| import api from "../api"; | |
| export default function Login({ onSuccess }) { | |
| const [password, setPassword] = useState(""); | |
| const [showPassword, setShowPassword] = useState(false); | |
| const [error, setError] = useState(""); | |
| const [loading, setLoading] = useState(false); | |
| const handleSubmit = async (e) => { | |
| e.preventDefault(); | |
| setError(""); | |
| setLoading(true); | |
| try { | |
| const res = await api.post("/auth/login", { password }); | |
| localStorage.setItem("panelToken", res.data.token); | |
| onSuccess(); | |
| } catch (err) { | |
| setError(err.response?.data?.detail || "登录失败"); | |
| } finally { | |
| setLoading(false); | |
| } | |
| }; | |
| return ( | |
| <div className="min-h-screen flex items-center justify-center p-4"> | |
| <div className="w-full max-w-md"> | |
| {/* Logo */} | |
| <div className="text-center mb-8"> | |
| <div className="inline-flex items-center justify-center w-16 h-16 rounded-2xl bg-purple-600/20 mb-4"> | |
| <Rocket className="w-10 h-10 text-purple-400" /> | |
| </div> | |
| <h1 className="text-3xl font-bold text-white">AGY2API</h1> | |
| <p className="text-gray-400 mt-2">Antigravity API 代理服务控制面板</p> | |
| </div> | |
| {/* 登录卡片 */} | |
| <div className="card"> | |
| <h2 className="text-xl font-semibold mb-6 text-center">登录控制面板</h2> | |
| {error && ( | |
| <div className="bg-red-500/10 border border-red-500/30 text-red-400 px-4 py-3 rounded-lg mb-4"> | |
| {error} | |
| </div> | |
| )} | |
| <form onSubmit={handleSubmit} className="space-y-4"> | |
| <div> | |
| <label className="block text-sm font-medium text-gray-300 mb-2"> | |
| 密码 | |
| </label> | |
| <div className="relative"> | |
| <input | |
| type={showPassword ? "text" : "password"} | |
| value={password} | |
| onChange={(e) => setPassword(e.target.value)} | |
| className="w-full px-4 py-3 bg-dark-800 border border-dark-600 rounded-lg text-white placeholder-gray-500 pr-12" | |
| placeholder="请输入控制面板密码" | |
| required | |
| /> | |
| <button | |
| type="button" | |
| onClick={() => setShowPassword(!showPassword)} | |
| className="absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-300" | |
| > | |
| {showPassword ? <EyeOff size={20} /> : <Eye size={20} />} | |
| </button> | |
| </div> | |
| </div> | |
| <button | |
| type="submit" | |
| disabled={loading} | |
| className="w-full btn btn-primary py-3 flex items-center justify-center disabled:opacity-50" | |
| > | |
| {loading ? ( | |
| <span className="animate-spin rounded-full h-5 w-5 border-b-2 border-white"></span> | |
| ) : ( | |
| "登录" | |
| )} | |
| </button> | |
| </form> | |
| </div> | |
| </div> | |
| </div> | |
| ); | |
| } | |