fix:大屏编辑页面复制编码功能优化,不使用Clipboard API

main
hong.yang 1 year ago
parent c91241a3e8
commit 90c39e7b86

@ -3,7 +3,7 @@
"version": "2.0.1-2024010901-Alpha", "version": "2.0.1-2024010901-Alpha",
"description": "自定义大屏", "description": "自定义大屏",
"author": "gcpaas", "author": "gcpaas",
"license": "MIT", "license": "Apache-2.0",
"main": "packages/index.js", "main": "packages/index.js",
"keywords": [ "keywords": [
"dataRoom", "dataRoom",

@ -414,16 +414,22 @@ export default {
* 复制大屏编码 * 复制大屏编码
*/ */
copyCode () { copyCode () {
let code = this.dataForm.code try {
navigator.clipboard let code = this.dataForm.code
.writeText(code) const transfer = document.createElement('input')
.then(() => { document.body.appendChild(transfer)
this.$message.success("复制成功"); transfer.value = code
}) transfer.focus()
.catch(err => { transfer.select()
this.$message.error("复制失败,请手动复制"); if (document.execCommand('copy')) {
console.error(err); document.execCommand('copy')
}) }
transfer.blur()
transfer.style.display = 'none'
this.$message.success('复制成功')
} catch (e) {
this.$message.error('复制失败, 请手动复制')
}
} }
} }
} }

Loading…
Cancel
Save