fix: config fields not generated on first startup (#1016)

* fix: config fields not generated on first startup

* cleanup

* fix reference

* replace yaml module

* remove duplicated fields

* remove yaml.v3 as a direct dependency

* update dependency

* chore
This commit is contained in:
UUBulb
2025-03-03 19:02:25 +08:00
committed by GitHub
parent d972d331e2
commit f1e3613daf
9 changed files with 143 additions and 62 deletions

View File

@@ -11,9 +11,9 @@ import (
"github.com/gin-gonic/gin"
"github.com/patrickmn/go-cache"
"gopkg.in/yaml.v3"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
"sigs.k8s.io/yaml"
"github.com/nezhahq/nezha/model"
"github.com/nezhahq/nezha/pkg/utils"
@@ -22,7 +22,6 @@ import (
var Version = "debug"
var (
Conf *model.Config
Cache *cache.Cache
DB *gorm.DB
Loc *time.Location
@@ -69,15 +68,6 @@ func InitFrontendTemplates() {
}
}
// InitConfigFromPath 从给出的文件路径中加载配置
func InitConfigFromPath(path string) {
Conf = &model.Config{}
err := Conf.Read(path, FrontendTemplates)
if err != nil {
panic(err)
}
}
// InitDBFromPath 从给出的文件路径中加载数据库
func InitDBFromPath(path string) {
var err error