// routes/routes.go // 路由注册器 - 统一管理所有路由 package routes import ( "path/filepath" "github.com/gin-gonic/gin" ) // RegisterRoutes 注册所有路由 func RegisterRoutes(r *gin.Engine) { // 注册静态资源路由 registerStaticRoutes(r) // 注册页面路由 registerPageRoutes(r) // 注册API路由 registerAPIAppRoutes(r) registerAPIWebRoutes(r) // 404页面处理 - 所有未匹配的路由都返回404页面 r.NoRoute(func(c *gin.Context) { staticPath := getStaticPath() c.File(filepath.Join(staticPath, "html", "404.html")) }) }