Skip to content

Commit

Permalink
feat: update v2.0.10
Browse files Browse the repository at this point in the history
  • Loading branch information
devhaozi committed Jul 22, 2023
1 parent 1689ef4 commit a5e1fbc
Show file tree
Hide file tree
Showing 34 changed files with 3,114 additions and 229 deletions.
12 changes: 9 additions & 3 deletions app/console/commands/panel.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ import (
"os"

"github.com/gookit/color"
"github.com/spf13/cast"

"github.com/goravel/framework/contracts/console"
"github.com/goravel/framework/contracts/console/command"
"github.com/goravel/framework/facades"
"github.com/spf13/cast"

"panel/app/models"
"panel/app/services"
Expand Down Expand Up @@ -73,12 +72,19 @@ func (receiver *Panel) Handle(ctx console.Context) error {
color.Greenln("初始化成功")

case "update":
var task models.Task
err := facades.Orm().Query().Where("status", models.TaskStatusRunning).OrWhere("status", models.TaskStatusWaiting).FirstOrFail(&task)
if err == nil {
color.Redln("当前有任务正在执行,禁止更新")
return nil
}

input := arg1
proxy := false
if input == "y" || input == "Y" || input == "yes" || input == "Yes" {
proxy = true
}
err := tools.UpdatePanel(cast.ToBool(proxy))
err = tools.UpdatePanel(cast.ToBool(proxy))
if err != nil {
color.Redln("更新失败: " + err.Error())
return nil
Expand Down
4 changes: 2 additions & 2 deletions app/http/controllers/cron_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (r *CronController) Add(ctx http.Context) {
return
}
if validator.Fails() {
Error(ctx, http.StatusBadRequest, validator.Errors().All())
Error(ctx, http.StatusBadRequest, validator.Errors().One())
return
}

Expand Down Expand Up @@ -129,7 +129,7 @@ func (r *CronController) Update(ctx http.Context) {
return
}
if validator.Fails() {
Error(ctx, http.StatusBadRequest, validator.Errors().All())
Error(ctx, http.StatusBadRequest, validator.Errors().One())
return
}

Expand Down
9 changes: 8 additions & 1 deletion app/http/controllers/info_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,15 @@ func (c *InfoController) CheckUpdate(ctx http.Context) {
}

func (c *InfoController) Update(ctx http.Context) {
var task models.Task
err := facades.Orm().Query().Where("status", models.TaskStatusRunning).OrWhere("status", models.TaskStatusWaiting).FirstOrFail(&task)
if err == nil {
Error(ctx, http.StatusInternalServerError, "当前有任务正在执行,禁止更新")
return
}

proxy := ctx.Request().InputBool("proxy")
err := tools.UpdatePanel(proxy)
err = tools.UpdatePanel(proxy)
if err != nil {
facades.Log().Error("[面板][InfoController] 更新面板失败 ", err.Error())
Error(ctx, http.StatusInternalServerError, "更新失败: "+err.Error())
Expand Down
Loading

0 comments on commit a5e1fbc

Please sign in to comment.