From ee568f1e6f35d8be9251c7b7b4ba9bd591514533 Mon Sep 17 00:00:00 2001 From: vapao Date: Wed, 8 Jan 2020 00:27:23 +0800 Subject: [PATCH] U web update --- spug_web/src/pages/deploy/do/Ext1Index.js | 3 ++- spug_web/src/pages/deploy/do/Ext2Index.js | 3 ++- spug_web/src/pages/exec/task/ExecConsole.js | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/spug_web/src/pages/deploy/do/Ext1Index.js b/spug_web/src/pages/deploy/do/Ext1Index.js index 81a3a2f..74b0572 100644 --- a/spug_web/src/pages/deploy/do/Ext1Index.js +++ b/spug_web/src/pages/deploy/do/Ext1Index.js @@ -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'); }; diff --git a/spug_web/src/pages/deploy/do/Ext2Index.js b/spug_web/src/pages/deploy/do/Ext2Index.js index f7b418c..c685e11 100644 --- a/spug_web/src/pages/deploy/do/Ext2Index.js +++ b/spug_web/src/pages/deploy/do/Ext2Index.js @@ -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'); }; diff --git a/spug_web/src/pages/exec/task/ExecConsole.js b/spug_web/src/pages/exec/task/ExecConsole.js index 9785430..687b99b 100644 --- a/spug_web/src/pages/exec/task/ExecConsole.js +++ b/spug_web/src/pages/exec/task/ExecConsole.js @@ -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)) {