stellar-ui-v2 1.40.19 → 1.40.20

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.
@@ -1,11 +1,16 @@
1
- async function getImage(src) {
1
+ async function getImagePath(src) {
2
+ if (!src) {
3
+ throw new Error('图片路径不能为空');
4
+ return;
5
+ }
6
+ if (/^data\:image\/[a-zA-Z]+\;base64\,/.test(src)) return src;
2
7
  const image = await uni.getImageInfo({ src: src });
3
8
  if (Array.isArray(image)) {
4
9
  const [e, img] = image;
5
10
  if (e) throw e;
6
- return img;
11
+ return img.path;
7
12
  } else if (image.path) {
8
- return image;
13
+ return image.path;
9
14
  }
10
15
  throw new Error('获取图片失败');
11
16
  }
@@ -33,8 +38,8 @@ export function drawPoster(ctx, poster, data) {
33
38
  // 绘制宽高一致的图片
34
39
  if (data.image) {
35
40
  try {
36
- const image = await getImage(data.image);
37
- ctx.drawImage(image.path, 0, 40, width, width);
41
+ const path = await getImagePath(data.image);
42
+ ctx.drawImage(path, 0, 40, width, width);
38
43
  } catch (e) {
39
44
  console.error(e);
40
45
  }
@@ -71,8 +76,8 @@ export function drawPoster(ctx, poster, data) {
71
76
  // 绘制qrcode
72
77
  if (poster.qrcode) {
73
78
  try {
74
- const qrcode = await getImage(poster.qrcode);
75
- ctx.drawImage(qrcode.path, width - 80, width + 80, 70, 70);
79
+ const path = await getImagePath(poster.qrcode);
80
+ ctx.drawImage(path, width - 80, width + 80, 70, 70);
76
81
  } catch (e) {
77
82
  console.error(e);
78
83
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stellar-ui-v2",
3
- "version": "1.40.19",
3
+ "version": "1.40.20",
4
4
  "description": "StellarUI组件库",
5
5
  "main": "stellar-ui/index.js",
6
6
  "private": false,