From 8cbbef1ac09d61c7c7f872edaafe971906812d5f Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Mon, 23 Oct 2023 11:28:33 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E8=AE=A1=E5=88=92?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E8=84=9A=E6=9C=AC=E6=89=A7=E8=A1=8C=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E5=A4=84=E7=90=86=20(#2635)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/constant/errs.go | 5 +++++ backend/i18n/lang/en.yaml | 5 ++++- backend/i18n/lang/zh-Hant.yaml | 5 ++++- backend/i18n/lang/zh.yaml | 3 +++ backend/utils/cmd/cmd.go | 5 +++-- backend/utils/encrypt/encrypt_test.go | 26 -------------------------- frontend/src/views/cronjob/index.vue | 2 +- 7 files changed, 20 insertions(+), 31 deletions(-) delete mode 100644 backend/utils/encrypt/encrypt_test.go diff --git a/backend/constant/errs.go b/backend/constant/errs.go index 2281a3804..79a456bae 100644 --- a/backend/constant/errs.go +++ b/backend/constant/errs.go @@ -135,3 +135,8 @@ var ( var ( ErrFirewall = "ErrFirewall" ) + +// cronjob +var ( + ErrBashExecute = "ErrBashExecute" +) diff --git a/backend/i18n/lang/en.yaml b/backend/i18n/lang/en.yaml index 3d5483904..97e5a6a0a 100644 --- a/backend/i18n/lang/en.yaml +++ b/backend/i18n/lang/en.yaml @@ -128,4 +128,7 @@ ErrConfigAlreadyExist: "A configuration file with the same name already exists" ErrUserFindErr: "Failed to find user {{ .name }} {{ .err }}" #ssh -ErrFirewall: "No firewalld or ufw service is detected. Please check and try again!" \ No newline at end of file +ErrFirewall: "No firewalld or ufw service is detected. Please check and try again!" + +#cronjob +ErrBashExecute: "Script execution error, please check stderr-related information in the task output text field." \ No newline at end of file diff --git a/backend/i18n/lang/zh-Hant.yaml b/backend/i18n/lang/zh-Hant.yaml index 631e23a9e..e73fae535 100644 --- a/backend/i18n/lang/zh-Hant.yaml +++ b/backend/i18n/lang/zh-Hant.yaml @@ -128,4 +128,7 @@ ErrConfigAlreadyExist: "已存在同名配置文件" ErrUserFindErr: "用戶 {{ .name }} 查找失敗 {{ .err }}" #ssh -ErrFirewall: "當前未檢測到系統 firewalld 或 ufw 服務,請檢查後重試!" \ No newline at end of file +ErrFirewall: "當前未檢測到系統 firewalld 或 ufw 服務,請檢查後重試!" + +#cronjob +ErrBashExecute: "腳本執行錯誤,請在任務輸出文本區域中查看 stderr 相關信息。" \ No newline at end of file diff --git a/backend/i18n/lang/zh.yaml b/backend/i18n/lang/zh.yaml index ba66325c9..f2ccf246d 100644 --- a/backend/i18n/lang/zh.yaml +++ b/backend/i18n/lang/zh.yaml @@ -129,3 +129,6 @@ ErrUserFindErr: "用户 {{ .name }} 查找失败 {{ .err }}" #ssh ErrFirewall: "当前未检测到系统 firewalld 或 ufw 服务,请检查后重试!" + +#cronjob +ErrBashExecute: "脚本执行错误,请在任务输出文本域中查看 stderr 相关信息。" diff --git a/backend/utils/cmd/cmd.go b/backend/utils/cmd/cmd.go index 359834dad..deea87535 100644 --- a/backend/utils/cmd/cmd.go +++ b/backend/utils/cmd/cmd.go @@ -88,11 +88,12 @@ func ExecCronjobWithTimeOut(cmdStr string, workdir string, timeout time.Duration errMsg := "" if len(stderr.String()) != 0 { - errMsg = fmt.Sprintf("stderr:\n %s", stderr.String()) + errMsg = fmt.Sprintf("stderr:\n%s", stderr.String()) + err = buserr.New(constant.ErrBashExecute) } if len(stdout.String()) != 0 { if len(errMsg) != 0 { - errMsg = fmt.Sprintf("%s \n\n; stdout:\n %s", errMsg, stdout.String()) + errMsg = fmt.Sprintf("%s \n\n stdout:\n%s", errMsg, stdout.String()) } else { errMsg = fmt.Sprintf("stdout:\n %s", stdout.String()) } diff --git a/backend/utils/encrypt/encrypt_test.go b/backend/utils/encrypt/encrypt_test.go deleted file mode 100644 index 04e2e084f..000000000 --- a/backend/utils/encrypt/encrypt_test.go +++ /dev/null @@ -1,26 +0,0 @@ -package encrypt - -import ( - "fmt" - "testing" - - "github.com/1Panel-dev/1Panel/backend/init/viper" -) - -func TestStringEncrypt(t *testing.T) { - viper.Init() - p, err := StringEncrypt("1Panel@2022") - if err != nil { - t.Fatal(err) - } - fmt.Println(p) -} - -func TestStringDecrypt(t *testing.T) { - viper.Init() - p, err := StringDecrypt("dXn5bVtea+KVLDrLJlpnPIJNfW8TAMmqX1QNMdSGp88=") - if err != nil { - t.Fatal(err) - } - fmt.Println(p) -} diff --git a/frontend/src/views/cronjob/index.vue b/frontend/src/views/cronjob/index.vue index 9fe104fd0..3897db0a1 100644 --- a/frontend/src/views/cronjob/index.vue +++ b/frontend/src/views/cronjob/index.vue @@ -77,7 +77,7 @@ - +