Skip to content

Commit 83f0747

Browse files
committed
✨ Change theme
1 parent 708ea22 commit 83f0747

3 files changed

Lines changed: 25 additions & 0 deletions

File tree

‎controller/console/themectl.go‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,28 @@ import (
2727
log "github.com/sirupsen/logrus"
2828
)
2929

30+
func UpdateThemeAction(c *gin.Context) {
31+
result := util.NewResult()
32+
defer c.JSON(http.StatusOK, result)
33+
34+
theme := c.Param("id")
35+
36+
sessionData := util.GetSession(c)
37+
38+
settings := []*model.Setting{
39+
&model.Setting{
40+
Category: model.SettingCategoryTheme,
41+
Name: model.SettingNameThemeName,
42+
Value: theme,
43+
BlogID: sessionData.BID,
44+
},
45+
}
46+
if err := service.Setting.UpdateSettings(model.SettingCategoryTheme, settings); nil != err {
47+
result.Code = -1
48+
result.Msg = err.Error()
49+
}
50+
}
51+
3052
func GetThemesAction(c *gin.Context) {
3153
result := util.NewResult()
3254
defer c.JSON(http.StatusOK, result)

‎controller/router.go‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ func MapRoutes() *gin.Engine {
7171
consoleGroup.Use(console.LoginCheck())
7272

7373
consoleGroup.GET("/themes", console.GetThemesAction)
74+
consoleGroup.PUT("/themes/:id", console.UpdateThemeAction)
7475
consoleGroup.GET("/tags", console.GetTagsAction)
7576
consoleGroup.POST("/articles", console.AddArticleAction)
7677
consoleGroup.GET("/articles", console.GetArticlesAction)
@@ -135,6 +136,7 @@ func routePath(c *gin.Context) {
135136
return
136137
case util.PathArchives:
137138
showArchivesAction(c)
139+
138140
return
139141
case util.PathAuthors:
140142
showAuthorsAction(c)

‎theme/x/Sky/index.html‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Placeholder

0 commit comments

Comments
 (0)