Files
appco_dist/.output/public/_nuxt/D6aLwMZ4.js
T
2026-03-07 16:09:22 +03:30

2 lines
1.4 KiB
JavaScript

import{_ as d}from"./Cd5IQGm4.js";import{B as m}from"./D8wkbzbL.js";import{d as u,r as a,o as _,e as f,a0 as w,z as s,G as v,E as h,A,D as P,T as B}from"./sHYMdOhR.js";const W={key:0},g=u({__name:"InstallButton",emits:["show"],setup(I,{emit:r}){const i=r,t=a(!1),o=a(null),n=e=>{console.log("[PWA] beforeinstallprompt fired"),e.preventDefault(),o.value=e,t.value=!0},l=()=>{console.log("[PWA] App installed"),o.value=null,t.value=!1};_(()=>{window.matchMedia("(display-mode: standalone)").matches?console.log("[PWA] App already installed"):(window.addEventListener("beforeinstallprompt",n),window.addEventListener("appinstalled",l),console.log("[PWA] Waiting for install prompt..."),console.log("[PWA] Current URL:",window.location.href),console.log("[PWA] Protocol:",window.location.protocol))}),f(()=>{window.removeEventListener("beforeinstallprompt",n),window.removeEventListener("appinstalled",l)});const c=async()=>{if(!o.value){console.warn("[PWA] No installation prompt available");return}try{o.value.prompt();const{outcome:e}=await o.value.userChoice;console.log("[PWA] User choice:",e),e==="accepted"&&(t.value=!1)}catch(e){console.error("[PWA] Installation error:",e)}finally{o.value=null}};return w(t,e=>{i("show",e)}),(e,y)=>{const p=d;return s(),v(p,null,{default:h(()=>[t.value?(s(),A("div",W,[P(m,{onClick:c,icon:"vuesax-linear:import-2",title:"نصب اپلیکیشن"})])):B("",!0)]),_:1})}}}),b=Object.assign(g,{__name:"InstallButton"});export{b as _};