mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-22 22:36:06 +08:00
修复定时任务列表格式化 crontab
This commit is contained in:
parent
fcbcfc3a03
commit
cc9a17afa3
|
@ -13,7 +13,6 @@ import {
|
|||
spawn,
|
||||
} from 'child_process';
|
||||
import fs from 'fs';
|
||||
import cron_parser from 'cron-parser';
|
||||
import {
|
||||
getFileContentByName,
|
||||
concurrentRun,
|
||||
|
|
|
@ -51,7 +51,7 @@ import ViewManageModal from './viewManageModal';
|
|||
import { FilterValue, SorterResult } from 'antd/lib/table/interface';
|
||||
import { SharedContext } from '@/layouts';
|
||||
import useTableScrollHeight from '@/hooks/useTableScrollHeight';
|
||||
import { getCommandScript } from '@/utils';
|
||||
import { getCommandScript, parseCrontab } from '@/utils';
|
||||
import { ColumnProps } from 'antd/lib/table';
|
||||
import { VList } from 'virtuallist-antd';
|
||||
|
||||
|
@ -446,10 +446,7 @@ const Crontab = () => {
|
|||
data.map((x) => {
|
||||
return {
|
||||
...x,
|
||||
nextRunTime: cron_parser
|
||||
.parseExpression(x.schedule)
|
||||
.next()
|
||||
.toDate(),
|
||||
nextRunTime: parseCrontab(x.schedule),
|
||||
};
|
||||
}),
|
||||
);
|
||||
|
@ -736,10 +733,7 @@ const Crontab = () => {
|
|||
if (code === 200) {
|
||||
const index = value.findIndex((x) => x.id === cron.id);
|
||||
const result = [...value];
|
||||
data.nextRunTime = cron_parser
|
||||
.parseExpression(data.schedule)
|
||||
.next()
|
||||
.toDate();
|
||||
data.nextRunTime = parseCrontab(data.schedule);
|
||||
if (index !== -1) {
|
||||
result.splice(index, 1, {
|
||||
...cron,
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { LOG_END_SYMBOL } from './const';
|
||||
import cron_parser from 'cron-parser';
|
||||
|
||||
export default function browserType() {
|
||||
// 权重:系统 + 系统版本 > 平台 > 内核 + 载体 + 内核版本 + 载体版本 > 外壳 + 外壳版本
|
||||
|
@ -326,3 +327,14 @@ export function getCommandScript(
|
|||
}
|
||||
return [s, p];
|
||||
}
|
||||
|
||||
export function parseCrontab(schedule: string): Date {
|
||||
try {
|
||||
const time = cron_parser.parseExpression(schedule);
|
||||
if (time) {
|
||||
return time.next().toDate();
|
||||
}
|
||||
} catch (error) {}
|
||||
|
||||
return new Date('1970');
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user