|
|
|
@ -4,7 +4,9 @@ import { handleMsg, sendSub } from './utils/websocket'
|
|
|
|
|
|
|
|
|
|
const token = window.localStorage.getItem('token')
|
|
|
|
|
|
|
|
|
|
const server = 'nuke.aplesports.com:5000'
|
|
|
|
|
const server = process.env.VUE_APP_NUKE_URI
|
|
|
|
|
const api_proto = process.env.VUE_APP_NUKE_API_PROTO
|
|
|
|
|
const ws_proto = process.env.VUE_APP_NUKE_WS_PROTO
|
|
|
|
|
|
|
|
|
|
const state = reactive({
|
|
|
|
|
name: '',
|
|
|
|
@ -30,7 +32,7 @@ const methods = {
|
|
|
|
|
authenticate: async (token) => {
|
|
|
|
|
state.session = null
|
|
|
|
|
window.localStorage.setItem('token', token)
|
|
|
|
|
return axios.post(`http://${server}/api/v1`, {
|
|
|
|
|
return axios.post(`${api_proto}://${server}/api/v1`, {
|
|
|
|
|
token,
|
|
|
|
|
})
|
|
|
|
|
.then((res) => {
|
|
|
|
@ -42,7 +44,7 @@ const methods = {
|
|
|
|
|
},
|
|
|
|
|
connect: () => {
|
|
|
|
|
if (state.session !== null) {
|
|
|
|
|
state.ws = new WebSocket(`ws://${server}/ws/${state.session}`)
|
|
|
|
|
state.ws = new WebSocket(`${ws_proto}://${server}/ws/${state.session}`)
|
|
|
|
|
state.ws.onopen = () => {
|
|
|
|
|
clearInterval(interval)
|
|
|
|
|
sendSub(state.ws)
|
|
|
|
|