chet novoe
This commit is contained in:
BIN
public/apple-touch-icon.png
Normal file
BIN
public/apple-touch-icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 51 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
31
src/App.vue
31
src/App.vue
@@ -11,8 +11,8 @@
|
||||
<router-view/>
|
||||
</div>
|
||||
<OverlayView class="w-full sticky invisible lg:visible top-0 z-10"/>
|
||||
|
||||
<Button :label="Sub" @click="subscribeUserToPush"/>
|
||||
{{not}}
|
||||
<Button label="Sub" @click="checkSubscribe"/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -22,29 +22,34 @@ import OverlayView from "@/components/OverlayView.vue";
|
||||
import ToolBar from "@/components/ToolBar.vue";
|
||||
import Button from "primevue/button";
|
||||
import axiosSetup from "@/services/axiosSetup";
|
||||
import {onMounted} from "vue";
|
||||
import {onMounted, ref} from "vue";
|
||||
import {subscribeUserToPush} from "@/services/pushManager";
|
||||
import apiClient from '@/services/axiosSetup';
|
||||
|
||||
|
||||
const not = ref(Notification.permission)
|
||||
const checkSubscribe = async () => {
|
||||
if (Notification.permission === 'default') {
|
||||
Notification.requestPermission()
|
||||
await Notification.requestPermission().then(sendSubscribe)
|
||||
} else if (Notification.permission === 'granted') {
|
||||
try {
|
||||
const subscription = await subscribeUserToPush();
|
||||
console.log("Push subscription:", subscription);
|
||||
|
||||
// Отправка подписки на сервер для хранения
|
||||
await apiClient.post("/push/subscribe", subscription)
|
||||
} catch (error) {
|
||||
console.error("Failed to subscribe to push:", error);
|
||||
}
|
||||
await sendSubscribe()
|
||||
} else {
|
||||
// Пользователь ранее отклонил запрос
|
||||
}
|
||||
}
|
||||
|
||||
const sendSubscribe = async () => {
|
||||
try {
|
||||
const subscription = await subscribeUserToPush();
|
||||
console.log("Push subscription:", subscription);
|
||||
|
||||
// Отправка подписки на сервер для хранения
|
||||
await apiClient.post("/push/subscribe", subscription)
|
||||
} catch (error) {
|
||||
console.error("Failed to subscribe to push:", error);
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
await checkSubscribe()
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<!-- fill="var(--p-text-color)"-->
|
||||
<!-- />-->
|
||||
<!-- </svg>-->
|
||||
<img alt="logo" src="/src/assets/32.png" width="32" height="32" />
|
||||
<img alt="logo" src="/apple-touch-icon.png" width="32" height="32" />
|
||||
</template>
|
||||
<template #item="{ item, props, hasSubmenu, root }">
|
||||
<router-link :to="item.url" v-ripple class="flex items-center" v-bind="props.action">
|
||||
|
||||
Reference in New Issue
Block a user