mirror of https://github.com/openspug/spug
fix issue
parent
eb46568470
commit
3140c9ca43
|
@ -142,12 +142,12 @@ class Helper:
|
|||
if env:
|
||||
env = dict(env.items())
|
||||
env.update(os.environ)
|
||||
command = 'set -e\n' + command
|
||||
task = subprocess.Popen(command, env=env, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
while True:
|
||||
message = task.stdout.readline()
|
||||
if not message:
|
||||
break
|
||||
self.send_info('local', message.decode())
|
||||
message = message.decode().rstrip('\r\n')
|
||||
self.send_info('local', message + '\r\n')
|
||||
if task.wait() != 0:
|
||||
self.send_error('local', f'exit code: {task.returncode}')
|
||||
|
|
|
@ -3,21 +3,25 @@
|
|||
* Copyright (c) <spug.dev@gmail.com>
|
||||
* Released under the AGPL-3.0 License.
|
||||
*/
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import React, { useState, useEffect, useRef } from 'react';
|
||||
import { observer } from 'mobx-react';
|
||||
import { FullscreenOutlined, FullscreenExitOutlined, LoadingOutlined } from '@ant-design/icons';
|
||||
import { FitAddon } from 'xterm-addon-fit';
|
||||
import { Terminal } from 'xterm';
|
||||
import { Modal, Steps } from 'antd';
|
||||
import { X_TOKEN, human_time } from 'libs';
|
||||
import styles from './index.module.less';
|
||||
import store from './store';
|
||||
|
||||
export default observer(function Console() {
|
||||
const el = useRef()
|
||||
const [fullscreen, setFullscreen] = useState(false);
|
||||
const [step, setStep] = useState(0);
|
||||
const [status, setStatus] = useState('process')
|
||||
|
||||
useEffect(() => {
|
||||
store.outputs = [`${human_time()} 建立连接... `]
|
||||
const term = initialTerm()
|
||||
term.write(`${human_time()} 建立连接... `)
|
||||
let index = 0;
|
||||
const token = store.record.spug_version;
|
||||
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
||||
|
@ -29,17 +33,24 @@ export default observer(function Console() {
|
|||
} else {
|
||||
index += 1;
|
||||
const {data, step, status} = JSON.parse(e.data);
|
||||
if (data !== undefined) store.outputs.push(data);
|
||||
if (data !== undefined) term.write(data);
|
||||
if (step !== undefined) setStep(step);
|
||||
if (status !== undefined) setStatus(status);
|
||||
}
|
||||
}
|
||||
return () => {
|
||||
socket.close();
|
||||
store.outputs = []
|
||||
}
|
||||
return () => socket.close();
|
||||
}, [])
|
||||
|
||||
function initialTerm() {
|
||||
const fitPlugin = new FitAddon()
|
||||
const term = new Terminal({disableStdin: true})
|
||||
term.loadAddon(fitPlugin)
|
||||
term.setOption('theme', {background: '#fafafa', foreground: '#000', selection: '#999'})
|
||||
term.open(el.current)
|
||||
fitPlugin.fit()
|
||||
return term
|
||||
}
|
||||
|
||||
function handleClose() {
|
||||
store.fetchRecords();
|
||||
store.logVisible = false
|
||||
|
@ -74,7 +85,9 @@ export default observer(function Console() {
|
|||
<StepItem title="检出后任务" step={3}/>
|
||||
<StepItem title="执行打包" step={4}/>
|
||||
</Steps>
|
||||
<pre className={styles.out}>{store.outputs}</pre>
|
||||
<div className={styles.out}>
|
||||
<div ref={el}/>
|
||||
</div>
|
||||
</Modal>
|
||||
)
|
||||
})
|
||||
|
|
|
@ -19,9 +19,7 @@
|
|||
|
||||
.out {
|
||||
margin-top: 24px;
|
||||
min-height: 40px;
|
||||
max-height: 300px;
|
||||
padding: 10px 15px;
|
||||
padding: 8px 0 0 15px;
|
||||
border: 1px solid #d9d9d9;
|
||||
border-radius: 4px;
|
||||
background-color: #fafafa;
|
||||
|
|
|
@ -10,7 +10,6 @@ class Store {
|
|||
@observable records = [];
|
||||
@observable record = {};
|
||||
@observable deploy = {};
|
||||
@observable outputs = [];
|
||||
@observable isFetching = false;
|
||||
@observable formVisible = false;
|
||||
@observable addVisible = false;
|
||||
|
|
Loading…
Reference in New Issue