feat: 重构前端界面并修复认证路径

- 重构主页、关于页、演示页和帖子页的UI,使用现代化的卡片设计和布局
- 添加主题切换功能,支持亮色/暗色模式
- 修复后端认证路由路径,从`/api`改为`/api/auth`
- 更新页面标题为"HLAE中文站"
- 简化Providers组件,移除未使用的主题配置
- 添加Hero组件展示网站主标题和操作按钮
- 优化登录和注册页面的表单验证和UI
- 更新全局样式,添加品牌颜色和主题变量
- 改进导航栏,添加图标和更好的响应式设计
- 优化资源管理模态框,添加图标字段支持
This commit is contained in:
2026-03-10 17:52:32 +08:00
parent e06d464a74
commit 58373a15a9
19 changed files with 638 additions and 293 deletions

View File

@@ -1,6 +1,6 @@
import { useState } from 'react';
import { useNavigate, Link } from 'react-router-dom';
import { Card, Input, Button, Form, toast } from '@heroui/react';
import { Card, Input, Button, Form, toast, TextField, Label, FieldError } from '@heroui/react';
import { signUp } from '../../lib/auth-client';
export default function RegisterPage() {
@@ -9,7 +9,7 @@ export default function RegisterPage() {
const [loading, setLoading] = useState(false);
const navigate = useNavigate();
const handleRegister = async (e: React.FormEvent) => {
const handleRegister = async (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
setLoading(true);
try {
@@ -33,32 +33,50 @@ export default function RegisterPage() {
};
return (
<div className="flex items-center justify-center min-h-screen p-4">
<Card className="w-full max-w-md p-6">
<h1 className="text-2xl font-bold mb-6 text-center"> HLAE </h1>
<Form validationBehavior="native" onSubmit={handleRegister} className="flex flex-col gap-4">
<Input
isRequired
label="邮箱"
placeholder="请输入您的邮箱"
type="email"
value={email}
onChange={(e) => setEmail(e.target.value)}
/>
<Input
isRequired
label="密码"
placeholder="请输入您的密码"
type="password"
value={password}
onChange={(e) => setPassword(e.target.value)}
/>
<Button color="primary" type="submit" isLoading={loading}>
</Button>
<div className="text-center text-sm">
<Link to="/login" className="text-primary hover:underline"></Link>
</div>
<div className="flex flex-col items-center justify-center min-h-[calc(100vh-64px)] p-4">
<Card className="w-full max-w-md">
<Card.Header>
<Card.Title className="text-2xl font-bold text-center w-full"> HLAE </Card.Title>
</Card.Header>
<Form validationBehavior="native" onSubmit={handleRegister}>
<Card.Content className="flex flex-col gap-6">
<TextField
isRequired
name="email"
type="email"
value={email}
onChange={setEmail}
>
<Label></Label>
<Input placeholder="请输入您的邮箱" variant="secondary" />
<FieldError />
</TextField>
<TextField
isRequired
name="password"
type="password"
value={password}
onChange={setPassword}
>
<Label></Label>
<Input placeholder="请输入您的密码" variant="secondary" />
<FieldError />
</TextField>
</Card.Content>
<Card.Footer className="flex flex-col gap-3 mt-2">
<Button type="submit" isPending={loading} fullWidth className="font-bold">
</Button>
<Button as={Link} to="/login" variant="tertiary" fullWidth className="font-bold">
</Button>
<div className="flex justify-center mt-2">
<Link to="/" className="text-sm text-default-500 hover:text-primary transition-colors flex items-center gap-1">
<span> </span>
</Link>
</div>
</Card.Footer>
</Form>
</Card>
</div>