- Installa APP: Messaggio in CIMA
- in sistemazione: select compare la scelta di prima.
This commit is contained in:
54
src/components/CCheckAppRunning/CCheckAppRunning.ts
Executable file
54
src/components/CCheckAppRunning/CCheckAppRunning.ts
Executable file
@@ -0,0 +1,54 @@
|
||||
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,
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user