diff --git a/back/api/cron.ts b/back/api/cron.ts
index cd365132..2ef5c369 100644
--- a/back/api/cron.ts
+++ b/back/api/cron.ts
@@ -458,13 +458,12 @@ export default (app: Router) => {
}),
}),
async (req: Request, res: Response, next: NextFunction) => {
- const logger: Logger = Container.get('logger');
try {
const cronService = Container.get(CronService);
const data = await cronService.status({
...req.body,
- status: parseInt(req.body.status),
- pid: parseInt(req.body.pid) || '',
+ status: req.body.status ? parseInt(req.body.status) : undefined,
+ pid: req.body.pid ? parseInt(req.body.pid) : undefined,
});
return res.send({ code: 200, data });
} catch (e) {
diff --git a/back/services/cron.ts b/back/services/cron.ts
index 09876d04..078527fd 100644
--- a/back/services/cron.ts
+++ b/back/services/cron.ts
@@ -14,6 +14,8 @@ import cronClient from '../schedule/client';
import taskLimit from '../shared/pLimit';
import { spawn } from 'cross-spawn';
import dayjs from 'dayjs';
+import pickBy from 'lodash/pickBy';
+import omit from 'lodash/omit';
@Service()
export default class CronService {
@@ -89,7 +91,7 @@ export default class CronService {
last_running_time: number;
last_execution_time: number;
}) {
- const options: any = {
+ let options: any = {
status,
pid,
log_path,
@@ -99,7 +101,13 @@ export default class CronService {
options.last_running_time = last_running_time;
}
- return await CrontabModel.update({ ...options }, { where: { id: ids } });
+ for (const id of ids) {
+ const cron = await this.getDb({ id });
+ if (status === CrontabStatus.idle && log_path !== cron.log_path) {
+ options = omit(options, ['status', 'log_path', 'pid']);
+ }
+ await CrontabModel.update({ ...pickBy(options, (v) => v === 0 || !!v) }, { where: { id } });
+ }
}
public async remove(ids: number[]) {
diff --git a/shell/share.sh b/shell/share.sh
index aab2cb1c..1afa18d2 100755
--- a/shell/share.sh
+++ b/shell/share.sh
@@ -460,7 +460,7 @@ handle_task_after() {
[[ "$diff_time" == 0 ]] && diff_time=1
- echo -e "\n\n## 执行结束... $end_time 耗时 $diff_time 秒 "
+ echo -e "\n## 执行结束... $end_time 耗时 $diff_time 秒 "
[[ $ID ]] && update_cron "\"$ID\"" "1" "" "$log_path" "$begin_timestamp" "$diff_time"
}
diff --git a/src/layouts/index.less b/src/layouts/index.less
index 06b86b80..5735c0de 100644
--- a/src/layouts/index.less
+++ b/src/layouts/index.less
@@ -25,8 +25,8 @@ body {
}
.ant-modal-body {
- max-height: calc(90vh - 110px);
- max-height: calc(90vh - var(--vh-offset, 110px));
+ max-height: calc(80vh - 110px);
+ max-height: calc(80vh - var(--vh-offset, 110px));
overflow-y: auto;
}
@@ -181,6 +181,7 @@ body {
.react-codemirror2,
.CodeMirror {
height: 100%;
+ overflow: auto;
}
}
}
diff --git a/src/pages/crontab/logModal.tsx b/src/pages/crontab/logModal.tsx
index de995992..13ebe028 100644
--- a/src/pages/crontab/logModal.tsx
+++ b/src/pages/crontab/logModal.tsx
@@ -10,6 +10,7 @@ import {
import { PageLoading } from '@ant-design/pro-layout';
import { logEnded } from '@/utils';
import { CrontabStatus } from './type';
+import Ansi from 'ansi-to-react';
const { Countdown } = Statistic;
@@ -148,7 +149,7 @@ const CronLogModal = ({
: {}
}
>
- {value}
+
{lastLog}, + content:
, okText: intl.get('下载更新'), cancelText: intl.get('以后再说'), onOk() { @@ -102,7 +102,7 @@ const CheckUpdate = ({ systemInfo }: any) => { okButtonProps: { disabled: true }, title: intl.get('下载更新中...'), centered: true, - content:{lastLog}
{value}, + content:
, }); }; diff --git a/src/pages/subscription/logModal.tsx b/src/pages/subscription/logModal.tsx index 921fb4a6..c45ea2e0 100644 --- a/src/pages/subscription/logModal.tsx +++ b/src/pages/subscription/logModal.tsx @@ -9,6 +9,7 @@ import { } from '@ant-design/icons'; import { PageLoading } from '@ant-design/pro-layout'; import { logEnded } from '@/utils'; +import Ansi from 'ansi-to-react'; const SubscriptionLogModal = ({ subscription, @@ -122,7 +123,7 @@ const SubscriptionLogModal = ({ : {} } > - {value} +{value}