mirror of https://github.com/openspug/spug
U 优化web终端
parent
6392b69abf
commit
8fd9780250
|
@ -119,7 +119,7 @@ class SSHConsumer(WebsocketConsumer):
|
|||
self.close()
|
||||
|
||||
def _init(self):
|
||||
self.send(bytes_data=b'Connecting ...\r\n')
|
||||
self.send(bytes_data=b'\r\33[KConnecting ...\r')
|
||||
host = Host.objects.filter(pk=self.id).first()
|
||||
if not host:
|
||||
self.send(text_data='Unknown host\r\n')
|
||||
|
|
|
@ -18,11 +18,13 @@ function WebSSH(props) {
|
|||
useEffect(() => {
|
||||
const fitPlugin = new FitAddon();
|
||||
term.loadAddon(fitPlugin);
|
||||
term.open(container.current);
|
||||
term.write('WebSocket connecting ... ');
|
||||
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
||||
const socket = new WebSocket(`${protocol}//${window.location.host}/api/ws/ssh/${props.id}/?x-token=${X_TOKEN}`);
|
||||
socket.onmessage = e => _read_as_text(e.data);
|
||||
socket.onopen = () => {
|
||||
term.open(container.current);
|
||||
term.write('ok')
|
||||
term.focus();
|
||||
fitPlugin.fit();
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue