修复任务详情查看脚本错误

This commit is contained in:
whyour 2024-05-25 18:22:01 +08:00
parent e77d4c4337
commit 805a716033
5 changed files with 32 additions and 30 deletions

View File

@ -41,7 +41,7 @@ export default class ScriptService {
const relativePath = path.relative(config.scriptPath, filePath); const relativePath = path.relative(config.scriptPath, filePath);
const command = `${TASK_COMMAND} ${relativePath} now`; const command = `${TASK_COMMAND} ${relativePath} now`;
const pid = await this.scheduleService.runTask( const pid = await this.scheduleService.runTask(
command, `real_time=true ${command}`,
this.taskCallbacks(filePath), this.taskCallbacks(filePath),
{ command }, { command },
'start', 'start',
@ -63,7 +63,10 @@ export default class ScriptService {
} }
public async getFile(filePath: string, fileName: string) { public async getFile(filePath: string, fileName: string) {
const _filePath = join(config.scriptPath, filePath, fileName); let _filePath = join(config.scriptPath, filePath, fileName);
if (filePath.startsWith(config.dataPath)) {
_filePath = join(filePath, fileName);
}
const content = await getFileContentByName(_filePath); const content = await getFileContentByName(_filePath);
return content; return content;
} }

View File

@ -808,12 +808,13 @@ function pushPlusNotify(text, desp) {
function wePlusBotNotify(text, desp) { function wePlusBotNotify(text, desp) {
return new Promise((resolve) => { return new Promise((resolve) => {
const { WE_PLUS_BOT_TOKEN, WE_PLUS_BOT_RECEIVER, WE_PLUS_BOT_VERSION } = push_config; const { WE_PLUS_BOT_TOKEN, WE_PLUS_BOT_RECEIVER, WE_PLUS_BOT_VERSION } =
push_config;
if (WE_PLUS_BOT_TOKEN) { if (WE_PLUS_BOT_TOKEN) {
const template = 'txt'; const template = 'txt';
if(desp.length>800){ if (desp.length > 800) {
desp = desp.replace(/[\n\r]/g, '<br>'); desp = desp.replace(/[\n\r]/g, '<br>');
template = 'html'; template = 'html';
} }
const body = { const body = {
token: `${WE_PLUS_BOT_TOKEN}`, token: `${WE_PLUS_BOT_TOKEN}`,
@ -834,19 +835,12 @@ function wePlusBotNotify(text, desp) {
$.post(options, (err, resp, data) => { $.post(options, (err, resp, data) => {
try { try {
if (err) { if (err) {
console.log( console.log(`微加机器人发送通知消息失败😞\n`, err);
`微加机器人 发送通知消息失败😞\n`,
err,
);
} else { } else {
if (data.code === 200) { if (data.code === 200) {
console.log( console.log(`微加机器人发送通知消息完成🎉\n`);
`微加机器人 发送通知消息完成🎉\n`,
);
} else { } else {
console.log( console.log(`微加机器人发送通知消息异常 ${data.msg}\n`);
`微加机器人 发送通知消息异常 ${data.msg}\n`,
);
} }
} }
} catch (e) { } catch (e) {

View File

@ -110,7 +110,7 @@ const CronDetailModal = ({
minimap: { enabled: false }, minimap: { enabled: false },
lineNumbersMinChars: 3, lineNumbersMinChars: 3,
glyphMargin: false, glyphMargin: false,
accessibilitySupport: 'off' accessibilitySupport: 'off',
}} }}
onMount={(editor, monaco) => { onMount={(editor, monaco) => {
editorRef.current = editor; editorRef.current = editor;
@ -162,8 +162,9 @@ const CronDetailModal = ({
setValue(data); setValue(data);
} }
}); });
} else if (result) { } else {
setValidTabs([validTabs[0]]); setValidTabs([validTabs[0]]);
setActiveTabKey('log');
} }
}; };
@ -359,10 +360,15 @@ const CronDetailModal = ({
<Modal <Modal
title={ title={
<div className="crontab-title-wrapper"> <div className="crontab-title-wrapper">
<div style={{ minWidth: 0 }}> <div style={{ minWidth: 0, display: 'flex', alignItems: 'center' }}>
<Typography.Text <Typography.Text
style={{ width: '100%' }} style={{ width: 200, boxSizing: 'content-box' }}
ellipsis={{ tooltip: currentCron.name }} ellipsis={{
onEllipsis(ellipsis) {
return ellipsis;
},
tooltip: currentCron.name,
}}
> >
{currentCron.name} {currentCron.name}
</Typography.Text> </Typography.Text>

View File

@ -81,6 +81,7 @@
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
gap: 24px;
.operations { .operations {
display: flex; display: flex;

View File

@ -75,18 +75,16 @@ const Crontab = () => {
style={{ style={{
wordBreak: 'break-all', wordBreak: 'break-all',
marginBottom: 0, marginBottom: 0,
color: '#1890ff' color: '#1890ff',
cursor: 'pointer'
}} }}
ellipsis={{ tooltip: text, rows: 2 }} ellipsis={{ tooltip: text, rows: 2 }}
onClick={() => {
setDetailCron(record);
setIsDetailModalVisible(true);
}}
> >
<Link <Link>{record.name || '-'}</Link>
onClick={() => {
setDetailCron(record);
setIsDetailModalVisible(true);
}}
>
{record.name || '-'}
</Link>
</Paragraph> </Paragraph>
), ),
sorter: { sorter: {