Adjust some mechanics
This commit is contained in:
parent
16d95cd740
commit
e9416b5dce
1 changed files with 9 additions and 5 deletions
14
src/main.js
14
src/main.js
|
|
@ -5,15 +5,13 @@ import VueSocketIO from 'vue-socket.io';
|
||||||
Vue.config.productionTip = false;
|
Vue.config.productionTip = false;
|
||||||
|
|
||||||
let qs = new URLSearchParams(window.location.search);
|
let qs = new URLSearchParams(window.location.search);
|
||||||
let ws_uri;
|
let ws_uri = ``;
|
||||||
if (qs.get(`ws-uri`)) {
|
if (qs.get(`ws-uri`)) {
|
||||||
ws_uri = qs.get(`ws-uri`)
|
ws_uri = qs.get(`ws-uri`)
|
||||||
if (!ws_uri.match(/^(wss?|https?):\/\//)) {
|
if (!ws_uri.match(/^(wss?|https?):\/\//)) {
|
||||||
ws_uri = `ws://${ws_uri}`;
|
ws_uri = `ws://${ws_uri}`;
|
||||||
};
|
};
|
||||||
} else {
|
};
|
||||||
ws_uri = ``
|
|
||||||
}
|
|
||||||
|
|
||||||
// http://localhost:8080/?ws-uri=localhost:3000
|
// http://localhost:8080/?ws-uri=localhost:3000
|
||||||
|
|
||||||
|
|
@ -21,9 +19,15 @@ while (ws_uri.length == 0 || !ws_uri.match(/^(wss?|https?):\/\//)) {
|
||||||
ws_uri = prompt("Input a websocket URI to connect to");
|
ws_uri = prompt("Input a websocket URI to connect to");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qs.set(`ws-uri`, ws_uri);
|
||||||
|
window.history.pushState({}, ``, `/?${qs.toString()}`)
|
||||||
|
|
||||||
|
|
||||||
Vue.use(new VueSocketIO({
|
Vue.use(new VueSocketIO({
|
||||||
debug: true,
|
debug: true,
|
||||||
connection: ws_uri
|
connection: ws_uri
|
||||||
}))
|
}))
|
||||||
|
|
||||||
new Vue({render: h => h(App)}).$mount('#app');
|
new Vue({
|
||||||
|
render: h => h(App),
|
||||||
|
}).$mount('#app');
|
||||||
Loading…
Add table
Add a link
Reference in a new issue