chore: update theme related code

This commit is contained in:
JustSong 2024-01-01 20:25:53 +08:00
parent 83f95935de
commit 0c022f17cb
3 changed files with 4 additions and 8 deletions

View File

@ -14,6 +14,7 @@ import (
)
func SetWebRouter(router *gin.Engine, buildFS embed.FS) {
indexPageData, _ := buildFS.ReadFile(fmt.Sprintf("web/build/%s/index.html", common.Theme))
router.Use(gzip.Gzip(gzip.DefaultCompression))
router.Use(middleware.GlobalWebRateLimit())
router.Use(middleware.Cache())
@ -24,11 +25,6 @@ func SetWebRouter(router *gin.Engine, buildFS embed.FS) {
return
}
c.Header("Cache-Control", "no-cache")
indexPage, err := buildFS.ReadFile(fmt.Sprintf("web/build/%s/index.html", common.Theme))
if err != nil {
controller.RelayNotFound(c)
return
}
c.Data(http.StatusOK, "text/html; charset=utf-8", indexPage)
c.Data(http.StatusOK, "text/html; charset=utf-8", indexPageData)
})
}

View File

@ -4,7 +4,7 @@
## 提交新的主题
1. 在 `web` 文件夹下新建一个文件夹,文件夹名为主题名。
2. 把你的主题文件放到这个文件夹下。
3. 修改 `package.json` 文件,把 `build` 命令改为:`"build": "react-scripts build && mv build ../build/default"`,其中 `default` 为你的主题名。
3. 修改 `package.json` 文件,把 `build` 命令改为:`"build": "react-scripts build && mv -f build ../build/default"`,其中 `default` 为你的主题名。
## 主题列表
### default

View File

@ -18,7 +18,7 @@
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build && mv build ../build/default",
"build": "react-scripts build && mv -f build ../build/default",
"test": "react-scripts test",
"eject": "react-scripts eject"
},