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/>
|
<router-view/>
|
||||||
</div>
|
</div>
|
||||||
<OverlayView class="w-full sticky invisible lg:visible top-0 z-10"/>
|
<OverlayView class="w-full sticky invisible lg:visible top-0 z-10"/>
|
||||||
|
{{not}}
|
||||||
<Button :label="Sub" @click="subscribeUserToPush"/>
|
<Button label="Sub" @click="checkSubscribe"/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -22,29 +22,34 @@ import OverlayView from "@/components/OverlayView.vue";
|
|||||||
import ToolBar from "@/components/ToolBar.vue";
|
import ToolBar from "@/components/ToolBar.vue";
|
||||||
import Button from "primevue/button";
|
import Button from "primevue/button";
|
||||||
import axiosSetup from "@/services/axiosSetup";
|
import axiosSetup from "@/services/axiosSetup";
|
||||||
import {onMounted} from "vue";
|
import {onMounted, ref} from "vue";
|
||||||
import {subscribeUserToPush} from "@/services/pushManager";
|
import {subscribeUserToPush} from "@/services/pushManager";
|
||||||
import apiClient from '@/services/axiosSetup';
|
import apiClient from '@/services/axiosSetup';
|
||||||
|
|
||||||
|
|
||||||
|
const not = ref(Notification.permission)
|
||||||
const checkSubscribe = async () => {
|
const checkSubscribe = async () => {
|
||||||
if (Notification.permission === 'default') {
|
if (Notification.permission === 'default') {
|
||||||
Notification.requestPermission()
|
await Notification.requestPermission().then(sendSubscribe)
|
||||||
} else if (Notification.permission === 'granted') {
|
} else if (Notification.permission === 'granted') {
|
||||||
try {
|
await sendSubscribe()
|
||||||
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);
|
|
||||||
}
|
|
||||||
} else {
|
} 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 () => {
|
onMounted(async () => {
|
||||||
await checkSubscribe()
|
await checkSubscribe()
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
<!-- fill="var(--p-text-color)"-->
|
<!-- fill="var(--p-text-color)"-->
|
||||||
<!-- />-->
|
<!-- />-->
|
||||||
<!-- </svg>-->
|
<!-- </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>
|
||||||
<template #item="{ item, props, hasSubmenu, root }">
|
<template #item="{ item, props, hasSubmenu, root }">
|
||||||
<router-link :to="item.url" v-ripple class="flex items-center" v-bind="props.action">
|
<router-link :to="item.url" v-ripple class="flex items-center" v-bind="props.action">
|
||||||
|
|||||||
Reference in New Issue
Block a user