add admin router
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"html/template"
|
||||
"net/http"
|
||||
|
||||
"go_blog/config"
|
||||
@@ -31,12 +32,14 @@ func ListThemes(c *gin.Context) {
|
||||
}
|
||||
|
||||
// 渲染管理页面模板
|
||||
tpl := themeManager.GetTemplate("admin/themes") // 对应 templates/admin/themes.tmpl
|
||||
if tpl == nil {
|
||||
c.String(http.StatusInternalServerError, "模板 'admin/themes' 未找到")
|
||||
// 直接加载 web/admin/themes.tmpl 文件(路径相对于项目根目录)
|
||||
const themesTemplatePath = "web/admin/themes.tmpl" // 定义模板路径常量
|
||||
|
||||
tpl, err := template.ParseFiles(themesTemplatePath)
|
||||
if err != nil {
|
||||
c.String(http.StatusInternalServerError, "模板加载失败: "+err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
c.Header("Content-Type", "text/html; charset=utf-8")
|
||||
err = tpl.Execute(c.Writer, gin.H{
|
||||
"CurrentTheme": themeManager.CurrentTheme(),
|
||||
|
||||
Reference in New Issue
Block a user