18 lines
512 B
TypeScript
18 lines
512 B
TypeScript
import { useLocationStore } from '~/stores/location'
|
|
|
|
export default defineNuxtPlugin(() => {
|
|
const nuxtApp = useNuxtApp()
|
|
const me = nuxtApp.ssrContext?.event.context.me ?? null
|
|
const state = useState('me', () => null)
|
|
|
|
if (me) {
|
|
state.value = me
|
|
|
|
// Заполнить locationStore сразу на сервере для SSR
|
|
const locationStore = useLocationStore()
|
|
if (me.activeTeam?.selectedLocation) {
|
|
locationStore.setFromUserData(me.activeTeam.selectedLocation)
|
|
}
|
|
}
|
|
})
|