55 lines
1.4 KiB
TypeScript
Executable File
55 lines
1.4 KiB
TypeScript
Executable File
import { defineComponent, ref, computed, PropType, toRef } from 'vue'
|
|
import { useUserStore } from '@store/UserStore'
|
|
import { useRouter } from 'vue-router'
|
|
import { useGlobalStore } from '@store/globalStore'
|
|
import { useI18n } from '@/boot/i18n'
|
|
import { tools } from '@store/Modules/tools'
|
|
import { costanti, IMainCard } from '@store/Modules/costanti'
|
|
import { CBigBtn } from '@/components/CBigBtn'
|
|
|
|
|
|
export default defineComponent({
|
|
name: 'CCheckAppRunning',
|
|
components: { CBigBtn },
|
|
props: {},
|
|
setup(props, { emit }) {
|
|
|
|
const userStore = useUserStore()
|
|
const $router = useRouter()
|
|
const globalStore = useGlobalStore()
|
|
const { t } = useI18n()
|
|
|
|
const deferredPrompt = ref(<any>null)
|
|
|
|
const isAppRunning = computed(() => globalStore.isAppRunning )
|
|
|
|
const finishLoading = computed(() => globalStore.finishLoading)
|
|
|
|
function initprompt() {
|
|
window.addEventListener('beforeinstallprompt', (event) => {
|
|
event.preventDefault()
|
|
console.log('beforeinstallprompt !')
|
|
// Stash the event so it can be triggered later.
|
|
deferredPrompt.value = event
|
|
})
|
|
}
|
|
|
|
function installApp() {
|
|
if (deferredPrompt.value)
|
|
deferredPrompt.value.prompt()
|
|
}
|
|
|
|
initprompt()
|
|
|
|
return {
|
|
userStore,
|
|
tools,
|
|
costanti,
|
|
finishLoading,
|
|
deferredPrompt,
|
|
installApp,
|
|
isAppRunning,
|
|
}
|
|
}
|
|
})
|