mirror of
https://github.com/VueTorrent/VueTorrent.git
synced 2025-02-18 00:02:02 +03:00
fix: copy to clipboard on non secure context (no SSL) #521
This commit is contained in:
parent
5c5d8506ec
commit
058766f617
1 changed files with 17 additions and 2 deletions
|
@ -397,7 +397,22 @@ export default {
|
||||||
qbit.setAutoTMM(this.hashes, !this.torrent.auto_tmm)
|
qbit.setAutoTMM(this.hashes, !this.torrent.auto_tmm)
|
||||||
},
|
},
|
||||||
copyToClipBoard(text) {
|
copyToClipBoard(text) {
|
||||||
navigator.clipboard.writeText(text)
|
if (navigator.clipboard && window.isSecureContext) {
|
||||||
|
navigator.clipboard.writeText(text)
|
||||||
|
} else {
|
||||||
|
const textArea = document.createElement('textarea')
|
||||||
|
textArea.value = text
|
||||||
|
textArea.style.position = 'fixed'
|
||||||
|
textArea.style.opacity = '0'
|
||||||
|
document.body.appendChild(textArea)
|
||||||
|
textArea.select()
|
||||||
|
try {
|
||||||
|
document.execCommand('copy')
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Unable to copy to clipboard', err)
|
||||||
|
}
|
||||||
|
document.body.removeChild(textArea)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -408,4 +423,4 @@ export default {
|
||||||
font-size: 1em;
|
font-size: 1em;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
Loading…
Add table
Reference in a new issue