(install PWA) Add install PWA app

This commit is contained in:
Julien Calixte
2019-11-08 13:08:39 +01:00
parent 3c3516ed86
commit a9615c4feb
5 changed files with 64 additions and 1 deletions

View File

@@ -0,0 +1,29 @@
<template>
<span class="install-app" v-if="showInstall">
<a @click="prompt" class="navbar-item">installer</a>
<pwa-install></pwa-install>
</span>
</template>
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator'
import accountService from '@/services/AccountService'
@Component
export default class InstallApp extends Vue {
private showInstall: boolean = false
public mounted(): void {
window.addEventListener('beforeinstallprompt', async () => {
const accounts = await accountService.getAll(true)
this.showInstall = accounts.length > 0
})
}
public prompt(): void {
const pwaInstall = document.querySelector('pwa-install') as any
if (pwaInstall) {
pwaInstall.openPrompt()
}
}
}
</script>