diff --git a/back/api/system.ts b/back/api/system.ts index c1d8c16a..5925ef16 100644 --- a/back/api/system.ts +++ b/back/api/system.ts @@ -174,7 +174,10 @@ export default (app: Router) => { async (req: Request, res: Response, next: NextFunction) => { try { const systemService = Container.get(SystemService); - const uniqPath = await getUniqPath(req.body.command); + const command = req.body.command + const idStr = `cat ${config.crontabFile} | grep -E "${command}" | perl -pe "s|.*ID=(.*) ${command}.*|\\1|" | head -1 | awk -F " " '{print $1}' | xargs echo -n`; + let id = await promiseExec(idStr); + const uniqPath = await getUniqPath(command, id); const logTime = dayjs().format('YYYY-MM-DD-HH-mm-ss-SSS'); const logPath = `${uniqPath}/${logTime}.log`; res.setHeader('Content-type', 'application/octet-stream'); diff --git a/back/config/util.ts b/back/config/util.ts index 0d50a34a..5816535b 100644 --- a/back/config/util.ts +++ b/back/config/util.ts @@ -314,7 +314,7 @@ interface IFile { export function dirSort(a: IFile, b: IFile): number { if (a.type !== b.type) { return FileType[a.type] < FileType[b.type] ? -1 : 1 - }else if (a.mtime !== b.mtime) { + } else if (a.mtime !== b.mtime) { return a.mtime > b.mtime ? -1 : 1 } else { return 0; @@ -529,11 +529,8 @@ export async function parseContentVersion(content: string): Promise { return load(content) as IVersion; } -export async function getUniqPath(command: string): Promise { - const idStr = `cat ${config.crontabFile} | grep -E "${command}" | perl -pe "s|.*ID=(.*) ${command}.*|\\1|" | head -1 | awk -F " " '{print $1}' | xargs echo -n`; - let id = await promiseExec(idStr); - - if (/^\d\d*\d$/.test(id)) { +export async function getUniqPath(command: string, id: string): Promise { + if (/^\d+$/.test(id)) { id = `_${id}`; } else { id = ''; diff --git a/back/services/cron.ts b/back/services/cron.ts index a4da2c2e..69c36e76 100644 --- a/back/services/cron.ts +++ b/back/services/cron.ts @@ -392,10 +392,10 @@ export default class CronService { } let { id, command, log_path } = cron; - const uniqPath = await getUniqPath(command); + const uniqPath = await getUniqPath(command, `${id}`); const logTime = dayjs().format('YYYY-MM-DD-HH-mm-ss-SSS'); const logDirPath = path.resolve(config.logPath, `${uniqPath}`); - if (!log_path?.includes(uniqPath)) { + if (log_path?.split('/')?.every(x => x !== uniqPath)) { fs.mkdirSync(logDirPath, { recursive: true }); } const logPath = `${uniqPath}/${logTime}.log`; diff --git a/src/pages/crontab/index.less b/src/pages/crontab/index.less index 6602b37f..b9ebe376 100644 --- a/src/pages/crontab/index.less +++ b/src/pages/crontab/index.less @@ -193,3 +193,7 @@ body[data-mode='desktop'] { } } } + +.cron.pinned-cron > td { + background: #fafafa; +} \ No newline at end of file diff --git a/src/pages/crontab/index.tsx b/src/pages/crontab/index.tsx index a204c549..6353cb8c 100644 --- a/src/pages/crontab/index.tsx +++ b/src/pages/crontab/index.tsx @@ -71,50 +71,22 @@ const Crontab = () => { fixed: 'left', width: 120, render: (text: string, record: any) => ( - <> + { setDetailCron(record); setIsDetailModalVisible(true); }} > - {record.labels?.length > 0 && record.labels[0] !== '' && false ? ( - - {record.labels?.map((label: string) => ( - { - e.stopPropagation(); - setSearchValue(`label:${label}`); - setSearchText(`label:${label}`); - }} - > - {label} - - ))} - - } - > - {record.name || '-'} - - ) : ( - record.name || '-' - )} - {record.isPinned ? ( - - - - ) : ( - '' - )} + {record.name || '-'} - + ), sorter: { compare: (a, b) => a?.name?.localeCompare(b?.name),