feat:#17 add share button on calendar link page

This commit is contained in:
survellow
2024-08-14 23:53:07 +02:00
parent 00009f7bfe
commit ebbfb6b48e
4 changed files with 94 additions and 25 deletions

View File

@@ -84,28 +84,76 @@ const forwardToHTWKalendar = () => {
});
};
const actions = computed(() => [
{
label: t("calendarLink.copyToClipboard"),
icon: "pi pi-copy",
command: copyToClipboard,
},
{
label: t("calendarLink.toGoogleCalendar"),
icon: "pi pi-google",
command: forwardToGoogle,
},
{
label: t("calendarLink.toMicrosoftCalendar"),
icon: "pi pi-microsoft",
command: forwardToMicrosoft,
},
{
label: t("calendarLink.toHTWKalendar"),
icon: "pi pi-home",
command: forwardToHTWKalendar,
},
]);
const shareLink = () => {
if (typeof navigator.share === 'function' && navigator.canShare()) {
navigator
.share({
title: t("calendarLink.shareTitle"),
text: t("calendarLink.shareText") + getLink(),
url: "https://" + domain + "/",
})
.then(() => {
toast.add({
severity: "info",
summary: t("calendarLink.shareToastSummary"),
detail: t("calendarLink.shareToastNotification"),
life: 3000,
});
})
.catch(() => {
toast.add({
severity: "error",
summary: t("calendarLink.shareToastError"),
detail: t("calendarLink.shareToastErrorDetail"),
life: 3000,
});
});
} else {
toast.add({
severity: "error",
summary: t("calendarLink.shareToastError"),
detail: t("calendarLink.shareToastErrorDetail"),
life: 3000,
});
}
};
const actions = computed(() => {
var actionList = [
{
label: t("calendarLink.copyToClipboard"),
icon: "pi pi-copy",
command: copyToClipboard,
},
{
label: t("calendarLink.toGoogleCalendar"),
icon: "pi pi-google",
command: forwardToGoogle,
},
{
label: t("calendarLink.toMicrosoftCalendar"),
icon: "pi pi-microsoft",
command: forwardToMicrosoft,
},
{
label: t("calendarLink.toHTWKalendar"),
icon: "pi pi-home",
command: forwardToHTWKalendar,
}
];
if (typeof navigator.share === 'function' && navigator.canShare()) {
actionList.push({
label: t("calendarLink.share"),
icon: "pi pi-share-alt",
command: shareLink,
});
}
return actionList;
}
);
</script>
<template>