修改管理界面设置中的时区时同时也会应用到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

@@ -6,6 +6,7 @@ import (
"github.com/TeaOSLab/EdgeAPI/internal/remotelogs"
"github.com/TeaOSLab/EdgeAPI/internal/utils"
"github.com/TeaOSLab/EdgeAPI/internal/zero"
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
"github.com/TeaOSLab/EdgeCommon/pkg/systemconfigs"
"github.com/TeaOSLab/EdgeCommon/pkg/userconfigs"
@@ -13,6 +14,7 @@ import (
"github.com/iwind/TeaGo/Tea"
"github.com/iwind/TeaGo/dbs"
"github.com/iwind/TeaGo/types"
"time"
)
type SysSettingDAO dbs.DAO
@@ -211,6 +213,18 @@ func (this *SysSettingDAO) NotifyUpdate(tx *dbs.Tx, code string) error {
switch code {
case systemconfigs.SettingCodeAccessLogQueue:
accessLogQueueChanged <- zero.New()
case systemconfigs.SettingCodeAdminUIConfig:
// 修改当前时区
config, err := this.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
}
}
}
return nil
}