From 604949de18fb4334f3f62f53a792367db8348633 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 818f34a45..3e7799666 100644 --- a/backend/constant/errs.go +++ b/backend/constant/errs.go @@ -133,3 +133,8 @@ var ( var ( ErrFirewall = "ErrFirewall" ) + +// cronjob +var ( + ErrBashExecute = "ErrBashExecute" +) diff --git a/backend/i18n/lang/en.yaml b/backend/i18n/lang/en.yaml index 029975404..bafc44b66 100644 --- a/backend/i18n/lang/en.yaml +++ b/backend/i18n/lang/en.yaml @@ -124,4 +124,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 f5822bb96..b02f88aa8 100644 --- a/backend/i18n/lang/zh-Hant.yaml +++ b/backend/i18n/lang/zh-Hant.yaml @@ -124,4 +124,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 9039e1dca..bf61ce457 100644 --- a/backend/i18n/lang/zh.yaml +++ b/backend/i18n/lang/zh.yaml @@ -125,3 +125,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 7ccaba64d..633aeed9e 100644 --- a/backend/utils/cmd/cmd.go +++ b/backend/utils/cmd/cmd.go @@ -95,11 +95,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 @@ - +