add support GCM
Main daploy / deploy (push) Successful in 44s

This commit is contained in:
2024-11-25 22:58:10 +02:00
parent 1f85f23792
commit 16a0fa76de
7 changed files with 70 additions and 35 deletions
+1
View File
@@ -26,6 +26,7 @@ declare module 'vue' {
ExamplesSection: typeof import('./src/components/TheWelcome/ExamplesSection.vue')['default']
InputText: typeof import('primevue/inputtext')['default']
ManagePlacementInstructions: typeof import('./src/components/manage/ManagePlacementInstructions.vue')['default']
ProgressSpinner: typeof import('primevue/progressspinner')['default']
QueryRender: typeof import('./src/components/QueryRender.vue')['default']
RadioButton: typeof import('primevue/radiobutton')['default']
ReadContactInfo: typeof import('./src/components/read/ReadContactInfo.vue')['default']
+2 -1
View File
@@ -16,5 +16,6 @@
],
"theme_color": "#ffffff",
"background_color": "#ffffff",
"display": "standalone"
"display": "standalone",
"gcm_sender_id": "822536580006"
}
+8 -3
View File
@@ -8,6 +8,12 @@ self.addEventListener('install', (event) => {
// of event.waitUntil();
})
self.addEventListener('activate', (event) => {
event.waitUntil(
clients.claim(), // Привязка нового сервис-воркера к текущим клиентам
)
})
self.addEventListener('push', (event) => {
const data = event.data.json()
console.log('Push событие получено:', data.type)
@@ -77,10 +83,9 @@ self.addEventListener('notificationclick', (event) => {
if (clients.openWindow) {
console.log('новое окно', urlToOpen)
return clients.openWindow(urlToOpen).then((client) => {
if (client) {
return client.focus()
if (!client) {
console.log('новое окно не открылось')
}
console.log('новое окно не открылось')
})
}
})
@@ -1,7 +1,8 @@
<template>
<div class="flex items-center gap-2">
<i class="pi pi-spin pi-spinner" v-if="isLoading"></i>
<div v-if="isLoading" class="w-5 h-5">
<ProgressSpinner style="width: 100%; height: 100%" strokeWidth="8" fill="transparent" />
</div>
<RadioButton
v-else
v-model="model"
@@ -10,6 +11,7 @@
:value="method"
@change="$emit('change', $event)"
/>
<label :for="method">{{ label }}</label>
</div>
</template>
@@ -1,5 +1,5 @@
<template>
<CreateMessageDeliveryOption :isLoading="isLoading" :label :method v-model="model" />
<CreateMessageDeliveryOption :isLoading :label :method v-model="model" />
<!-- Ошибка разрешений -->
<p v-if="isError && model === method" class="text-red-500 mb-2">
@@ -44,6 +44,7 @@ async function requestNotificationPermission() {
}
const registration = await navigator.serviceWorker.ready
const subscription = await registration.pushManager.subscribe({
userVisibleOnly: true,
applicationServerKey: await applicationServerKeyPromise,