add copy functionality

This commit is contained in:
Bnyro 2022-08-28 16:35:40 +02:00 committed by Kavin
parent 960e0ce15e
commit ed9379dad7
No known key found for this signature in database
GPG Key ID: 49451E4482CC5BCD
2 changed files with 15 additions and 5 deletions

View File

@ -14,7 +14,7 @@
<h3 class="mt-4" v-text="generatedLink" />
<div class="flex justify-end mt-4">
<button class="btn" v-t="'actions.follow_link'" @click="followLink()" />
<button class="btn ml-5" v-t="'actions.copy_link'" @click="copyLink()" />
<button class="btn ml-3" v-t="'actions.copy_link'" @click="copyLink()" />
</div>
</div>
</div>
@ -68,10 +68,18 @@ export default {
event.preventDefault();
},
followLink() {
window.location.href = this.generatedLink;
window.open(this.generatedLink, "_blank").focus();
},
copyLink() {
this.$emit("close");
async copyLink() {
await this.copyURL(this.generatedLink);
},
async copyURL(mytext) {
try {
await navigator.clipboard.writeText(mytext);
alert(this.$t("info.copied"));
} catch ($e) {
alert(this.$t("info.cannot_copy"));
}
},
},
computed: {

View File

@ -149,6 +149,8 @@
},
"info": {
"preferences_note": "Note: preferences are saved in the local storage of your browser. Deleting your browser data will reset them.",
"page_not_found": "Page not found"
"page_not_found": "Page not found",
"copied": "Copied!",
"cannot_copy": "Can't copy!"
}
}