Initial commit from monorepo
This commit is contained in:
17
app/plugins/me.server.ts
Normal file
17
app/plugins/me.server.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user