Browse Source

修复非安全域复制失败问题

pull/1356/head
地亚尔-IT 1 year ago committed by GitHub
parent
commit
ae8dede13d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      src/modules/code.js

16
src/modules/code.js

@ -112,9 +112,17 @@ layui.define(['lay', 'util', 'element', 'form'], function(exports){
});
});
} catch(e) {
layer.msg('复制失败', {
icon: 2
});
var text = document.createElement("textarea");
text.setAttribute("readonly", "readonly");
text.value = util.unescape(finalCode);
document.body.appendChild(text);
text.select();
if (document.execCommand("copy")){
layer.msg('已复制', {icon: 1});
}else {
layer.msg('复制失败', {icon: 2});
}
document.body.removeChild(text);
}
}();
}
@ -369,4 +377,4 @@ layui.define(['lay', 'util', 'element', 'form'], function(exports){
// 若为源码版,则自动加载该组件依赖的 css 文件
if(!layui['layui.all']){
layui.addcss('modules/code.css?v=3', 'skincodecss');
}
}

Loading…
Cancel
Save