This commit is contained in:
Daniel 2024-09-25 23:44:10 +08:00
parent 1f47be1a11
commit 2deb986c87
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
3 changed files with 106 additions and 7 deletions

View file

@ -51,7 +51,7 @@ var Conf *AppConf
// AppConf 维护应用元数据,保存在 ~/.siyuan/conf.json。
type AppConf struct {
LogLevel string `json:"logLevel"` // 日志级别:Off, Trace, Debug, Info, Warn, Error, Fatal
LogLevel string `json:"logLevel"` // 日志级别:off, trace, debug, info, warn, error, fatal
Appearance *conf.Appearance `json:"appearance"` // 外观
Langs []*conf.Lang `json:"langs"` // 界面语言列表
Lang string `json:"lang"` // 选择的界面语言,同 Appearance.Lang
@ -87,6 +87,10 @@ type AppConf struct {
m *sync.Mutex
}
func NewAppConf() *AppConf {
return &AppConf{LogLevel: "debug", m: &sync.Mutex{}}
}
func (conf *AppConf) GetUILayout() *conf.UILayout {
conf.m.Lock()
defer conf.m.Unlock()
@ -114,7 +118,7 @@ func (conf *AppConf) SetUser(user *conf.User) {
func InitConf() {
initLang()
Conf = &AppConf{LogLevel: "debug", m: &sync.Mutex{}}
Conf = NewAppConf()
confPath := filepath.Join(util.ConfDir, "conf.json")
if gulu.File.IsExist(confPath) {
if data, err := os.ReadFile(confPath); err != nil {