add routers themes

This commit is contained in:
张超
2025-04-09 16:56:05 +08:00
parent 577cd10161
commit 33cb413a12
14 changed files with 275 additions and 118 deletions

View File

@@ -1,10 +1,9 @@
package parser // Declare the package at the top
package themes // Declare the package at the top
import (
"fmt"
config "go_blog/config" // Adjust import path as needed
"net/http"
"your_project_path/config" // Adjust import path as needed
"your_project_path/themes" // Adjust import path as needed
"github.com/gin-gonic/gin"
)
@@ -24,7 +23,7 @@ func RenderTemplate(c *gin.Context, tmpl string, data gin.H) {
// SwitchTheme handles POST requests to switch the current theme
func SwitchTheme(c *gin.Context) {
newTheme := c.PostForm("theme")
manager := themes.GetManager()
manager := &ThemeManager{} //themes.GetManager()
if err := manager.LoadTheme(newTheme); err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})