mirror of
				https://github.com/TeaOSLab/EdgeAPI.git
				synced 2025-11-04 07:50:25 +08:00 
			
		
		
		
	修改管理界面设置中的时区时同时也会应用到API节点/API节点默认时区为Asia/Shanghai
This commit is contained in:
		@@ -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
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user