修改管理界面设置中的时区时同时也会应用到API节点/API节点默认时区为Asia/Shanghai

This commit is contained in:
GoEdgeLab
2022-09-09 10:28:44 +08:00
parent 80f34d8298
commit 004f82eba2
3 changed files with 40 additions and 1 deletions

View File

@@ -15,6 +15,7 @@ import (
"github.com/TeaOSLab/EdgeAPI/internal/setup"
"github.com/TeaOSLab/EdgeAPI/internal/utils"
"github.com/TeaOSLab/EdgeCommon/pkg/iplibrary"
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
"github.com/go-sql-driver/mysql"
"github.com/iwind/TeaGo/Tea"
"github.com/iwind/TeaGo/dbs"
@@ -132,6 +133,9 @@ func (this *APINode) Start() {
logs.Println("[API_NODE]notify ready ...")
dbs.NotifyReady()
// 设置时区
this.setupTimeZone()
// 读取配置
this.setProgress("DATABASE", "加载API配置")
logs.Println("[API_NODE]reading api config ...")
@@ -811,3 +815,17 @@ func (this *APINode) setProgress(name, description string) {
Description: description,
}
}
// 设置时区
func (this *APINode) setupTimeZone() {
config, err := models.SharedSysSettingDAO.ReadAdminUIConfig(nil, nil)
if err == nil && config != nil {
if len(config.TimeZone) == 0 {
config.TimeZone = nodeconfigs.DefaultTimeZoneLocation
}
location, err := time.LoadLocation(config.TimeZone)
if err == nil && time.Local != location {
time.Local = location
}
}
}