mirror of
https://codeberg.org/JasterV/intisync.ex.git
synced 2026-04-26 18:10:07 +00:00
27 lines
722 B
JavaScript
27 lines
722 B
JavaScript
const NativeShare = () => {
|
|
return {
|
|
mounted() {
|
|
this.el.addEventListener("click", async () => {
|
|
// Check if sharing is supported
|
|
if (!navigator.canShare) {
|
|
this.pushEvent("url_share_error", {
|
|
error: "Unfortunately, sharing is not supported",
|
|
});
|
|
return;
|
|
}
|
|
|
|
try {
|
|
await navigator.share({
|
|
title: this.el.dataset.title,
|
|
text: this.el.dataset.text,
|
|
url: this.el.dataset.url,
|
|
});
|
|
this.pushEvent("url_shared", {});
|
|
} catch (error) {
|
|
this.pushEvent("url_share_error", { error: error.message });
|
|
}
|
|
});
|
|
},
|
|
};
|
|
};
|
|
export default NativeShare;
|