diff --git a/go.mod b/go.mod index 2dafa9f..f2754bd 100644 --- a/go.mod +++ b/go.mod @@ -37,6 +37,7 @@ require ( golang.org/x/text v0.16.0 google.golang.org/grpc v1.63.0 google.golang.org/protobuf v1.34.2 + gopkg.in/yaml.v3 v3.0.1 gorm.io/driver/sqlite v1.5.5 gorm.io/gorm v1.25.10 ) @@ -86,5 +87,4 @@ require ( golang.org/x/time v0.5.0 // indirect golang.org/x/tools v0.22.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/model/config.go b/model/config.go index 0e0d573..bfd25e3 100644 --- a/model/config.go +++ b/model/config.go @@ -6,10 +6,11 @@ import ( "strconv" "strings" - "github.com/knadh/koanf/parsers/yaml" + kyaml "github.com/knadh/koanf/parsers/yaml" "github.com/knadh/koanf/providers/env" "github.com/knadh/koanf/providers/file" "github.com/knadh/koanf/v2" + "gopkg.in/yaml.v3" ) var Languages = map[string]string{ @@ -121,7 +122,7 @@ func (c *Config) Read(path string) error { } if _, err := os.Stat(path); err == nil { - err = c.k.Load(file.Provider(path), yaml.Parser()) + err = c.k.Load(file.Provider(path), kyaml.Parser()) if err != nil { return err } @@ -137,7 +138,7 @@ func (c *Config) Read(path string) error { } if c.Site.Brand == "" { - c.Site.Brand = "NeZha" + c.Site.Brand = "Nezha Monitoring" } if c.Site.CookieName == "" { c.Site.CookieName = "nezha-dashboard" @@ -201,7 +202,7 @@ func (c *Config) updateIgnoredIPNotificationID() { // Save 保存配置文件 func (c *Config) Save() error { c.updateIgnoredIPNotificationID() - data, err := c.k.Marshal(yaml.Parser()) + data, err := yaml.Marshal(c) if err != nil { return err }