|
|
@@ -4,16 +4,12 @@
|
|
|
<img :src="posterUrl" alt="" />
|
|
|
|
|
|
<div class="btns">
|
|
|
- <van-button
|
|
|
- class="copy"
|
|
|
- @click="copyText(shareUrl)"
|
|
|
- round
|
|
|
- color="linear-gradient(180deg, #FFD1D8 , #FFEAD0 )"
|
|
|
- >複製連結</van-button
|
|
|
- >
|
|
|
- <van-button class="save" @click="save" round color="linear-gradient(180deg, #FF7340 , #FF3E3E )"
|
|
|
- >保存圖片</van-button
|
|
|
- >
|
|
|
+ <van-button class="copy" @click="share()" round color="linear-gradient(180deg, #FFD1D8 , #FFEAD0 )">
|
|
|
+ 分享
|
|
|
+ </van-button>
|
|
|
+ <van-button class="save" @click="save" round color="linear-gradient(180deg, #FF7340 , #FF3E3E )">
|
|
|
+ 保存圖片
|
|
|
+ </van-button>
|
|
|
</div>
|
|
|
</div>
|
|
|
</ion-modal>
|
|
|
@@ -30,6 +26,7 @@ import { useClipboard } from '@vueuse/core'
|
|
|
import toast from '@/utils/toast'
|
|
|
import { Filesystem, Directory, Encoding } from '@capacitor/filesystem'
|
|
|
import { Media } from '@capacitor-community/media'
|
|
|
+import { Share } from '@capacitor/share'
|
|
|
|
|
|
const show = ref(false)
|
|
|
|
|
|
@@ -59,9 +56,9 @@ const props = defineProps({
|
|
|
const { user } = useUserStore()
|
|
|
async function getInviteUrl() {
|
|
|
if (props.pageType === 'mine') {
|
|
|
- return 'https://shorts.izouma.com/share2.html?referrer=' + user.id
|
|
|
+ return 'https://shorts.izouma.com/static/share2.html?referrer=' + user.id
|
|
|
} else {
|
|
|
- return `https://shorts.izouma.com/share1.html?referrer=${user.id}&num=${props.episodeNum}&title=${
|
|
|
+ return `https://shorts.izouma.com/static/share1.html?referrer=${user.id}&num=${props.episodeNum}&title=${
|
|
|
props.title
|
|
|
}&cover=${encodeURIComponent(props.poster)}`
|
|
|
}
|
|
|
@@ -127,11 +124,15 @@ async function save() {
|
|
|
const savedFile = await Filesystem.writeFile({
|
|
|
path: 'share.png',
|
|
|
data: posterUrl.value,
|
|
|
- directory: Directory.Data
|
|
|
+ directory: Directory.Cache
|
|
|
})
|
|
|
+ const albums = (await Media.getAlbums()).albums
|
|
|
+ console.log(albums)
|
|
|
+ const album = albums?.length ? albums.find(a => a.name === 'Camera') || albums[0] : null
|
|
|
await Media.savePhoto({
|
|
|
path: savedFile.uri,
|
|
|
- album: 'FirstCash'
|
|
|
+ albumIdentifier: album.identifier,
|
|
|
+ name: 'share'
|
|
|
})
|
|
|
toast.success('保存成功')
|
|
|
} catch (e) {
|
|
|
@@ -144,6 +145,23 @@ async function save() {
|
|
|
link.click()
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+async function share() {
|
|
|
+ if (Capacitor.isNativePlatform()) {
|
|
|
+ const savedFile = await Filesystem.writeFile({
|
|
|
+ path: 'share.png',
|
|
|
+ data: posterUrl.value,
|
|
|
+ directory: Directory.Cache
|
|
|
+ })
|
|
|
+ await Share.share({
|
|
|
+ title: '走馬短劇',
|
|
|
+ text: '海量短劇先睹為快',
|
|
|
+ url: savedFile.uri
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ copyText(shareUrl.value)
|
|
|
+ }
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
<style lang="less" scoped>
|