|
|
@ -10,22 +10,24 @@ export default function({ |
|
|
|
let socket |
|
|
|
let socket |
|
|
|
|
|
|
|
|
|
|
|
const init = async(token) => { |
|
|
|
const init = async(token) => { |
|
|
|
if (socket) { |
|
|
|
try { |
|
|
|
socket.disconnect() |
|
|
|
if (socket) { |
|
|
|
} |
|
|
|
socket.disconnect() |
|
|
|
const isUrl = $axios.defaults.baseURL.startsWith('http') |
|
|
|
} |
|
|
|
const url = isUrl ? $axios.defaults.baseURL : window.location.origin |
|
|
|
const isUrl = $axios.defaults.baseURL.startsWith('http') |
|
|
|
const path = isUrl ? undefined : ($axios.defaults.baseURL === '..' ? window.location.path.split('/').slice(0, -1).join('/') : $axios.defaults.baseURL) |
|
|
|
const url = isUrl ? $axios.defaults.baseURL : window.location.origin |
|
|
|
|
|
|
|
const path = isUrl ? undefined : ($axios.defaults.baseURL === '..' ? window.location.pathname.split('/').slice(0, -1).join('/') : $axios.defaults.baseURL) |
|
|
|
|
|
|
|
|
|
|
|
socket = io(url, { |
|
|
|
socket = io(url, { |
|
|
|
path, |
|
|
|
path, |
|
|
|
extraHeaders: { 'xc-auth': token } |
|
|
|
extraHeaders: { 'xc-auth': token } |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
socket.on('connect_error', () => { |
|
|
|
socket.on('connect_error', () => { |
|
|
|
socket.disconnect() |
|
|
|
socket.disconnect() |
|
|
|
socket = null |
|
|
|
socket = null |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
} catch { } |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
app.router.onReady(() => { |
|
|
|
app.router.onReady(() => { |
|
|
|