|
@@ -262,27 +262,32 @@ export default {
|
|
|
img.crossOrigin = "Anonymous";
|
|
|
img.src = svgToBase64(dataUri);
|
|
|
img.onload = ()=>{
|
|
|
- canvas.width = img.width;
|
|
|
- canvas.height = img.height;
|
|
|
- console.log('width',img.width)
|
|
|
- console.log('height',img.height)
|
|
|
- ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
|
|
|
- ctx.fillStyle="#fff";
|
|
|
- ctx.fillRect(0, 0, img.width, img.height);
|
|
|
- ctx.drawImage(img, 0, 0);
|
|
|
- canvas.toBlob(async (blob) => {
|
|
|
- const data = [new ClipboardItem({ [blob.type]: blob })];
|
|
|
- await navigator.clipboard.write(data).then(
|
|
|
- () => {
|
|
|
- this.$message.success('复制成功!')
|
|
|
- },
|
|
|
- () => {
|
|
|
- this.$message.success('复制失败,稍后再试')
|
|
|
- }
|
|
|
- ).finally(()=>{
|
|
|
- this.lockLoding && this.lockLoding.close();
|
|
|
- });
|
|
|
- });
|
|
|
+ canvas.width = img.width;
|
|
|
+ canvas.height = img.height;
|
|
|
+ console.log('width',img.width)
|
|
|
+ console.log('height',img.height)
|
|
|
+ ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
|
|
|
+ ctx.fillStyle="#fff";
|
|
|
+ ctx.fillRect(0, 0, img.width, img.height);
|
|
|
+ ctx.drawImage(img, 0, 0);
|
|
|
+ if(window.ClipboardItem) {
|
|
|
+ canvas.toBlob(async (blob) => {
|
|
|
+ const data = [new ClipboardItem({ [blob.type]: blob })];
|
|
|
+ await navigator.clipboard.write(data).then(
|
|
|
+ () => {
|
|
|
+ this.$message.success('复制成功!')
|
|
|
+ },
|
|
|
+ () => {
|
|
|
+ this.$message.success('复制失败,稍后再试')
|
|
|
+ }
|
|
|
+ ).finally(()=>{
|
|
|
+ this.lockLoding && this.lockLoding.close();
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }else {
|
|
|
+ this.lockLoding && this.lockLoding.close();
|
|
|
+ this.$message.success('浏览器暂不支持')
|
|
|
+ }
|
|
|
}
|
|
|
},{
|
|
|
preserveDimensions:true,//让svg为实际图片大小
|