fixes
This commit is contained in:
13
src/App.vue
13
src/App.vue
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
<!-- Контентная часть заполняет оставшееся пространство -->
|
<!-- Контентная часть заполняет оставшееся пространство -->
|
||||||
<div class="flex-grow ">
|
<div class="flex-grow ">
|
||||||
|
{{ tg_id }}
|
||||||
<Button label="Sub" :class="checkNotif ? 'flex' : '!hidden'" @click="checkSubscribe"/>
|
<Button label="Sub" :class="checkNotif ? 'flex' : '!hidden'" @click="checkSubscribe"/>
|
||||||
<router-view/>
|
<router-view/>
|
||||||
</div>
|
</div>
|
||||||
@@ -24,9 +25,19 @@ import {subscribeUserToPush} from "@/services/pushManager";
|
|||||||
import apiClient from '@/services/axiosSetup';
|
import apiClient from '@/services/axiosSetup';
|
||||||
|
|
||||||
const checkNotif = computed(() => {
|
const checkNotif = computed(() => {
|
||||||
return 'Notification' in window && Notification.permission === 'default'
|
|
||||||
|
return !!tg_id.value && 'Notification' in window && Notification.permission === 'default'
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const tg_id = computed(() => {
|
||||||
|
if (window.Telegram?.WebApp) {
|
||||||
|
const tg = window.Telegram.WebApp;
|
||||||
|
tg.expand(); // Разворачиваем приложение на весь экран
|
||||||
|
return tg.initDataUnsafe.user?.id ?? null; // Если tg_id нет, возвращаем null
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
|
||||||
const checkSubscribe = async () => {
|
const checkSubscribe = async () => {
|
||||||
if ("Notification" in window) {
|
if ("Notification" in window) {
|
||||||
if (Notification.permission === 'default') {
|
if (Notification.permission === 'default') {
|
||||||
|
|||||||
Reference in New Issue
Block a user