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"`
Type string `json:"type" 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"`
Hour int `json:"hour" validate:"number"`
Minute int `json:"minute" validate:"number"`
@ -27,7 +27,7 @@ type CronjobUpdate struct {
ID uint `json:"id" validate:"required"`
Name string `json:"name" 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"`
Hour int `json:"hour" validate:"number"`
Minute int `json:"minute" validate:"number"`

View File

@ -632,8 +632,10 @@ const message = {
cronjob: {
cronTask: 'Task',
changeStatus: 'Change status',
disableMsg: 'The cronjob cannot continue to run after it is stopped. Do you want to stop it?',
enableMsg: 'The cronjob has been stopped. Enable now?',
disableMsg:
'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',
record: 'Records',
shell: 'Shell script',

View File

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

View File

@ -330,7 +330,7 @@ const weekOptions = [
{ label: i18n.global.t('cronjob.thursday'), value: 4 },
{ label: i18n.global.t('cronjob.friday'), value: 5 },
{ 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({
name: [Rules.requiredInput],
@ -456,7 +456,9 @@ function checkScript() {
case 'perMonth':
return row.day > 0 && row.day < 32 && row.hour >= 0 && row.hour < 24 && row.minute >= 0 && row.minute < 60;
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':
return row.hour >= 0 && row.hour < 24 && row.minute >= 0 && row.minute < 60;
case 'perHour':