add admin router

This commit is contained in:
张超
2025-06-18 18:34:08 +08:00
parent 67c85327ee
commit 4c9f6c140f
4 changed files with 32 additions and 86 deletions

View File

@@ -24,26 +24,3 @@ func ShowAdminIndexPage(c *gin.Context) {
c.String(http.StatusInternalServerError, "渲染模板失败: "+err.Error())
}
}
// ShowThemeSwitchPage 渲染主题切换页面
func ShowThemeSwitchPage(c *gin.Context) {
// 假设主题列表存储在固定路径或需要手动维护(示例数据,需根据实际情况修改)
themes := []string{"default", "dark", "light"} // 示例主题列表
currentTheme := "default" // 示例当前主题(需根据实际存储方式获取)
// 直接加载 web/admin 目录下的 themes.tmpl 模板(需确保文件存在)
tpl, err := template.ParseFiles("web/admin/themes.tmpl")
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": currentTheme,
"Themes": themes,
})
if err != nil {
c.String(http.StatusInternalServerError, "渲染模板失败: "+err.Error())
}
}