|
|
@ -26,6 +26,10 @@ export default defineNuxtPlugin(async (nuxtApp) => { |
|
|
|
} catch {} |
|
|
|
} catch {} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (nuxtApp.$state.signedIn.value) { |
|
|
|
|
|
|
|
await init(nuxtApp.$state.token.value) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
router.afterEach((to, from) => { |
|
|
|
router.afterEach((to, from) => { |
|
|
|
if (!socket || (to.path === from.path && (to.query && to.query.type) === (from.query && from.query.type))) return |
|
|
|
if (!socket || (to.path === from.path && (to.query && to.query.type) === (from.query && from.query.type))) return |
|
|
|
|
|
|
|
|
|
|
@ -77,8 +81,6 @@ export default defineNuxtPlugin(async (nuxtApp) => { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (nuxtApp.$state.signedIn.value) await init(nuxtApp.$state.token.value) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
watch((nuxtApp.$state as GlobalState).token, (newToken, oldToken) => { |
|
|
|
watch((nuxtApp.$state as GlobalState).token, (newToken, oldToken) => { |
|
|
|
if (newToken && newToken !== oldToken) init(newToken) |
|
|
|
if (newToken && newToken !== oldToken) init(newToken) |
|
|
|
else if (!newToken) socket.disconnect() |
|
|
|
else if (!newToken) socket.disconnect() |
|
|
|