feat: add support for the Web Share Target API (#1100)

Co-authored-by: userquin <userquin@gmail.com>
This commit is contained in:
Horváth Bálint 2023-01-14 21:58:52 +01:00 committed by GitHub
parent a6a825e553
commit bede92404b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 221 additions and 7 deletions

View file

@ -5,6 +5,12 @@ export default defineNuxtPlugin(() => {
const registrationError = ref(false)
const swActivated = ref(false)
// https://thomashunter.name/posts/2021-12-11-detecting-if-pwa-twa-is-installed
const ua = navigator.userAgent
const ios = ua.match(/iPhone|iPad|iPod/)
const standalone = window.matchMedia('(display-mode: standalone)').matches
const isInstalled = !!(standalone || (ios && !ua.match(/Safari/)))
const registerPeriodicSync = (swUrl: string, r: ServiceWorkerRegistration) => {
setInterval(async () => {
if (!online.value)
@ -54,6 +60,7 @@ export default defineNuxtPlugin(() => {
return {
provide: {
pwa: reactive({
isInstalled,
swActivated,
registrationError,
needRefresh,