Il problema era sulla fetch nel service worker, gestita in quel modo personalizzato, andava in conflitto, non tenendo le chiamate bloccanti, ma uscivano prima che arrivasse la risposta del server. - Per chi è da tanto che non si collega a RISO, compare "Email non verificata"... (si risolve chiudendo su ESCI e riloggandosi)... però andrebbe sistemata. (stesso problema di prima).
68 lines
1.9 KiB
TypeScript
Executable File
68 lines
1.9 KiB
TypeScript
Executable File
import { defineComponent, ref, computed, onMounted } from 'vue';
|
||
import { useGlobalStore } from '@store/globalStore';
|
||
import { tools } from '@tools';
|
||
|
||
export default defineComponent({
|
||
name: 'CCheckAppRunning',
|
||
setup() {
|
||
const globalStore = useGlobalStore();
|
||
|
||
const isAppRunning = computed(() => globalStore.isAppRunning === true);
|
||
const finishLoading = computed(() => globalStore.finishLoading === true);
|
||
const deferredPrompt = computed(() => globalStore.deferredPrompt);
|
||
const homescreen = computed(() => globalStore.homescreen === true);
|
||
|
||
const viewiOS = ref(false);
|
||
const viewAndroid = ref(false);
|
||
const showNotice = ref(false);
|
||
const showOther = ref(false);
|
||
|
||
// === Rilevamento WebView ===
|
||
const currentUrl = window.location.href;
|
||
|
||
const webViewDetectors = [
|
||
{ name: 'Telegram', test: /Telegram/ },
|
||
{ name: 'WhatsApp', test: /WhatsApp/ },
|
||
{ name: 'Facebook', test: /FBAV|FBAN/ },
|
||
{ name: 'Instagram', test: /Instagram/ },
|
||
{ name: 'Messenger', test: /Messenger/ },
|
||
];
|
||
|
||
const matchedWebView = webViewDetectors.find(({ test }) => test.test(navigator.userAgent));
|
||
const isInRestrictedWebView = !!matchedWebView;
|
||
const webViewName = matchedWebView ? matchedWebView.name : 'un’app';
|
||
|
||
// === Installazione ===
|
||
function installApp() {
|
||
if (globalStore.deferredPrompt) {
|
||
globalStore.deferredPrompt.prompt();
|
||
globalStore.deferredPrompt.userChoice.then((choiceResult: any) => {
|
||
if (choiceResult.outcome === 'accepted') {
|
||
globalStore.deferredPrompt = null;
|
||
}
|
||
});
|
||
}
|
||
}
|
||
|
||
onMounted(() => {
|
||
tools.checkApp();
|
||
});
|
||
|
||
return {
|
||
tools,
|
||
finishLoading,
|
||
isAppRunning,
|
||
deferredPrompt,
|
||
homescreen,
|
||
viewiOS,
|
||
viewAndroid,
|
||
installApp,
|
||
isInRestrictedWebView,
|
||
webViewName,
|
||
currentUrl,
|
||
showNotice,
|
||
showOther,
|
||
};
|
||
},
|
||
});
|