feat: 添加用户登录认证功能

- 新增登录页面(使用 shadcn-svelte 组件)
- 后端添加 JWT 认证 API (/api/auth/login, /api/auth/validate)
- 用户账号通过 server/config.yaml 配置
- 前端路由保护(未登录跳转登录页)
- 侧边栏显示当前用户信息
- 支持退出登录功能
This commit is contained in:
clz
2026-01-11 18:50:01 +08:00
parent 4884993d27
commit 829b3445bc
11 changed files with 639 additions and 16 deletions

View File

@@ -41,6 +41,10 @@ func healthCheck(version string) gin.HandlerFunc {
func setupAPIRoutes(r *gin.Engine) {
api := r.Group("/api")
{
// 认证相关(无需登录)
api.POST("/auth/login", handler.Login)
api.GET("/auth/validate", handler.ValidateToken)
// 账单上传
api.POST("/upload", handler.Upload)
@@ -49,13 +53,13 @@ func setupAPIRoutes(r *gin.Engine) {
// 账单查询
api.GET("/bills", handler.ListBills)
// 手动创建账单
api.POST("/bills/manual", handler.CreateManualBills)
// 月度统计(全部数据)
api.GET("/monthly-stats", handler.MonthlyStats)
// 待复核数据统计
api.GET("/review-stats", handler.ReviewStats)
}