mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-02-04 04:30:05 +00:00
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:
@@ -56,7 +56,7 @@ type Config struct {
|
||||
}
|
||||
|
||||
// Read 读取配置文件并应用
|
||||
func (c *Config) Read(path string, userTemplates []UserTemplate) error {
|
||||
func (c *Config) Read(path string, frontendTemplates []FrontendTemplate) error {
|
||||
c.k = koanf.New(".")
|
||||
c.filePath = path
|
||||
|
||||
@@ -89,8 +89,8 @@ func (c *Config) Read(path string, userTemplates []UserTemplate) error {
|
||||
c.Location = "Asia/Shanghai"
|
||||
}
|
||||
var userTemplateValid bool
|
||||
for _, v := range userTemplates {
|
||||
if v.Path == c.UserTemplate {
|
||||
for _, v := range frontendTemplates {
|
||||
if v.Path == c.UserTemplate && c.UserTemplate != "admin-dist" {
|
||||
userTemplateValid = true
|
||||
break
|
||||
}
|
||||
|
||||
@@ -18,17 +18,19 @@ type SettingForm struct {
|
||||
EnablePlainIPInNotification bool `json:"enable_plain_ip_in_notification,omitempty" validate:"optional"`
|
||||
}
|
||||
|
||||
type UserTemplate struct {
|
||||
type FrontendTemplate struct {
|
||||
Path string `json:"path,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Repository string `json:"repository,omitempty"`
|
||||
Author string `json:"author,omitempty"`
|
||||
Community bool `json:"community,omitempty"`
|
||||
Version string `json:"version,omitempty"`
|
||||
IsAdmin string `json:"is_admin,omitempty"`
|
||||
}
|
||||
|
||||
type SettingResponse struct {
|
||||
Config
|
||||
|
||||
Version string `json:"version,omitempty"`
|
||||
UserTemplates []UserTemplate `json:"user_templates,omitempty"`
|
||||
Version string `json:"version,omitempty"`
|
||||
FrontendTemplates []FrontendTemplate `json:"frontend_templates,omitempty"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user