From 02b3abfb8c861ea00f6ce8bc162936e18ba8a87d Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Sat, 12 Aug 2023 13:17:53 +0200 Subject: [PATCH] [#110] Add interaction buttons for displayed secret - Copy secret to clipboard - Download secret to local text file - Display secret as QR-Code (i.e. TOTP URIs) Signed-off-by: Knut Ahlers --- src/app.vue | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 66 insertions(+), 2 deletions(-) diff --git a/src/app.vue b/src/app.vue index ccc2a1d..201964e 100644 --- a/src/app.vue +++ b/src/app.vue @@ -235,15 +235,56 @@ @@ -311,6 +352,7 @@ export default { secretExpiry: null, secretId: '', secretQRDataURL: '', + secretContentQRDataURL: '', securePassword: '', selectedExpiry: null, showError: false, @@ -335,6 +377,16 @@ export default { }) }, + copySecret() { + navigator.clipboard.writeText(this.secret) + .then(() => { + this.copyToClipboardSuccess = true + window.setTimeout(() => { + this.copyToClipboardSuccess = false + }, 500) + }) + }, + copySecretUrl() { navigator.clipboard.writeText(this.secretUrl) .then(() => { @@ -503,6 +555,18 @@ export default { window.setTheme(to ? 'dark' : 'light') }, + secret(to) { + if (this.customize.disableQRSupport || !to) { + return + } + + qrcode.toDataURL(to, { width: 200 }) + .then(url => { + this.secretContentQRDataURL = url + }) + .catch(() => this.secretContentQRDataURL = null) + }, + secretUrl(to) { if (this.customize.disableQRSupport) { return