odtool / main.go
bot
初始化
9f6f5a5
raw
history blame contribute delete
520 Bytes
package main
import (
"alist/api"
"github.com/gin-gonic/gin"
)
func main() {
r := gin.Default()
// 提供静态资源(Vue 构建后的目录)
r.Static("/assets", "./dist/assets")
r.LoadHTMLFiles("./dist/index.html")
// 所有接口前缀为 /api
apiGroup := r.Group("/api")
api.Setup(apiGroup)
// 所有非 API 的路由都返回 index.html(用于前端路由)
r.NoRoute(func(c *gin.Context) {
c.HTML(200, "index.html", nil)
})
// 启动服务
r.Run(":8080") // 默认监听 8080 端口
}