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

38
pages/share-target.vue Normal file
View file

@ -0,0 +1,38 @@
<script setup>
definePageMeta({
middleware: () => {
if (!useRuntimeConfig().public.pwaEnabled)
return navigateTo('/')
},
})
useWebShareTarget()
const pwaIsInstalled = process.server ? false : useNuxtApp().$pwa.isInstalled
</script>
<template>
<MainContent>
<template #title>
<NuxtLink to="/share-target" flex items-center gap-2>
<div i-ri:share-line />
<span>{{ $t('share-target.title') }}</span>
</NuxtLink>
</template>
<slot>
<div flex="~ col" px5 py2 gap-y-4>
<div
v-if="!pwaIsInstalled || !currentUser"
role="alert"
gap-1
p-2
text-red-600 dark:text-red-400
border="~ base rounded red-600 dark:red-400"
>
{{ $t('share-target.hint') }}
</div>
<div>{{ $t('share-target.description') }}</div>
</div>
</slot>
</MainContent>
</template>