|
|
@ -4,7 +4,9 @@ import { handleMsg, sendSub } from './utils/websocket'
|
|
|
|
|
|
|
|
|
|
|
|
const token = window.localStorage.getItem('token')
|
|
|
|
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({
|
|
|
|
const state = reactive({
|
|
|
|
name: '',
|
|
|
|
name: '',
|
|
|
@ -30,7 +32,7 @@ const methods = {
|
|
|
|
authenticate: async (token) => {
|
|
|
|
authenticate: async (token) => {
|
|
|
|
state.session = null
|
|
|
|
state.session = null
|
|
|
|
window.localStorage.setItem('token', token)
|
|
|
|
window.localStorage.setItem('token', token)
|
|
|
|
return axios.post(`http://${server}/api/v1`, {
|
|
|
|
return axios.post(`${api_proto}://${server}/api/v1`, {
|
|
|
|
token,
|
|
|
|
token,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.then((res) => {
|
|
|
|
.then((res) => {
|
|
|
@ -42,7 +44,7 @@ const methods = {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
connect: () => {
|
|
|
|
connect: () => {
|
|
|
|
if (state.session !== null) {
|
|
|
|
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 = () => {
|
|
|
|
state.ws.onopen = () => {
|
|
|
|
clearInterval(interval)
|
|
|
|
clearInterval(interval)
|
|
|
|
sendSub(state.ws)
|
|
|
|
sendSub(state.ws)
|
|
|
|