fix isAppRunning

This commit is contained in:
Surya Paolo
2022-12-20 10:58:55 +01:00
parent 3aaa94c33e
commit 2a97456c0f
17 changed files with 57 additions and 36 deletions

View File

@@ -1,4 +1,4 @@
import { defineComponent, ref, computed, PropType, toRef } from 'vue'
import { defineComponent, ref, computed, PropType, toRef, onMounted } from 'vue'
import { useUserStore } from '@store/UserStore'
import { useRouter } from 'vue-router'
import { useGlobalStore } from '@store/globalStore'
@@ -19,36 +19,41 @@ export default defineComponent({
const globalStore = useGlobalStore()
const { t } = useI18n()
const deferredPrompt = ref(<any>null)
const isAppRunning = computed(() => globalStore.isAppRunning )
const finishLoading = computed(() => globalStore.finishLoading)
const deferredPrompt = computed(() => globalStore.deferredPrompt)
function initprompt() {
window.addEventListener('beforeinstallprompt', (event) => {
event.preventDefault()
console.log('beforeinstallprompt !')
// Stash the event so it can be triggered later.
deferredPrompt.value = event
globalStore.deferredPrompt = event
})
}
function installApp() {
if (deferredPrompt.value)
deferredPrompt.value.prompt()
if (globalStore.deferredPrompt)
globalStore.deferredPrompt.prompt()
}
initprompt()
function mounted() {
initprompt()
tools.checkApp()
}
onMounted(mounted)
return {
userStore,
tools,
costanti,
finishLoading,
deferredPrompt,
installApp,
isAppRunning,
deferredPrompt,
}
}
})