mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-02-05 21:20:06 +00:00
✨ add theme hotaru
This commit is contained in:
@@ -2,9 +2,12 @@ package model
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"github.com/fsnotify/fsnotify"
|
||||
"github.com/spf13/viper"
|
||||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
// Config ..
|
||||
@@ -13,6 +16,7 @@ type Config struct {
|
||||
Site struct {
|
||||
Brand string // 站点名称
|
||||
CookieName string // 浏览器 Cookie 名称
|
||||
Theme string
|
||||
}
|
||||
GitHub struct {
|
||||
Admin string // 管理员ID列表
|
||||
@@ -38,11 +42,23 @@ func (c *Config) Read(path string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if c.Site.Theme == "" {
|
||||
c.Site.Theme = "default"
|
||||
}
|
||||
|
||||
c.v.OnConfigChange(func(in fsnotify.Event) {
|
||||
fmt.Println("配置文件更新,重载配置")
|
||||
c.v.Unmarshal(c)
|
||||
fmt.Println("配置文件更新,重载配置", c)
|
||||
})
|
||||
|
||||
go c.v.WatchConfig()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Config) Save() error {
|
||||
data, err := yaml.Marshal(c)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return ioutil.WriteFile(c.v.ConfigFileUsed(), data, os.ModePerm)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user