mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-07-21 14:19:41 +02:00
Add Web Share api to ContextMenu.vue (#462)
* Add Web Share api to ContextMenu.vue. Copy to clipboard is the fallback * Add Web Share api to ContextMenu.vue. Copy to clipboard is the fallback * Add translation
This commit is contained in:
parent
59f8b74460
commit
f7f5c97f07
5 changed files with 15308 additions and 19 deletions
|
@ -33,6 +33,7 @@
|
|||
<script>
|
||||
import ConfirmationDialog from "@/components/UI/Dialogs/ConfirmationDialog.vue";
|
||||
import { api } from "@/api";
|
||||
import { utils } from "@/utils";
|
||||
export default {
|
||||
components: {
|
||||
ConfirmationDialog,
|
||||
|
@ -44,6 +45,9 @@ export default {
|
|||
menuIcon: {
|
||||
default: "mdi-dots-vertical",
|
||||
},
|
||||
name: {
|
||||
type: String,
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
loggedIn() {
|
||||
|
@ -64,8 +68,8 @@ export default {
|
|||
action: "print",
|
||||
},
|
||||
{
|
||||
title: this.$t("general.link"),
|
||||
icon: "mdi-content-copy",
|
||||
title: this.$t("general.share"),
|
||||
icon: "mdi-share-variant",
|
||||
color: "accent",
|
||||
action: "share",
|
||||
},
|
||||
|
@ -88,6 +92,9 @@ export default {
|
|||
...this.defaultMenu,
|
||||
];
|
||||
},
|
||||
recipeText() {
|
||||
return this.$t("recipe.share-recipe-message", [this.name]);
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
@ -103,7 +110,15 @@ export default {
|
|||
this.$refs.deleteRecipieConfirm.open();
|
||||
break;
|
||||
case "share":
|
||||
this.updateClipboard();
|
||||
if (navigator.share){
|
||||
navigator.share({
|
||||
title: this.name,
|
||||
text: this.recipeText,
|
||||
url: this.recipeURL,
|
||||
})
|
||||
.then(() => console.log('Successful share'))
|
||||
.catch((error) => console.log('WebShareAPI not supported', error))
|
||||
} else this.updateClipboard();
|
||||
break;
|
||||
case "edit":
|
||||
this.$router.push(`/recipe/${this.slug}` + "?edit=true");
|
||||
|
@ -123,10 +138,10 @@ export default {
|
|||
updateClipboard() {
|
||||
const copyText = this.recipeURL;
|
||||
navigator.clipboard.writeText(copyText).then(
|
||||
() => console.log("Copied", copyText),
|
||||
() => console.log("Copied Failed", copyText)
|
||||
);
|
||||
() => { console.log("Copied to Clipboard", copyText);
|
||||
utils.notify.success("Copied to Clipboard");},
|
||||
() => console.log("Copied Failed", copyText));
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
</script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue