feat: restructure into XFlow monorepo with Nuxt 4, Modular Onion Monolith, Android client, and Desktop CLI
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import { initializeApp, getApps } from 'firebase/app'
|
||||
|
||||
export default defineNuxtPlugin(() => {
|
||||
const config = useRuntimeConfig()
|
||||
|
||||
const firebaseConfig = {
|
||||
apiKey: config.public.firebaseApiKey,
|
||||
authDomain: config.public.firebaseAuthDomain,
|
||||
projectId: config.public.firebaseProjectId,
|
||||
appId: config.public.firebaseAppId,
|
||||
messagingSenderId: config.public.firebaseMessagingSenderId
|
||||
}
|
||||
|
||||
if (!firebaseConfig.apiKey) {
|
||||
console.warn('[Firebase] API key not configured. Google Sign-In will not work.')
|
||||
return
|
||||
}
|
||||
|
||||
if (!getApps().length) {
|
||||
initializeApp(firebaseConfig)
|
||||
console.log('[Firebase] Initialized')
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,26 @@
|
||||
export default defineNuxtPlugin(() => {
|
||||
if ('serviceWorker' in navigator) {
|
||||
navigator.serviceWorker.ready.then(registration => {
|
||||
console.log('[PWA] Service Worker ready:', registration.scope)
|
||||
})
|
||||
|
||||
// Handle push messages when app is open
|
||||
navigator.serviceWorker.addEventListener('message', event => {
|
||||
if (event.data?.type === 'PUSH_RECEIVED') {
|
||||
const { title, body } = event.data.payload || {}
|
||||
// Local alarm: vibrate and show notification
|
||||
if (navigator.vibrate) {
|
||||
navigator.vibrate([200, 100, 200])
|
||||
}
|
||||
if ('Notification' in window && Notification.permission === 'granted') {
|
||||
new Notification(title || 'XFlow Alarm', {
|
||||
body: body || 'Alarm triggered',
|
||||
icon: '/pwa-192x192.svg',
|
||||
badge: '/favicon.svg',
|
||||
...({ vibrate: [200, 100, 200] } as any)
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user