mirror of
https://github.com/VueTorrent/VueTorrent.git
synced 2024-11-28 21:18:54 +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() {
|
||||
this.showWrapDrag = true
|
||||
},
|
||||
DragLeave(e) {
|
||||
DragLeave() {
|
||||
this.showWrapDrag = false
|
||||
},
|
||||
closeWrap() {
|
||||
if (this.showWrapDrag) this.showWrapDrag = false
|
||||
else this.close()
|
||||
},
|
||||
async paste() {
|
||||
async paste(e) {
|
||||
if (navigator.clipboard && window.isSecureContext) {
|
||||
this.urls = await navigator.clipboard.readText()
|
||||
} 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() {
|
||||
if (this.files.length || this.urls) {
|
||||
|
|
|
@ -432,13 +432,13 @@ export default {
|
|||
textArea.style.opacity = '0'
|
||||
document.body.appendChild(textArea)
|
||||
textArea.select()
|
||||
try {
|
||||
document.execCommand('copy')
|
||||
} catch (err) {
|
||||
console.error('Unable to copy to clipboard', err)
|
||||
if (!document.execCommand('copy')) {
|
||||
this.$toast.error(this.$i18n.t("toast.copyNotSupported").toString())
|
||||
return
|
||||
}
|
||||
document.body.removeChild(textArea)
|
||||
}
|
||||
this.$toast.success(this.$i18n.t("toast.copySuccess").toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -461,7 +461,9 @@
|
|||
"ruleSaved": "Rule saved!",
|
||||
"renameFileFailed": "Unable to rename file",
|
||||
"renameFolderFailed": "Unable to rename file",
|
||||
"copySuccess": "Text copied!",
|
||||
"copyNotSupported": "Unable to copy, clipboard API unavailable on this browser",
|
||||
"pasteSuccess": "Text pasted!",
|
||||
"pasteNotSupported": "Unable to paste, clipboard API unavailable on this browser"
|
||||
},
|
||||
"rightClick": {
|
||||
|
|
|
@ -450,8 +450,10 @@
|
|||
"ruleSaved": "Règle enregistrée !",
|
||||
"renameFileFailed": "Impossible de renommer le fichier",
|
||||
"renameFolderFailed": "Impossible de renommer le dossier",
|
||||
"copyNotSupported": "Impossible de copier, clipboard API indisponible dans ce navigateur",
|
||||
"pasteNotSupported": "Impossible de coller, clipboard API indisponible dans ce navigateur"
|
||||
"copySuccess": "Texte copié!",
|
||||
"copyNotSupported": "Impossible de copier, Clipboard API indisponible dans ce navigateur",
|
||||
"pasteSuccess": "Texte collé!",
|
||||
"pasteNotSupported": "Impossible de coller, Clipboard API indisponible dans ce navigateur"
|
||||
},
|
||||
"rightClick": {
|
||||
"resume": "Reprendre",
|
||||
|
|
Loading…
Reference in a new issue