AnCao/main.go
yanlongqi 441eb215f6 将CSS迁移到Less并添加用户认证功能
主要变更:
- 将所有CSS文件迁移到Less预处理器
- 配置Vite支持Less编译
- 使用Less变量、嵌套和父选择器优化样式代码
- 添加用户注册和登录功能
- 实现用户认证中间件和保护路由
- 新增Profile和Login页面
- 添加底部导航栏组件TabBarLayout
- 更新CLAUDE.md为中文文档

技术改进:
- Less变量统一管理主题色和间距
- CSS嵌套提高代码可读性和可维护性
- 模块化样式组织更清晰

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-03 23:21:38 +08:00

46 lines
1.2 KiB
Go

package main
import (
"ankao/internal/handlers"
"ankao/internal/middleware"
"github.com/gin-gonic/gin"
)
func main() {
// 创建Gin路由器
r := gin.Default()
// 应用自定义中间件
r.Use(middleware.Logger())
// 静态文件服务
r.Static("/static", "./web/static")
r.StaticFile("/", "./web/index.html")
// API路由组
api := r.Group("/api")
{
// 健康检查
api.GET("/health", handlers.HealthCheckHandler)
// 用户相关API
api.POST("/login", handlers.Login) // 用户登录
api.POST("/register", handlers.Register) // 用户注册
// 题目相关API
api.GET("/questions", handlers.GetQuestions) // 获取题目列表
api.GET("/questions/random", handlers.GetRandomQuestion) // 获取随机题目
api.GET("/questions/:id", handlers.GetQuestionByID) // 获取指定题目
api.POST("/submit", handlers.SubmitAnswer) // 提交答案
api.GET("/statistics", handlers.GetStatistics) // 获取统计数据
api.POST("/reset", handlers.ResetProgress) // 重置进度
}
// 启动服务器
port := ":8080"
if err := r.Run(port); err != nil {
panic("服务器启动失败: " + err.Error())
}
}