diff --git a/backend/app/dto/cronjob.go b/backend/app/dto/cronjob.go index 030bb716a..6317c9d7c 100644 --- a/backend/app/dto/cronjob.go +++ b/backend/app/dto/cronjob.go @@ -53,6 +53,7 @@ type CronjobDownload struct { } type CronjobClean struct { + IsDelete bool `json:"isDelete"` CleanData bool `json:"cleanData"` CronjobID uint `json:"cronjobID" validate:"required"` } diff --git a/backend/app/service/cornjob.go b/backend/app/service/cornjob.go index 909f1554a..57b9be2d3 100644 --- a/backend/app/service/cornjob.go +++ b/backend/app/service/cornjob.go @@ -108,7 +108,8 @@ func (u *CronjobService) CleanRecord(req dto.CronjobClean) error { } else { u.removeExpiredLog(cronjob) } - } else { + } + if req.IsDelete { records, _ := backupRepo.ListRecord(backupRepo.WithByCronID(cronjob.ID)) for _, records := range records { records.CronjobID = 0 @@ -224,7 +225,7 @@ func (u *CronjobService) Delete(req dto.CronjobBatchDelete) error { global.Cron.Remove(cron.EntryID(idItem)) } global.LOG.Infof("stop cronjob entryID: %s", cronjob.EntryIDs) - if err := u.CleanRecord(dto.CronjobClean{CronjobID: id, CleanData: req.CleanData}); err != nil { + if err := u.CleanRecord(dto.CronjobClean{CronjobID: id, CleanData: req.CleanData, IsDelete: true}); err != nil { return err } if err := cronjobRepo.Delete(commonRepo.WithByID(id)); err != nil { diff --git a/cmd/server/docs/docs.go b/cmd/server/docs/docs.go index f53be5dfa..60a791651 100644 --- a/cmd/server/docs/docs.go +++ b/cmd/server/docs/docs.go @@ -14924,6 +14924,9 @@ const docTemplate = `{ }, "cronjobID": { "type": "integer" + }, + "isDelete": { + "type": "boolean" } } }, diff --git a/cmd/server/docs/swagger.json b/cmd/server/docs/swagger.json index 239f9a4be..38fd1885e 100644 --- a/cmd/server/docs/swagger.json +++ b/cmd/server/docs/swagger.json @@ -14917,6 +14917,9 @@ }, "cronjobID": { "type": "integer" + }, + "isDelete": { + "type": "boolean" } } }, diff --git a/cmd/server/docs/swagger.yaml b/cmd/server/docs/swagger.yaml index b79d8490f..ef7cf3410 100644 --- a/cmd/server/docs/swagger.yaml +++ b/cmd/server/docs/swagger.yaml @@ -573,6 +573,8 @@ definitions: type: boolean cronjobID: type: integer + isDelete: + type: boolean required: - cronjobID type: object diff --git a/frontend/src/components/upload/index.vue b/frontend/src/components/upload/index.vue index 3c7f866a3..b95a6edad 100644 --- a/frontend/src/components/upload/index.vue +++ b/frontend/src/components/upload/index.vue @@ -322,16 +322,7 @@ const buttons = [ { label: i18n.global.t('commons.button.recover'), click: (row: File.File) => { - if (type.value !== 'app') { - onRecover(row); - } else { - ElMessageBox.confirm(i18n.global.t('app.restoreWarn'), i18n.global.t('commons.button.recover'), { - confirmButtonText: i18n.global.t('commons.button.confirm'), - cancelButtonText: i18n.global.t('commons.button.cancel'), - }).then(async () => { - onRecover(row); - }); - } + onRecover(row); }, }, { diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index 132e14071..f6d8a523e 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -1577,8 +1577,6 @@ const message = { upgradeHelper: 'The abnormal application needs to be synchronized to the normal state first', installWarn: 'Currently, if the port external access is not checked, it will not be able to access through the external network IP: port. Do you want to continue?', - restoreWarn: - 'The restore operation will delete the current data of the application and restart it. This operation cannot be rolled back, continue?', showIgnore: 'View ignore application', cancelIgnore: 'Cancel ignore', ignoreList: 'ignore list', diff --git a/frontend/src/lang/modules/tw.ts b/frontend/src/lang/modules/tw.ts index 8f2e80c20..8f49394a6 100644 --- a/frontend/src/lang/modules/tw.ts +++ b/frontend/src/lang/modules/tw.ts @@ -1476,7 +1476,6 @@ const message = { installHelper: '配置鏡像加速可以解決鏡像拉取失敗的問題', upgradeHelper: '異常應用需要先同步到正常狀態', installWarn: '當前未勾選端口外部訪問,將無法通過外網IP:端口訪問,是否繼續? ', - restoreWarn: '恢復操作將刪除該應用當前數據並重啟。此操作不可回滾,是否繼續?', showIgnore: '查看忽略應用', cancelIgnore: '取消忽略', ignoreList: '忽略列表', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index fbcc089ed..20a6d7156 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -1476,7 +1476,6 @@ const message = { installHelper: '配置镜像加速可以解决镜像拉取失败的问题', upgradeHelper: '异常应用需要先同步到正常状态', installWarn: '当前未勾选端口外部访问,将无法通过外网IP:端口访问,是否继续?', - restoreWarn: '恢复操作将删除该应用当前数据并重启。此操作不可回滚,是否继续?', showIgnore: '查看忽略应用', cancelIgnore: '取消忽略', ignoreList: '忽略列表', diff --git a/frontend/src/views/cronjob/index.vue b/frontend/src/views/cronjob/index.vue index ebc4c6896..e11ff1afe 100644 --- a/frontend/src/views/cronjob/index.vue +++ b/frontend/src/views/cronjob/index.vue @@ -304,9 +304,16 @@ const onDelete = async (row: Cronjob.CronjobInfo | null) => { }; const onSubmitDelete = async () => { - await deleteCronjob({ ids: operateIDs.value, cleanData: cleanData.value }); - MsgSuccess(i18n.global.t('commons.msg.deleteSuccess')); - search(); + loading.value = true; + await deleteCronjob({ ids: operateIDs.value, cleanData: cleanData.value }) + .then(() => { + loading.value = false; + MsgSuccess(i18n.global.t('commons.msg.deleteSuccess')); + search(); + }) + .catch(() => { + loading.value = false; + }); }; const onChangeStatus = async (id: number, status: string) => {