mirror of
https://github.com/VueTorrent/VueTorrent.git
synced 2025-02-26 20:31:13 +03:00
perf: Add toasts for copy/paste success/error (#620)
This commit is contained in:
parent
e990d344d2
commit
6cabef1b56
4 changed files with 18 additions and 9 deletions
|
@ -241,19 +241,24 @@ export default {
|
||||||
startDropFile() {
|
startDropFile() {
|
||||||
this.showWrapDrag = true
|
this.showWrapDrag = true
|
||||||
},
|
},
|
||||||
DragLeave(e) {
|
DragLeave() {
|
||||||
this.showWrapDrag = false
|
this.showWrapDrag = false
|
||||||
},
|
},
|
||||||
closeWrap() {
|
closeWrap() {
|
||||||
if (this.showWrapDrag) this.showWrapDrag = false
|
if (this.showWrapDrag) this.showWrapDrag = false
|
||||||
else this.close()
|
else this.close()
|
||||||
},
|
},
|
||||||
async paste() {
|
async paste(e) {
|
||||||
if (navigator.clipboard && window.isSecureContext) {
|
if (navigator.clipboard && window.isSecureContext) {
|
||||||
this.urls = await navigator.clipboard.readText()
|
this.urls = await navigator.clipboard.readText()
|
||||||
} else {
|
} else {
|
||||||
this.urls = document.execCommand('paste')
|
e.target.focus()
|
||||||
|
if (!document.execCommand('paste')) {
|
||||||
|
this.$toast.error(this.$i18n.t("toast.pasteNotSupported").toString())
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
this.$toast.success(this.$i18n.t("toast.pasteSuccess").toString())
|
||||||
},
|
},
|
||||||
submit() {
|
submit() {
|
||||||
if (this.files.length || this.urls) {
|
if (this.files.length || this.urls) {
|
||||||
|
|
|
@ -432,13 +432,13 @@ export default {
|
||||||
textArea.style.opacity = '0'
|
textArea.style.opacity = '0'
|
||||||
document.body.appendChild(textArea)
|
document.body.appendChild(textArea)
|
||||||
textArea.select()
|
textArea.select()
|
||||||
try {
|
if (!document.execCommand('copy')) {
|
||||||
document.execCommand('copy')
|
this.$toast.error(this.$i18n.t("toast.copyNotSupported").toString())
|
||||||
} catch (err) {
|
return
|
||||||
console.error('Unable to copy to clipboard', err)
|
|
||||||
}
|
}
|
||||||
document.body.removeChild(textArea)
|
document.body.removeChild(textArea)
|
||||||
}
|
}
|
||||||
|
this.$toast.success(this.$i18n.t("toast.copySuccess").toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -461,7 +461,9 @@
|
||||||
"ruleSaved": "Rule saved!",
|
"ruleSaved": "Rule saved!",
|
||||||
"renameFileFailed": "Unable to rename file",
|
"renameFileFailed": "Unable to rename file",
|
||||||
"renameFolderFailed": "Unable to rename file",
|
"renameFolderFailed": "Unable to rename file",
|
||||||
|
"copySuccess": "Text copied!",
|
||||||
"copyNotSupported": "Unable to copy, clipboard API unavailable on this browser",
|
"copyNotSupported": "Unable to copy, clipboard API unavailable on this browser",
|
||||||
|
"pasteSuccess": "Text pasted!",
|
||||||
"pasteNotSupported": "Unable to paste, clipboard API unavailable on this browser"
|
"pasteNotSupported": "Unable to paste, clipboard API unavailable on this browser"
|
||||||
},
|
},
|
||||||
"rightClick": {
|
"rightClick": {
|
||||||
|
|
|
@ -450,8 +450,10 @@
|
||||||
"ruleSaved": "Règle enregistrée !",
|
"ruleSaved": "Règle enregistrée !",
|
||||||
"renameFileFailed": "Impossible de renommer le fichier",
|
"renameFileFailed": "Impossible de renommer le fichier",
|
||||||
"renameFolderFailed": "Impossible de renommer le dossier",
|
"renameFolderFailed": "Impossible de renommer le dossier",
|
||||||
"copyNotSupported": "Impossible de copier, clipboard API indisponible dans ce navigateur",
|
"copySuccess": "Texte copié!",
|
||||||
"pasteNotSupported": "Impossible de coller, clipboard API indisponible dans ce navigateur"
|
"copyNotSupported": "Impossible de copier, Clipboard API indisponible dans ce navigateur",
|
||||||
|
"pasteSuccess": "Texte collé!",
|
||||||
|
"pasteNotSupported": "Impossible de coller, Clipboard API indisponible dans ce navigateur"
|
||||||
},
|
},
|
||||||
"rightClick": {
|
"rightClick": {
|
||||||
"resume": "Reprendre",
|
"resume": "Reprendre",
|
||||||
|
|
Loading…
Add table
Reference in a new issue