U web update

pull/22/head
vapao 2020-01-08 00:27:23 +08:00
parent f1f20ec00a
commit ee568f1e6f
3 changed files with 6 additions and 3 deletions

View File

@ -37,7 +37,8 @@ class Ext1Index extends React.Component {
.then(({token, outputs}) => {
store.request.status = '2';
store.outputs = outputs;
this.socket = new WebSocket(`ws://localhost:8000/ws/exec/${token}/`);
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
this.socket = new WebSocket(`${protocol}//${window.location.host}/api/ws/exec/${token}/`);
this.socket.onopen = () => {
this.socket.send('ok');
};

View File

@ -37,7 +37,8 @@ class Ext1Index extends React.Component {
.then(({token, outputs}) => {
store.request.status = '2';
store.outputs = outputs;
this.socket = new WebSocket(`ws://localhost:8000/ws/exec/${token}/`);
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
this.socket = new WebSocket(`${protocol}//${window.location.host}/api/ws/exec/${token}/`);
this.socket.onopen = () => {
this.socket.send('ok');
};

View File

@ -17,7 +17,8 @@ class ExecConsole extends React.Component {
}
componentDidMount() {
this.socket = new WebSocket(`ws://localhost:8000/ws/exec/${store.token}/`);
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
this.socket = new WebSocket(`${protocol}//${window.location.host}/api/ws/exec/${store.token}/`);
this.socket.onopen = () => {
this.socket.send('ok');
for (let item of Object.values(store.outputs)) {