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