mirror of
https://github.com/whyour/qinglong.git
synced 2026-07-17 17:54:32 +08:00
调试脚本增加停止,修复调试交互
This commit is contained in:
@@ -47,6 +47,7 @@ const EditModal = ({
|
||||
const [log, setLog] = useState<string>('');
|
||||
const { theme } = useTheme();
|
||||
const editorRef = useRef<any>(null);
|
||||
const [isRunning, setIsRunning] = useState(false);
|
||||
|
||||
const cancel = () => {
|
||||
handleCancel();
|
||||
@@ -80,7 +81,22 @@ const EditModal = ({
|
||||
path: cNode.parent || '',
|
||||
},
|
||||
})
|
||||
.then((data) => {});
|
||||
.then((data) => {
|
||||
setIsRunning(true);
|
||||
});
|
||||
};
|
||||
|
||||
const stop = () => {
|
||||
request
|
||||
.put(`${config.apiPrefix}scripts/stop`, {
|
||||
data: {
|
||||
filename: cNode.value,
|
||||
path: cNode.parent || '',
|
||||
},
|
||||
})
|
||||
.then((data) => {
|
||||
setIsRunning(false);
|
||||
});
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
@@ -94,6 +110,13 @@ const EditModal = ({
|
||||
return;
|
||||
}
|
||||
|
||||
if (_message === '执行结束') {
|
||||
_message = '';
|
||||
setTimeout(() => {
|
||||
setIsRunning(false);
|
||||
}, 300);
|
||||
}
|
||||
|
||||
if (log) {
|
||||
_message = `\n${_message}`;
|
||||
}
|
||||
@@ -135,8 +158,12 @@ const EditModal = ({
|
||||
<Option value="shell">shell</Option>
|
||||
<Option value="python">python</Option>
|
||||
</Select>
|
||||
<Button type="primary" style={{ marginRight: 8 }} onClick={run}>
|
||||
运行
|
||||
<Button
|
||||
type="primary"
|
||||
style={{ marginRight: 8 }}
|
||||
onClick={isRunning ? stop : run}
|
||||
>
|
||||
{isRunning ? '停止' : '运行'}
|
||||
</Button>
|
||||
<Button
|
||||
type="primary"
|
||||
@@ -169,6 +196,7 @@ const EditModal = ({
|
||||
type="primary"
|
||||
style={{ marginRight: 8 }}
|
||||
onClick={() => {
|
||||
stop();
|
||||
handleCancel();
|
||||
}}
|
||||
>
|
||||
@@ -181,7 +209,12 @@ const EditModal = ({
|
||||
onClose={cancel}
|
||||
visible={visible}
|
||||
>
|
||||
<SplitPane split="vertical" minSize={200} defaultSize="50%">
|
||||
<SplitPane
|
||||
split="vertical"
|
||||
minSize={200}
|
||||
defaultSize="50%"
|
||||
style={{ height: 'calc(100vh - 55px)' }}
|
||||
>
|
||||
<Editor
|
||||
language={language}
|
||||
value={value}
|
||||
@@ -196,9 +229,7 @@ const EditModal = ({
|
||||
editorRef.current = editor;
|
||||
}}
|
||||
/>
|
||||
<div>
|
||||
<pre>{log}</pre>
|
||||
</div>
|
||||
<pre style={{ height: '100%', whiteSpace: 'break-spaces' }}>{log}</pre>
|
||||
</SplitPane>
|
||||
<SaveModal
|
||||
visible={saveModalVisible}
|
||||
|
||||
Reference in New Issue
Block a user