1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-01-19 08:19:15 +08:00

fix: 解决计划任务执行周期错误的问题 (#1349)

This commit is contained in:
ssongliu 2023-06-12 18:42:11 +08:00 committed by GitHub
parent 95bc3d9855
commit 02023102d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 8 deletions

View File

@ -6,7 +6,7 @@ type CronjobCreate struct {
Name string `json:"name" validate:"required"` Name string `json:"name" validate:"required"`
Type string `json:"type" validate:"required"` Type string `json:"type" validate:"required"`
SpecType string `json:"specType" validate:"required"` SpecType string `json:"specType" validate:"required"`
Week int `json:"week" validate:"number,max=7,min=1"` Week int `json:"week" validate:"number,max=6,min=0"`
Day int `json:"day" validate:"number"` Day int `json:"day" validate:"number"`
Hour int `json:"hour" validate:"number"` Hour int `json:"hour" validate:"number"`
Minute int `json:"minute" validate:"number"` Minute int `json:"minute" validate:"number"`
@ -27,7 +27,7 @@ type CronjobUpdate struct {
ID uint `json:"id" validate:"required"` ID uint `json:"id" validate:"required"`
Name string `json:"name" validate:"required"` Name string `json:"name" validate:"required"`
SpecType string `json:"specType" validate:"required"` SpecType string `json:"specType" validate:"required"`
Week int `json:"week" validate:"number,max=7,min=1"` Week int `json:"week" validate:"number,max=6,min=0"`
Day int `json:"day" validate:"number"` Day int `json:"day" validate:"number"`
Hour int `json:"hour" validate:"number"` Hour int `json:"hour" validate:"number"`
Minute int `json:"minute" validate:"number"` Minute int `json:"minute" validate:"number"`

View File

@ -632,8 +632,10 @@ const message = {
cronjob: { cronjob: {
cronTask: 'Task', cronTask: 'Task',
changeStatus: 'Change status', changeStatus: 'Change status',
disableMsg: 'The cronjob cannot continue to run after it is stopped. Do you want to stop it?', disableMsg:
enableMsg: 'The cronjob has been stopped. Enable now?', 'Stopping the scheduled task will result in the task no longer automatically executing. Do you want to continue?',
enableMsg:
'Enabling the scheduled task will allow the task to automatically execute on a regular basis. Do you want to continue?',
taskType: 'Task type', taskType: 'Task type',
record: 'Records', record: 'Records',
shell: 'Shell script', shell: 'Shell script',

View File

@ -633,8 +633,8 @@ const message = {
cronjob: { cronjob: {
cronTask: '计划任务', cronTask: '计划任务',
changeStatus: '状态修改', changeStatus: '状态修改',
disableMsg: '计划任务停止后将无法继续运行是否停止', disableMsg: '停止计划任务会导致该任务不再自动执行是否继续',
enableMsg: '该计划任务已停止是否启用', enableMsg: '启用计划任务会让该任务定期自动执行是否继续',
taskType: '任务类型', taskType: '任务类型',
record: '报告', record: '报告',
shell: 'Shell 脚本', shell: 'Shell 脚本',

View File

@ -330,7 +330,7 @@ const weekOptions = [
{ label: i18n.global.t('cronjob.thursday'), value: 4 }, { label: i18n.global.t('cronjob.thursday'), value: 4 },
{ label: i18n.global.t('cronjob.friday'), value: 5 }, { label: i18n.global.t('cronjob.friday'), value: 5 },
{ label: i18n.global.t('cronjob.saturday'), value: 6 }, { label: i18n.global.t('cronjob.saturday'), value: 6 },
{ label: i18n.global.t('cronjob.sunday'), value: 7 }, { label: i18n.global.t('cronjob.sunday'), value: 0 },
]; ];
const rules = reactive({ const rules = reactive({
name: [Rules.requiredInput], name: [Rules.requiredInput],
@ -456,7 +456,9 @@ function checkScript() {
case 'perMonth': case 'perMonth':
return row.day > 0 && row.day < 32 && row.hour >= 0 && row.hour < 24 && row.minute >= 0 && row.minute < 60; return row.day > 0 && row.day < 32 && row.hour >= 0 && row.hour < 24 && row.minute >= 0 && row.minute < 60;
case 'perWeek': case 'perWeek':
return row.week > 0 && row.week < 8 && row.hour >= 0 && row.hour < 24 && row.minute >= 0 && row.minute < 60; return (
row.week >= 0 && row.week < 7 && row.hour >= 0 && row.hour < 24 && row.minute >= 0 && row.minute < 60
);
case 'perDay': case 'perDay':
return row.hour >= 0 && row.hour < 24 && row.minute >= 0 && row.minute < 60; return row.hour >= 0 && row.hour < 24 && row.minute >= 0 && row.minute < 60;
case 'perHour': case 'perHour':