embed frontend files

This commit is contained in:
Simon Ding
2024-07-07 12:19:38 +08:00
parent 198e5fd43d
commit edb95df582
18 changed files with 303 additions and 40 deletions

View File

@@ -4,7 +4,9 @@ import (
"polaris/db"
"polaris/log"
"polaris/pkg/tmdb"
"polaris/ui"
"github.com/gin-contrib/static"
"github.com/hekmon/transmissionrpc"
"github.com/robfig/cron"
@@ -15,9 +17,9 @@ import (
func NewServer(db *db.Client) *Server {
r := gin.Default()
return &Server{
r: r,
db: db,
cron: cron.New(),
r: r,
db: db,
cron: cron.New(),
tasks: make(map[string]*transmissionrpc.Torrent),
}
}
@@ -27,7 +29,7 @@ type Server struct {
db *db.Client
cron *cron.Cron
language string
tasks map[string]*transmissionrpc.Torrent
tasks map[string]*transmissionrpc.Torrent
}
func (s *Server) scheduler() {
@@ -42,6 +44,8 @@ func (s *Server) checkTasks() {
func (s *Server) Serve() error {
s.scheduler()
//st, _ := fs.Sub(ui.Web, "build/web")
s.r.Use(static.Serve("/", static.EmbedFolder(ui.Web, "build/web")))
api := s.r.Group("/api/v1")