zydx-plus 1.35.471 → 1.35.472

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zydx-plus",
3
- "version": "1.35.471",
3
+ "version": "1.35.472",
4
4
  "description": "Vue.js",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -49,7 +49,8 @@
49
49
  "react": "^18.2.0",
50
50
  "react-dom": "^18.2.0",
51
51
  "tldraw": "^2.0.2",
52
- "@tldraw/editor": "^2.0.2"
52
+ "@tldraw/editor": "^2.0.2",
53
+ "buffer": "^5.7.1"
53
54
  },
54
55
  "peerDependencies": {
55
56
  "vue": "^3.2.13"
@@ -8,6 +8,11 @@ import {createElement} from 'react'
8
8
  import {createRoot} from 'react-dom/client'
9
9
  import {AssetRecordType,createShapeId, Tldraw, FileHelpers} from 'tldraw'
10
10
  import 'tldraw/tldraw.css'
11
+ import * as buffer from "buffer"; //引入buffer
12
+
13
+ if (typeof window.Buffer === "undefined") { // 判断当前环境是否有Buffer对象
14
+ window.Buffer = buffer.Buffer; // Buffer对象不存在则创建导入的buffer
15
+ }
11
16
 
12
17
  const clearJson = {
13
18
  store: {
@@ -102,27 +107,27 @@ export default {
102
107
  }, null))
103
108
  },
104
109
  methods: {
105
- exportImg() {
106
- return new Promise((rl,ri) => {
107
- editorAPP.getSvg([...editorAPP.getCurrentPageShapeIds()],{}).then(r => {
108
- const s = new XMLSerializer().serializeToString(r);
109
- const src = `data:image/svg+xml;base64,${window.btoa(s)}`;
110
- const img = new Image(); // 创建图片容器承载过渡
111
- img.src = src;
112
- img.onload = () => {
113
- // ↓ 第二部分
114
- const canvas = document.createElement('canvas');
115
- canvas.width = img.width;
116
- canvas.height = img.height;
117
- const context = canvas.getContext('2d');
118
- context.drawImage(img, 0, 0);
119
- const ImgBase64 = canvas.toDataURL('image/png');
120
- let blob = this.dataURLtoBlob(ImgBase64);
121
- let file = new File([blob], `${new Date().getTime()}.png`, {lastModified: Date.now()});
122
- rl(file)
123
- }
124
- })
125
- })
110
+ exportImg() {
111
+ return new Promise((rl,ri) => {
112
+ editorAPP.getSvg([...editorAPP.getCurrentPageShapeIds()],{}).then(r => {
113
+ const s = new XMLSerializer().serializeToString(r);
114
+ const src = `data:image/svg+xml;base64,${Buffer.from(s).toString('base64')}`;
115
+ const img = new Image(); // 创建图片容器承载过渡
116
+ img.src = src;
117
+ img.onload = () => {
118
+ // ↓ 第二部分
119
+ const canvas = document.createElement('canvas');
120
+ canvas.width = img.width;
121
+ canvas.height = img.height;
122
+ const context = canvas.getContext('2d');
123
+ context.drawImage(img, 0, 0);
124
+ const ImgBase64 = canvas.toDataURL('image/png');
125
+ let blob = this.dataURLtoBlob(ImgBase64);
126
+ let file = new File([blob], `${new Date().getTime()}.png`, {lastModified: Date.now()});
127
+ rl(file)
128
+ }
129
+ })
130
+ })
126
131
  },
127
132
  dataURLtoBlob(dataurl) {
128
133
  let arr = dataurl.split(',');
@@ -390,7 +395,6 @@ export default {
390
395
  },
391
396
  styleProps(t, e) {
392
397
  const style = [...editorAPP.styleProps[t]]
393
- console.log(style)
394
398
  const index = style.findIndex(item => item[1] === e)
395
399
  return style[index][0]
396
400
  },
package/src/index.js CHANGED
@@ -87,7 +87,7 @@ function install(app) {
87
87
  }
88
88
 
89
89
  export default {
90
- version: '1.35.471',
90
+ version: '1.35.472',
91
91
  install,
92
92
  Calendar,
93
93
  Message,