mirror of
https://github.com/ArthurDanjou/artsite.git
synced 2026-01-20 18:22:21 +01:00
Refactor WebSocket handling and remove nuxt-visitors module
Replaced nuxt-visitors module with a custom WebSocket implementation for location tracking. Removed redundant code and comments in `useVisitors` composable and introduced the `location.server` plugin to manage user location. Updated dependencies and configurations to reflect these changes, streamlining the approach.
This commit is contained in:
11
app/plugins/location.server.ts
Normal file
11
app/plugins/location.server.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
export default defineNuxtPlugin(() => {
|
||||
const event = useRequestEvent()
|
||||
console.log('event', event)
|
||||
|
||||
useState('location', () => ({
|
||||
latitude: event?.context.cf?.latitude || Math.random() * 180 - 90, // default to random latitude (only in dev)
|
||||
longitude: event?.context.cf?.longitude || Math.random() * 360 - 180, // default to random longitude (only in dev)
|
||||
}))
|
||||
|
||||
console.log(useState('location').value)
|
||||
})
|
||||
Reference in New Issue
Block a user