feat: enhance admin UI with responsive styles and new components
- Updated styles in src/styles.css for better responsiveness and layout adjustments. - Added new CSS classes for edit drawer and item rail components. - Introduced animations for drawer transitions. - Created new types in src/types/admin.ts for better type safety in admin features. - Modified vite.config.ts to change server port and enable strict port settings for development.
This commit is contained in:
59
src/pages/login/LoginPage.tsx
Normal file
59
src/pages/login/LoginPage.tsx
Normal file
@@ -0,0 +1,59 @@
|
||||
import { FormEvent, useState } from "react";
|
||||
|
||||
import { login, setToken } from "@/api";
|
||||
import { Alert, AlertDescription } from "@/components/ui/alert";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Input } from "@/components/ui/input";
|
||||
|
||||
export function LoginPage({ onDone }: { onDone: () => void }) {
|
||||
const [email, setEmail] = useState("admin@example.com");
|
||||
const [password, setPassword] = useState("ChangeMe123!");
|
||||
const [error, setError] = useState("");
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
const submit = async (event: FormEvent) => {
|
||||
event.preventDefault();
|
||||
setLoading(true);
|
||||
setError("");
|
||||
try {
|
||||
const result = await login(email, password);
|
||||
setToken(result.token);
|
||||
onDone();
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : "登录失败");
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<main className="login-shell">
|
||||
<Card className="login-panel">
|
||||
<CardHeader className="p-0">
|
||||
<span className="login-kicker">万趣运营后台</span>
|
||||
<CardTitle>万趣小程序管理端</CardTitle>
|
||||
<CardDescription>按前台页面结构维护内容、商品和线索。</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent className="p-0">
|
||||
<form className="login-form-stack" onSubmit={submit}>
|
||||
<label>
|
||||
账号
|
||||
<Input value={email} onChange={(event) => setEmail(event.target.value)} autoComplete="username" />
|
||||
</label>
|
||||
<label>
|
||||
密码
|
||||
<Input type="password" value={password} onChange={(event) => setPassword(event.target.value)} autoComplete="current-password" />
|
||||
</label>
|
||||
{error ? (
|
||||
<Alert variant="warning">
|
||||
<AlertDescription>{error}</AlertDescription>
|
||||
</Alert>
|
||||
) : null}
|
||||
<Button disabled={loading}>{loading ? "登录中" : "进入维护台"}</Button>
|
||||
</form>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user