修复退出调试自动删除调试日志目录

This commit is contained in:
whyour 2023-08-22 22:18:18 +08:00
parent a8174e89be
commit 40e8041401
11 changed files with 36 additions and 23 deletions

View File

@ -265,9 +265,11 @@ export default (app: Router) => {
let { filename, path, pid } = req.body;
const { name, ext } = parse(filename);
const filePath = join(config.scriptPath, path, `${name}.swap${ext}`);
const logPath = join(config.logPath, path, `${name}.swap`);
const scriptService = Container.get(ScriptService);
const result = await scriptService.stopScript(filePath, pid);
emptyDir(logPath);
res.send(result);
} catch (e) {
return next(e);

View File

@ -53,10 +53,9 @@ export default class ScriptService {
}
public async stopScript(filePath: string, pid: number) {
let str = '';
if (!pid) {
const relativePath = path.relative(config.scriptPath, filePath);
pid = await getPid(`${TASK_COMMAND} -l ${relativePath} now`);
pid = await getPid(`${TASK_COMMAND} -l ${relativePath} now`) as number;
}
try {
await killTask(pid);

View File

@ -195,7 +195,7 @@ body {
}
.ant-tooltip {
max-width: 250px !important;
max-width: 300px !important;
}
}

View File

@ -83,7 +83,7 @@ const CronModal = ({
>
<Input.TextArea
rows={4}
autoSize={true}
autoSize={{ minRows: 1, maxRows: 5 }}
placeholder={intl.get(
'支持输入脚本路径/任意系统可执行命令/task 脚本路径',
)}

View File

@ -56,8 +56,8 @@ const DependenceLogModal = ({
) {
const log = (data.log || []).join('') as string;
setValue(log);
setExecuting(!log.includes(intl.get('结束时间')));
setIsRemoveFailed(log.includes(intl.get('删除失败')));
setExecuting(!log.includes('结束时间'));
setIsRemoveFailed(log.includes('删除失败'));
}
})
.finally(() => {

View File

@ -130,7 +130,7 @@ const DependenceModal = ({
>
<Input.TextArea
rows={4}
autoSize={true}
autoSize={{ minRows: 1, maxRows: 5 }}
placeholder={intl.get('请输入依赖名称')}
/>
</Form.Item>

View File

@ -91,7 +91,11 @@ const Env = () => {
render: (text: string, record: any) => {
return (
<div style={{ display: 'flex', alignItems: 'center' }}>
<Tooltip title={text} placement="topLeft">
<Tooltip
title={text}
placement="topLeft"
overlayInnerStyle={{ maxHeight: 400, overflowY: 'auto' }}
>
<div className="text-ellipsis">{text}</div>
</Tooltip>
<Copy text={text} />

View File

@ -1,4 +1,4 @@
import intl from 'react-intl-universal'
import intl from 'react-intl-universal';
import React, { useEffect, useState } from 'react';
import { Modal, message, Input, Form, Radio } from 'antd';
import { request } from '@/utils/http';
@ -44,7 +44,9 @@ const EnvModal = ({
);
if (code === 200) {
message.success(env ? intl.get('更新变量成功') : intl.get('创建变量成功'));
message.success(
env ? intl.get('更新变量成功') : intl.get('创建变量成功'),
);
handleCancel(data);
}
setLoading(false);
@ -82,7 +84,11 @@ const EnvModal = ({
name="name"
label={intl.get('名称')}
rules={[
{ required: true, message: intl.get('请输入环境变量名称'), whitespace: true },
{
required: true,
message: intl.get('请输入环境变量名称'),
whitespace: true,
},
{
pattern: /^[a-zA-Z_][0-9a-zA-Z_]*$/,
message: intl.get('只能输入字母数字下划线,且不能以数字开头'),
@ -108,12 +114,15 @@ const EnvModal = ({
name="value"
label={intl.get('值')}
rules={[
{ required: true, message: intl.get('请输入环境变量值'), whitespace: true },
{
required: true,
message: intl.get('请输入环境变量值'),
whitespace: true,
},
]}
>
<Input.TextArea
rows={4}
autoSize={true}
autoSize={{ minRows: 1, maxRows: 8 }}
placeholder={intl.get('请输入环境变量值')}
/>
</Form.Item>

View File

@ -185,7 +185,7 @@ const Initialization = () => {
style={{ maxWidth: 400 }}
>
<Input.TextArea
autoSize={true}
autoSize={{ minRows: 1, maxRows: 5 }}
placeholder={`请输入${x.label}`}
/>
</Form.Item>

View File

@ -88,7 +88,7 @@ const NotificationSetting = ({ data }: any) => {
) : (
<Input.TextArea
disabled={loading}
autoSize={true}
autoSize={{ minRows: 1, maxRows: 5 }}
placeholder={x.placeholder || `请输入${x.label}`}
/>
)}

View File

@ -326,8 +326,7 @@ const SubscriptionModal = ({
]}
>
<Input.TextArea
rows={4}
autoSize={true}
autoSize={{ minRows: 1, maxRows: 5 }}
placeholder={intl.get('请输入订阅链接')}
onPaste={onNamePaste}
onChange={onUrlChange}
@ -415,7 +414,7 @@ const SubscriptionModal = ({
>
<Input.TextArea
rows={4}
autoSize={true}
autoSize={{ minRows: 1, maxRows: 5 }}
placeholder={intl.get(
'请输入脚本筛选白名单关键词,多个关键词竖线分割',
)}
@ -429,7 +428,7 @@ const SubscriptionModal = ({
>
<Input.TextArea
rows={4}
autoSize={true}
autoSize={{ minRows: 1, maxRows: 5 }}
placeholder={intl.get(
'请输入脚本筛选黑名单关键词,多个关键词竖线分割',
)}
@ -443,7 +442,7 @@ const SubscriptionModal = ({
>
<Input.TextArea
rows={4}
autoSize={true}
autoSize={{ minRows: 1, maxRows: 5 }}
placeholder={intl.get(
'请输入脚本依赖文件关键词,多个关键词竖线分割',
)}
@ -472,7 +471,7 @@ const SubscriptionModal = ({
<Input.TextArea
onPaste={onNamePaste}
rows={4}
autoSize={true}
autoSize={{ minRows: 1, maxRows: 5 }}
placeholder={intl.get('请输入运行订阅前要执行的命令')}
/>
</Form.Item>
@ -486,7 +485,7 @@ const SubscriptionModal = ({
<Input.TextArea
onPaste={onNamePaste}
rows={4}
autoSize={true}
autoSize={{ minRows: 1, maxRows: 5 }}
placeholder={intl.get('请输入运行订阅后要执行的命令')}
/>
</Form.Item>