mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2024-11-10 09:02:42 +08:00
fix: 统一时区获取方法 (#6175)
This commit is contained in:
parent
cc7981229c
commit
64405fba3d
12 changed files with 21 additions and 24 deletions
|
@ -72,7 +72,7 @@ func (b *BaseApi) SearchJobRecords(c *gin.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
loc, _ := time.LoadLocation(common.LoadTimeZone())
|
loc, _ := time.LoadLocation(common.LoadTimeZoneByCmd())
|
||||||
req.StartTime = req.StartTime.In(loc)
|
req.StartTime = req.StartTime.In(loc)
|
||||||
req.EndTime = req.EndTime.In(loc)
|
req.EndTime = req.EndTime.In(loc)
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ func (b *BaseApi) LoadMonitor(c *gin.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
loc, _ := time.LoadLocation(common.LoadTimeZone())
|
loc, _ := time.LoadLocation(common.LoadTimeZoneByCmd())
|
||||||
req.StartTime = req.StartTime.In(loc)
|
req.StartTime = req.StartTime.In(loc)
|
||||||
req.EndTime = req.EndTime.In(loc)
|
req.EndTime = req.EndTime.In(loc)
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ func (u *BackupRepo) ListRecord(opts ...DBOption) ([]model.BackupRecord, error)
|
||||||
for _, opt := range opts {
|
for _, opt := range opts {
|
||||||
db = opt(db)
|
db = opt(db)
|
||||||
}
|
}
|
||||||
err := db.Debug().Find(&users).Error
|
err := db.Find(&users).Error
|
||||||
return users, err
|
return users, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -140,7 +140,7 @@ func (c *ClamService) SearchWithPage(req dto.SearchClamWithPage) (int64, interfa
|
||||||
item.LastHandleDate = "-"
|
item.LastHandleDate = "-"
|
||||||
datas = append(datas, item)
|
datas = append(datas, item)
|
||||||
}
|
}
|
||||||
nyc, _ := time.LoadLocation(common.LoadTimeZone())
|
nyc, _ := time.LoadLocation(common.LoadTimeZoneByCmd())
|
||||||
for i := 0; i < len(datas); i++ {
|
for i := 0; i < len(datas); i++ {
|
||||||
logPaths := loadFileByName(datas[i].Name)
|
logPaths := loadFileByName(datas[i].Name)
|
||||||
sort.Slice(logPaths, func(i, j int) bool {
|
sort.Slice(logPaths, func(i, j int) bool {
|
||||||
|
@ -323,7 +323,7 @@ func (c *ClamService) LoadRecords(req dto.ClamLogSearch) (int64, interface{}, er
|
||||||
}
|
}
|
||||||
|
|
||||||
var filterFiles []string
|
var filterFiles []string
|
||||||
nyc, _ := time.LoadLocation(common.LoadTimeZone())
|
nyc, _ := time.LoadLocation(common.LoadTimeZoneByCmd())
|
||||||
for _, item := range logPaths {
|
for _, item := range logPaths {
|
||||||
t1, err := time.ParseInLocation(constant.DateTimeSlimLayout, item, nyc)
|
t1, err := time.ParseInLocation(constant.DateTimeSlimLayout, item, nyc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -52,7 +52,7 @@ func (u *ContainerService) PageVolume(req dto.SearchWithPage) (int64, interface{
|
||||||
records = list.Volumes[start:end]
|
records = list.Volumes[start:end]
|
||||||
}
|
}
|
||||||
|
|
||||||
nyc, _ := time.LoadLocation(common.LoadTimeZone())
|
nyc, _ := time.LoadLocation(common.LoadTimeZoneByCmd())
|
||||||
for _, item := range records {
|
for _, item := range records {
|
||||||
tag := make([]string, 0)
|
tag := make([]string, 0)
|
||||||
for _, val := range item.Labels {
|
for _, val := range item.Labels {
|
||||||
|
|
|
@ -312,7 +312,7 @@ func (u *SSHService) LoadLog(req dto.SearchSSHLog) (*dto.SSHLog, error) {
|
||||||
|
|
||||||
showCountFrom := (req.Page - 1) * req.PageSize
|
showCountFrom := (req.Page - 1) * req.PageSize
|
||||||
showCountTo := req.Page * req.PageSize
|
showCountTo := req.Page * req.PageSize
|
||||||
nyc, _ := time.LoadLocation(common.LoadTimeZone())
|
nyc, _ := time.LoadLocation(common.LoadTimeZoneByCmd())
|
||||||
qqWry, err := qqwry.NewQQwry()
|
qqWry, err := qqwry.NewQQwry()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
global.LOG.Errorf("load qqwry datas failed: %s", err)
|
global.LOG.Errorf("load qqwry datas failed: %s", err)
|
||||||
|
|
|
@ -17,14 +17,14 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func Run() {
|
func Run() {
|
||||||
nyc, _ := time.LoadLocation(common.LoadTimeZone())
|
nyc, _ := time.LoadLocation(common.LoadTimeZoneByCmd())
|
||||||
global.Cron = cron.New(cron.WithLocation(nyc), cron.WithChain(cron.Recover(cron.DefaultLogger)), cron.WithChain(cron.DelayIfStillRunning(cron.DefaultLogger)))
|
global.Cron = cron.New(cron.WithLocation(nyc), cron.WithChain(cron.Recover(cron.DefaultLogger)), cron.WithChain(cron.DelayIfStillRunning(cron.DefaultLogger)))
|
||||||
|
|
||||||
var (
|
var (
|
||||||
interval model.Setting
|
interval model.Setting
|
||||||
status model.Setting
|
status model.Setting
|
||||||
)
|
)
|
||||||
syncBeforeStart()
|
go syncBeforeStart()
|
||||||
if err := global.DB.Where("key = ?", "MonitorStatus").Find(&status).Error; err != nil {
|
if err := global.DB.Where("key = ?", "MonitorStatus").Find(&status).Error; err != nil {
|
||||||
global.LOG.Errorf("load monitor status from db failed, err: %v", err)
|
global.LOG.Errorf("load monitor status from db failed, err: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
package job
|
package job
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"path"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto/request"
|
"github.com/1Panel-dev/1Panel/backend/app/dto/request"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/repo"
|
"github.com/1Panel-dev/1Panel/backend/app/repo"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/service"
|
"github.com/1Panel-dev/1Panel/backend/app/service"
|
||||||
|
@ -8,9 +12,6 @@ import (
|
||||||
"github.com/1Panel-dev/1Panel/backend/global"
|
"github.com/1Panel-dev/1Panel/backend/global"
|
||||||
"github.com/1Panel-dev/1Panel/backend/utils/common"
|
"github.com/1Panel-dev/1Panel/backend/utils/common"
|
||||||
"github.com/1Panel-dev/1Panel/backend/utils/files"
|
"github.com/1Panel-dev/1Panel/backend/utils/files"
|
||||||
"path"
|
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type ssl struct {
|
type ssl struct {
|
||||||
|
@ -25,7 +26,7 @@ func (ssl *ssl) Run() {
|
||||||
sslRepo := repo.NewISSLRepo()
|
sslRepo := repo.NewISSLRepo()
|
||||||
sslService := service.NewIWebsiteSSLService()
|
sslService := service.NewIWebsiteSSLService()
|
||||||
sslList, _ := sslRepo.List()
|
sslList, _ := sslRepo.List()
|
||||||
nyc, _ := time.LoadLocation(common.LoadTimeZone())
|
nyc, _ := time.LoadLocation(common.LoadTimeZoneByCmd())
|
||||||
global.LOG.Info("The scheduled certificate update task is currently in progress ...")
|
global.LOG.Info("The scheduled certificate update task is currently in progress ...")
|
||||||
now := time.Now().Add(10 * time.Second)
|
now := time.Now().Add(10 * time.Second)
|
||||||
for _, s := range sslList {
|
for _, s := range sslList {
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
package job
|
package job
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/dto/request"
|
"github.com/1Panel-dev/1Panel/backend/app/dto/request"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/model"
|
"github.com/1Panel-dev/1Panel/backend/app/model"
|
||||||
"github.com/1Panel-dev/1Panel/backend/app/repo"
|
"github.com/1Panel-dev/1Panel/backend/app/repo"
|
||||||
|
@ -8,8 +11,6 @@ import (
|
||||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
"github.com/1Panel-dev/1Panel/backend/constant"
|
||||||
"github.com/1Panel-dev/1Panel/backend/global"
|
"github.com/1Panel-dev/1Panel/backend/global"
|
||||||
"github.com/1Panel-dev/1Panel/backend/utils/common"
|
"github.com/1Panel-dev/1Panel/backend/utils/common"
|
||||||
"sync"
|
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type website struct{}
|
type website struct{}
|
||||||
|
@ -19,7 +20,7 @@ func NewWebsiteJob() *website {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *website) Run() {
|
func (w *website) Run() {
|
||||||
nyc, _ := time.LoadLocation(common.LoadTimeZone())
|
nyc, _ := time.LoadLocation(common.LoadTimeZoneByCmd())
|
||||||
websites, _ := repo.NewIWebsiteRepo().List()
|
websites, _ := repo.NewIWebsiteRepo().List()
|
||||||
global.LOG.Info("Website scheduled task in progress ...")
|
global.LOG.Info("Website scheduled task in progress ...")
|
||||||
now := time.Now().Add(10 * time.Minute)
|
now := time.Now().Add(10 * time.Minute)
|
||||||
|
|
|
@ -30,7 +30,7 @@ func PasswordExpired() gin.HandlerFunc {
|
||||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypePasswordExpired, err)
|
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypePasswordExpired, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
loc, _ := time.LoadLocation(common.LoadTimeZone())
|
loc, _ := time.LoadLocation(common.LoadTimeZoneByCmd())
|
||||||
expiredTime, err := time.ParseInLocation(constant.DateTimeLayout, extime.Value, loc)
|
expiredTime, err := time.ParseInLocation(constant.DateTimeLayout, extime.Value, loc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
helper.ErrorWithDetail(c, constant.CodePasswordExpired, constant.ErrTypePasswordExpired, err)
|
helper.ErrorWithDetail(c, constant.CodePasswordExpired, constant.ErrTypePasswordExpired, err)
|
||||||
|
|
|
@ -256,13 +256,6 @@ func LoadSizeUnit2F(value float64) string {
|
||||||
return fmt.Sprintf("%.2f", value)
|
return fmt.Sprintf("%.2f", value)
|
||||||
}
|
}
|
||||||
|
|
||||||
func LoadTimeZone() string {
|
|
||||||
loc := time.Now().Location()
|
|
||||||
if _, err := time.LoadLocation(loc.String()); err != nil {
|
|
||||||
return "Asia/Shanghai"
|
|
||||||
}
|
|
||||||
return loc.String()
|
|
||||||
}
|
|
||||||
func LoadTimeZoneByCmd() string {
|
func LoadTimeZoneByCmd() string {
|
||||||
loc := time.Now().Location().String()
|
loc := time.Now().Location().String()
|
||||||
if _, err := time.LoadLocation(loc); err != nil {
|
if _, err := time.LoadLocation(loc); err != nil {
|
||||||
|
|
|
@ -131,6 +131,8 @@ const onSave = async (formEl: FormInstance | undefined) => {
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
|
let href = window.location.href;
|
||||||
|
window.open(href, '_self');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue