使用VUE重构项目
Some checks failed
build / build (api, amd64, linux) (push) Failing after -51s
build / build (api, arm64, linux) (push) Failing after -52s
build / build (api.exe, amd64, windows) (push) Failing after -51s

This commit is contained in:
2026-04-20 00:19:11 +08:00
parent c080bb8d4a
commit db7f1ba82f
12743 changed files with 1250466 additions and 359982 deletions

View File

@@ -3,6 +3,7 @@ package main
import (
"io"
"log"
"net/http"
"os"
"path/filepath"
"strings"
@@ -299,30 +300,31 @@ func registerAdminRoutesV2(v2 *gin.RouterGroup) {
}
func registerWebRoutes(router *gin.Engine) {
themeRoot := filepath.Join(".", "frontend", "theme")
adminRoot := filepath.Join(".", "frontend", "admin")
adminRoot := filepath.Join(".", "frontend", "admin", "dist")
if _, err := os.Stat(themeRoot); err == nil {
router.Static("/theme", themeRoot)
}
if _, err := os.Stat(adminRoot); err == nil {
router.Static("/admin-assets", adminRoot)
}
securePath := "/" + service.GetAdminSecurePath()
subscribePath := "/" + service.GetSubscribePath()
router.GET("/", handler.UserThemePage)
router.GET("/dashboard", handler.UserThemePage)
// Redirect root to admin if needed, or just 404
router.GET("/", func(c *gin.Context) {
c.Redirect(http.StatusTemporaryRedirect, securePath)
})
router.GET(subscribePath+"/:token", handler.Subscribe)
router.GET(securePath, handler.AdminAppPage)
router.GET(securePath+"/", handler.AdminAppPage)
router.GET(securePath+"/plugin-panel/:kind", handler.AdminPluginPanelPage)
router.GET(securePath+"/plugins/:plugin", handler.AdminAppPage)
// Serve Vue admin panel index.html for all admin-related routes (SPA)
router.NoRoute(func(c *gin.Context) {
path := c.Request.URL.Path
if path == securePath || strings.HasPrefix(path, securePath+"/") {
handler.AdminAppPage(c)
return
indexFile := filepath.Join(adminRoot, "index.html")
if _, err := os.Stat(indexFile); err == nil {
c.File(indexFile)
return
}
}
c.JSON(404, gin.H{"message": "not found"})
})