use mysql
This commit is contained in:
21
admin/thememanager.go
Normal file
21
admin/thememanager.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package admin
|
||||
|
||||
import (
|
||||
"go_blog/themes"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
var themeManager = themes.NewManager("themes")
|
||||
var router = gin.Default()
|
||||
|
||||
// 切换主题(管理后台)
|
||||
func switchTheme(c *gin.Context) {
|
||||
newTheme := c.PostForm("theme")
|
||||
if err := themeManager.LoadTheme(newTheme); err != nil {
|
||||
c.JSON(500, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
themeManager.RegisterStaticRoutes(router) // 重新注册静态路由
|
||||
c.JSON(200, gin.H{"status": "success"})
|
||||
}
|
||||
Reference in New Issue
Block a user