mirror of
https://github.com/WJQSERVER-STUDIO/ghproxy.git
synced 2026-02-03 00:01:10 +08:00
feat(pages): add page theme configuration and static files
This commit is contained in:
parent
785a74dfeb
commit
8336896979
13 changed files with 477 additions and 25 deletions
24
main.go
24
main.go
|
|
@ -35,8 +35,10 @@ var (
|
|||
)
|
||||
|
||||
var (
|
||||
//go:embed pages/*
|
||||
//go:embed pages/bootstrap/*
|
||||
pagesFS embed.FS
|
||||
//go:embed pages/nebula/*
|
||||
NebulaPagesFS embed.FS
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
@ -159,9 +161,23 @@ func init() {
|
|||
})
|
||||
router.StaticFile("/favicon.ico", faviconPath)
|
||||
} else if !cfg.Pages.Enabled {
|
||||
pages, err := fs.Sub(pagesFS, "pages")
|
||||
if err != nil {
|
||||
logError("Failed when processing pages: %s", err)
|
||||
var pages fs.FS
|
||||
var err error
|
||||
if cfg.Pages.Theme == "bootstrap" {
|
||||
pages, err = fs.Sub(pagesFS, "pages/bootstrap")
|
||||
if err != nil {
|
||||
logError("Failed when processing pages: %s", err)
|
||||
}
|
||||
} else if cfg.Pages.Theme == "nebula" {
|
||||
pages, err = fs.Sub(NebulaPagesFS, "pages/nebula")
|
||||
if err != nil {
|
||||
logError("Failed when processing pages: %s", err)
|
||||
}
|
||||
} else {
|
||||
pages, err = fs.Sub(pagesFS, "pages/bootstrap")
|
||||
if err != nil {
|
||||
logError("Failed when processing pages: %s", err)
|
||||
}
|
||||
}
|
||||
router.GET("/", gin.WrapH(http.FileServer(http.FS(pages))))
|
||||
router.GET("/favicon.ico", gin.WrapH(http.FileServer(http.FS(pages))))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue