forked from Mirrors/elk
chore: refactor cancel install logic
This commit is contained in:
parent
b1876bc160
commit
0ce69d5399
1 changed files with 7 additions and 5 deletions
|
@ -76,6 +76,12 @@ export default defineNuxtPlugin(() => {
|
||||||
showInstallPrompt.value = false
|
showInstallPrompt.value = false
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const cancelInstall = () => {
|
||||||
|
deferredPrompt = undefined
|
||||||
|
showInstallPrompt.value = false
|
||||||
|
window.removeEventListener('beforeinstallprompt', beforeInstallPrompt)
|
||||||
|
}
|
||||||
|
|
||||||
const install = async () => {
|
const install = async () => {
|
||||||
if (!showInstallPrompt.value || !deferredPrompt) {
|
if (!showInstallPrompt.value || !deferredPrompt) {
|
||||||
showInstallPrompt.value = false
|
showInstallPrompt.value = false
|
||||||
|
@ -87,11 +93,7 @@ export default defineNuxtPlugin(() => {
|
||||||
deferredPrompt.prompt()
|
deferredPrompt.prompt()
|
||||||
const { outcome } = await deferredPrompt.userChoice
|
const { outcome } = await deferredPrompt.userChoice
|
||||||
if (outcome === 'dismissed')
|
if (outcome === 'dismissed')
|
||||||
window.removeEventListener('beforeinstallprompt', beforeInstallPrompt)
|
cancelInstall()
|
||||||
}
|
|
||||||
|
|
||||||
const cancelInstall = () => {
|
|
||||||
showInstallPrompt.value = false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in a new issue