|
|
@ -23,7 +23,8 @@ export default function({ |
|
|
|
socket.disconnect() |
|
|
|
socket.disconnect() |
|
|
|
socket = null |
|
|
|
socket = null |
|
|
|
}) |
|
|
|
}) |
|
|
|
} catch { } |
|
|
|
} catch { |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
app.router.onReady(() => { |
|
|
|
app.router.onReady(() => { |
|
|
@ -32,13 +33,11 @@ export default function({ |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
socket.emit('page', { |
|
|
|
socket.emit('page', { |
|
|
|
id: store.state.users.user && store.state.users.user.id, |
|
|
|
|
|
|
|
path: to.matched[0].path + (to.query && to.query.type ? `?type=${to.query.type}` : '') |
|
|
|
path: to.matched[0].path + (to.query && to.query.type ? `?type=${to.query.type}` : '') |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
if (socket) { |
|
|
|
if (socket) { |
|
|
|
socket.emit('page', { |
|
|
|
socket.emit('page', { |
|
|
|
id: store.state.users.user && store.state.users.user.id, |
|
|
|
|
|
|
|
path: route.matched[0].path + (route.query && route.query.type ? `?type=${route.query.type}` : '') |
|
|
|
path: route.matched[0].path + (route.query && route.query.type ? `?type=${route.query.type}` : '') |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
@ -49,9 +48,8 @@ export default function({ |
|
|
|
if (socket) { |
|
|
|
if (socket) { |
|
|
|
socket.emit('event', { |
|
|
|
socket.emit('event', { |
|
|
|
event: evt, |
|
|
|
event: evt, |
|
|
|
id: store.state.users.user && store.state.users.user.id, |
|
|
|
|
|
|
|
...(data || {}), |
|
|
|
...(data || {}), |
|
|
|
$current_url: gatPath(app) |
|
|
|
path: gatPath(app) |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -61,14 +59,14 @@ export default function({ |
|
|
|
|
|
|
|
|
|
|
|
function getListener(binding) { |
|
|
|
function getListener(binding) { |
|
|
|
return function(e) { |
|
|
|
return function(e) { |
|
|
|
if (!socket) { return } |
|
|
|
if (!socket) { |
|
|
|
const cat = window.location.hash.replace(/\d+\/(?=dashboard)/, '') |
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
const event = binding.value && binding.value[0] |
|
|
|
const event = binding.value && binding.value[0] |
|
|
|
const data = binding.value && binding.value[1] |
|
|
|
const data = binding.value && binding.value[1] |
|
|
|
const extra = binding.value && binding.value.slice(2) |
|
|
|
const extra = binding.value && binding.value.slice(2) |
|
|
|
tele.emit(event, |
|
|
|
tele.emit(event, |
|
|
|
{ |
|
|
|
{ |
|
|
|
cat, |
|
|
|
|
|
|
|
data, |
|
|
|
data, |
|
|
|
extra |
|
|
|
extra |
|
|
|
}) |
|
|
|
}) |
|
|
@ -87,14 +85,16 @@ export default function({ |
|
|
|
|
|
|
|
|
|
|
|
store.watch(state => state.project.projectInfo && state.project.projectInfo.teleEnabled && state.users.token, (token) => { |
|
|
|
store.watch(state => state.project.projectInfo && state.project.projectInfo.teleEnabled && state.users.token, (token) => { |
|
|
|
if (token) { |
|
|
|
if (token) { |
|
|
|
init(token).then(() => {}) |
|
|
|
init(token).then(() => { |
|
|
|
|
|
|
|
}) |
|
|
|
} else if (socket) { |
|
|
|
} else if (socket) { |
|
|
|
socket.disconnect() |
|
|
|
socket.disconnect() |
|
|
|
socket = null |
|
|
|
socket = null |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
if (store.state.project.projectInfo && store.state.project.projectInfo.teleEnabled && store.state.users.token) { |
|
|
|
if (store.state.project.projectInfo && store.state.project.projectInfo.teleEnabled && store.state.users.token) { |
|
|
|
init(store.state.users.token).then(() => {}) |
|
|
|
init(store.state.users.token).then(() => { |
|
|
|
|
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|