fix isAppRunning
This commit is contained in:
@@ -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,
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user