test
This commit is contained in:
@@ -87,27 +87,20 @@ const shareImageToWhatsapp = async (url) => {
|
|||||||
|
|
||||||
// 创建文件对象
|
// 创建文件对象
|
||||||
const file = new File([blob], 'image.jpg', { type: 'image/jpeg' })
|
const file = new File([blob], 'image.jpg', { type: 'image/jpeg' })
|
||||||
const message = '分享了图片 ' + url
|
|
||||||
|
|
||||||
// 构造WhatsApp链接
|
|
||||||
const whatsappLink = `https://api.whatsapp.com/send?text=${encodeURIComponent(message)}`
|
|
||||||
window.open(whatsappLink, '_blank')
|
|
||||||
|
|
||||||
// 判断浏览器是否支持文件分享
|
// 判断浏览器是否支持文件分享
|
||||||
// if (navigator.canShare && navigator.canShare({ files: [file] })) {
|
if (navigator.canShare && navigator.canShare({ files: [file] })) {
|
||||||
// await navigator.share({
|
await navigator.share({
|
||||||
// files: [file],
|
files: [file]
|
||||||
// title: '分享图片',
|
})
|
||||||
// text: '给你一张图片'
|
} else {
|
||||||
// })
|
// 你可以附加一些自定义文本
|
||||||
// } else {
|
const message = 'share image ' + url
|
||||||
// // 你可以附加一些自定义文本
|
|
||||||
// const message = '看看这张图片! ' + url
|
|
||||||
|
|
||||||
// // 构造WhatsApp链接
|
// 构造WhatsApp链接
|
||||||
// const whatsappLink = `whatsapp://send?text=${encodeURIComponent(message)}`
|
const whatsappLink = `https://api.whatsapp.com/send/?text=${encodeURIComponent(message)}`
|
||||||
// window.open(whatsappLink, '_blank')
|
window.open(whatsappLink, '_blank')
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const isShare = ref(false)
|
const isShare = ref(false)
|
||||||
|
|||||||
Reference in New Issue
Block a user