Refactor: Load UserTemplates from embedded yaml file (#575)

* Refactor: Load UserTemplates from embedded yaml file

* feat: add version field to UserTemplates

* refactor: use shell script to fetch frontends

* chore: add *-dist to .gitignore

* refactor: rename to FrontendTemplates

BREAKING CHANGE: This commit changes the `user_templates` filed
in the communication json between backend and the admin-frontend.

Keep user config.yml `user_template` filed.
This commit is contained in:
Moraxyc
2024-12-10 21:57:20 +08:00
committed by GitHub
parent 96cbec9dd3
commit 8f8a30c02c
9 changed files with 98 additions and 70 deletions

View File

@@ -23,9 +23,9 @@ func listConfig(c *gin.Context) (model.SettingResponse, error) {
authorized := isMember // TODO || isViewPasswordVerfied
conf := model.SettingResponse{
Config: *singleton.Conf,
Version: singleton.Version,
UserTemplates: singleton.UserTemplates,
Config: *singleton.Conf,
Version: singleton.Version,
FrontendTemplates: singleton.FrontendTemplates,
}
if !authorized {
@@ -59,8 +59,8 @@ func updateConfig(c *gin.Context) (any, error) {
return nil, err
}
var userTemplateValid bool
for _, v := range singleton.UserTemplates {
if v.Path == sf.UserTemplate {
for _, v := range singleton.FrontendTemplates {
if v.Path == sf.UserTemplate && sf.UserTemplate != "admin-dist" {
userTemplateValid = true
break
}

View File

@@ -104,6 +104,7 @@ func main() {
}
// 初始化 dao 包
singleton.InitFrontendTemplates()
singleton.InitConfigFromPath(dashboardCliParam.ConfigFile)
singleton.InitTimezoneAndCache()
singleton.InitDBFromPath(dashboardCliParam.DatebaseLocation)