next-element-vue 0.3.5 → 0.3.6

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/dist/index.umd.js CHANGED
@@ -2,8 +2,8 @@
2
2
  /**
3
3
  * 作  者:huangteng
4
4
  * 邮  箱:htengweb@163.com
5
- * 当前版本:0.3.5 v
6
- * 发布日期:2024-09-03
5
+ * 当前版本:0.3.6 v
6
+ * 发布日期:2024-09-15
7
7
  * 地  址:https://www.npmjs.com/package/next-element-vue
8
8
  */
9
9
 
@@ -797,7 +797,8 @@
797
797
  confirmDeleteLabel: "确定要删除该标注吗?",
798
798
  saveLabel: "保存当前标注",
799
799
  instructions: "使用说明",
800
- labelNoUpdate: "暂无标签数据更新"
800
+ labelNoUpdate: "暂无标签数据更新",
801
+ zoomRestore: "还原"
801
802
  },
802
803
  labelme: {
803
804
  saveLabel: "保存",
@@ -881,7 +882,8 @@
881
882
  confirmDeleteLabel: "Are you sure you want to delete this annotation?",
882
883
  saveLabel: "save label",
883
884
  instructions: "instructions",
884
- labelNoUpdate: "No label data update"
885
+ labelNoUpdate: "No label data update",
886
+ zoomRestore: "restore zoom"
885
887
  },
886
888
  labelme: {
887
889
  saveLabel: "saving...",
@@ -965,7 +967,8 @@
965
967
  confirmDeleteLabel: "确定要删除该标注吗?",
966
968
  saveLabel: "保存当前标注",
967
969
  instructions: "使用说明",
968
- labelNoUpdate: "暂无标签数据更新"
970
+ labelNoUpdate: "暂无标签数据更新",
971
+ zoomRestore: "还原"
969
972
  },
970
973
  labelme: {
971
974
  saveLabel: "保存"
@@ -5779,7 +5782,7 @@
5779
5782
  emits: [ "fullscreen", "save" ],
5780
5783
  setup(props, {emit: emit}) {
5781
5784
  const _ns = vue.inject("ns", {}), {t: t} = useLocale(), switchFillscreen = val => {
5782
- emit("fullscreen", val);
5785
+ emit("fullscreen", val), document.body.style.overflow = val ? "hidden" : "auto";
5783
5786
  };
5784
5787
  return () => vue.createVNode(vue.Fragment, null, [ vue.createVNode(vue.Fragment, null, [ vue.createVNode("ul", {
5785
5788
  class: [ _ns.be("header", "tool") ]
@@ -6158,7 +6161,7 @@
6158
6161
  },
6159
6162
  emits: [ "change" ],
6160
6163
  setup(props, {emit: emit, expose: expose}) {
6161
- const ns = vue.inject("ns", {}), _emit = vue.inject("_emit", null), canvasMainRef = vue.ref(), canvasBaseRef = vue.ref(), canvasRectRef = vue.ref(), labels = vue.ref([]), drawBaseCanvas = vue.ref({}), formatLabelsType = () => {
6164
+ const ns = vue.inject("ns", {}), _emit = vue.inject("_emit", null), mainBasaeRef = vue.ref(), canvasMainRef = vue.ref(), canvasBaseRef = vue.ref(), canvasRectRef = vue.ref(), labels = vue.ref([]), drawBaseCanvas = vue.ref({}), formatLabelsType = () => {
6162
6165
  const _labels = deepClone(labels.value);
6163
6166
  let yolo_label = [];
6164
6167
  return {
@@ -6176,22 +6179,39 @@
6176
6179
  canvasRectRef.value.width = canvasWidth, canvasRectRef.value.height = canvasHeight,
6177
6180
  canvasRectRef.value.style.width = canvasWidth + "px", canvasRectRef.value.style.height = canvasHeight + "px";
6178
6181
  }, loadingImage = vue.ref(!1), renderImageLabel = rowInfo => {
6179
- labels.value = (rowInfo => rowInfo.labels ? rowInfo.labels.map((rect => {
6180
- const typeName = props.classes[rect.type];
6181
- return typeName && (rect.typeName = typeName), rect;
6182
- })) : [])(rowInfo);
6183
- const clientHeight = canvasMainRef.value?.clientHeight, ctx = canvasBaseRef.value?.getContext("2d");
6182
+ const ctx = canvasBaseRef.value?.getContext("2d");
6184
6183
  if (rowInfo?.imageSrc) {
6185
6184
  const image = new Image;
6186
6185
  image.src = rowInfo.imageSrc, loadingImage.value = !0, image.onload = () => {
6187
6186
  loadingImage.value = !1;
6188
- let {width: width, height: height} = image;
6189
- if (height > clientHeight) {
6190
- const scale = height / clientHeight;
6191
- height = clientHeight, image.style.height = height + "px", width /= scale;
6192
- }
6193
- const canvasHeight = height, scaleFactor = parseFloat((canvasHeight / height).toFixed(3)), canvasWidth = Math.ceil(width * scaleFactor);
6194
- setContainerWidthHeight(canvasWidth, canvasHeight), labels.value = ((labels, canvasHeight) => {
6187
+ const {canvasWidth: canvasWidth, canvasHeight: canvasHeight, scaleFactor: scaleFactor, originWidth: originWidth, originHeight: originHeight} = (image => {
6188
+ const clientWidth = mainBasaeRef.value?.elementInstance.clientWidth, clientHeight = mainBasaeRef.value?.elementInstance.clientHeight;
6189
+ let {width: width, height: height} = image, scaleFactor = 1;
6190
+ const scale = width / height;
6191
+ if (scale > 1 ? (width = clientWidth, height = clientWidth / scale) : (width = clientHeight * scale,
6192
+ height = clientHeight), height > clientHeight) {
6193
+ const scale = height / clientHeight;
6194
+ height = clientHeight, width /= scale;
6195
+ } else if (width > clientWidth) {
6196
+ const scale = width / clientWidth;
6197
+ width = clientWidth, height /= scale;
6198
+ }
6199
+ const canvasWidth = parseInt(width.toString()), canvasHeight = parseInt(height.toString());
6200
+ return scaleFactor = Number((canvasWidth / canvasHeight).toFixed(2)), {
6201
+ canvasWidth: canvasWidth,
6202
+ canvasHeight: canvasHeight,
6203
+ scaleFactor: scaleFactor,
6204
+ originWidth: image.width,
6205
+ originHeight: image.height
6206
+ };
6207
+ })(image);
6208
+ labels.value = ((rowInfo, originWidth, originHeight) => rowInfo.labels ? rowInfo.labels.map((rect => {
6209
+ const typeName = props.classes[rect.type];
6210
+ return typeName && (rect.typeName = typeName), rect.originWidth || (rect.originWidth = originWidth),
6211
+ rect.originHeight || (rect.originHeight = originHeight), rect;
6212
+ })) : [])(rowInfo, originWidth, originHeight), image.style.width = canvasWidth + "px",
6213
+ image.style.height = canvasHeight + "px", setContainerWidthHeight(canvasWidth, canvasHeight),
6214
+ labels.value = ((labels, canvasHeight) => {
6195
6215
  let scale_rects = [];
6196
6216
  for (let i = 0; i < labels.length; i++) {
6197
6217
  const rect = labels[i], scale = parseFloat((canvasHeight / rect.canvasHeight).toFixed(3));
@@ -6203,8 +6223,10 @@
6203
6223
  return scale_rects;
6204
6224
  })(labels.value, canvasHeight);
6205
6225
  const {updateLabels: updateLabels, addDrawRect: addDrawRect, hitCanvasLabel: hitCanvasLabel} = (options => {
6206
- const {ctx: ctx, labels: labels, image: image, canvasWidth: canvasWidth, canvasHeight: canvasHeight} = options, updateLabels = () => {
6207
- ctx.clearRect(0, 0, canvasWidth, canvasHeight), ctx.drawImage(image, 0, 0, canvasWidth, canvasHeight);
6226
+ const {canvas: canvas, ctx: ctx, labels: labels, image: image, canvasWidth: canvasWidth, canvasHeight: canvasHeight} = options, updateLabels = scaleOffset => {
6227
+ scaleOffset && (canvas.width = canvasWidth, ctx.save(), ctx.translate(scaleOffset.x, scaleOffset.y),
6228
+ ctx.scale(scaleOffset.scale, scaleOffset.scale)), ctx.clearRect(0, 0, canvasWidth, canvasHeight),
6229
+ ctx.drawImage(image, 0, 0, canvasWidth, canvasHeight);
6208
6230
  for (let i = 0; i < labels.length; i++) {
6209
6231
  const rect = labels[i], {startX: startX, startY: startY, rectWidth: rectWidth, rectHeight: rectHeight, type: type} = rect, color = colors$1[type % colors$1.length];
6210
6232
  if (ctx.font = "bold 14px serif", ctx.textBaseline = "top", ctx.save(), ctx.strokeStyle = color,
@@ -6219,7 +6241,8 @@
6219
6241
  updateLabels: updateLabels,
6220
6242
  addDrawRect: (rect, color = "#f30635") => {
6221
6243
  const {startX: startX, startY: startY, rectWidth: rectWidth, rectHeight: rectHeight} = rect;
6222
- ctx.strokeStyle = color, ctx.strokeRect(startX, startY, rectWidth, rectHeight);
6244
+ ctx.save(), ctx.strokeStyle = color, ctx.strokeRect(startX, startY, rectWidth, rectHeight),
6245
+ ctx.restore();
6223
6246
  },
6224
6247
  hitCanvasLabel: (x, y) => {
6225
6248
  let hit_rect = null, hit_index = null, color = null;
@@ -6246,7 +6269,7 @@
6246
6269
  });
6247
6270
  drawBaseCanvas.value.updateLabels = updateLabels, drawBaseCanvas.value.addDrawRect = addDrawRect,
6248
6271
  drawBaseCanvas.value.hitCanvasLabel = hitCanvasLabel;
6249
- const {clearCanvas: clearCanvas, removeEventAll: removeEventAll} = ((canvas, callback, keyW) => {
6272
+ const {clearCanvas: clearCanvas, removeEventAll: removeEventAll} = (({canvas: canvas, originWidth: originWidth, originHeight: originHeight}, callback, keyW) => {
6250
6273
  const canvasWidth = canvas.width, canvasHeight = canvas.height, ctx = canvas?.getContext("2d"), clearCanvas = () => {
6251
6274
  ctx.clearRect(0, 0, canvasWidth, canvasHeight);
6252
6275
  };
@@ -6260,14 +6283,16 @@
6260
6283
  rectWidth: rectWidth,
6261
6284
  rectHeight: rectHeight,
6262
6285
  canvasWidth: canvasWidth,
6263
- canvasHeight: canvasHeight
6286
+ canvasHeight: canvasHeight,
6287
+ originWidth: originWidth,
6288
+ originHeight: originHeight
6264
6289
  }, {
6265
6290
  endX: endX,
6266
6291
  endY: endY
6267
6292
  });
6268
6293
  }, documentKeydown = event => {
6269
- "KeyW" === event.code && (isWKeyPressed = !0, canvas.style.cursor = "crosshair",
6270
- canvas.style.zIndex = "11", keyW && keyW());
6294
+ isWKeyPressed || "KeyW" === event.code && (event.preventDefault(), isWKeyPressed = !0,
6295
+ canvas.style.cursor = "crosshair", canvas.style.zIndex = "11", keyW && keyW());
6271
6296
  }, documentKeyup = event => {
6272
6297
  isDrawing || "KeyW" === event.code && (isWKeyPressed = !1, canvas.style.cursor = "unset",
6273
6298
  canvas.style.zIndex = "0");
@@ -6277,13 +6302,13 @@
6277
6302
  };
6278
6303
  document.addEventListener("keydown", documentKeydown), document.addEventListener("keyup", documentKeyup),
6279
6304
  document.addEventListener("mouseup", documentMouseup);
6280
- const canvasMousedown = e => {
6281
- isWKeyPressed && (isDrawing = !0, startX = e.offsetX, startY = e.offsetY);
6282
- }, canvasMousemove = e => {
6283
- isDrawing && isWKeyPressed && (isRectDraw = !0, endX = e.offsetX, endY = e.offsetY,
6305
+ const canvasMousedown = event => {
6306
+ isWKeyPressed && (isDrawing = !0, startX = event.offsetX, startY = event.offsetY);
6307
+ }, canvasMousemove = event => {
6308
+ isDrawing && isWKeyPressed && (isRectDraw = !0, endX = event.offsetX, endY = event.offsetY,
6284
6309
  drawRect());
6285
- }, canvasMouseup = e => {
6286
- e.stopPropagation(), isRectDraw && (isDrawing = !1, isWKeyPressed = !1, canvas.style.cursor = "unset",
6310
+ }, canvasMouseup = event => {
6311
+ event.stopPropagation(), isRectDraw && (isDrawing = !1, isWKeyPressed = !1, canvas.style.cursor = "unset",
6287
6312
  canvas.style.zIndex = "0", drawRectDone(), isRectDraw = !1);
6288
6313
  };
6289
6314
  canvas.addEventListener("mousedown", canvasMousedown), canvas.addEventListener("mousemove", canvasMousemove),
@@ -6297,12 +6322,16 @@
6297
6322
  clearCanvas: clearCanvas,
6298
6323
  drawRect: drawRect,
6299
6324
  removeEventAll: () => {
6300
- document.removeEventListener("mousedown", documentKeydown), document.removeEventListener("keyup", documentKeyup),
6325
+ document.removeEventListener("keydown", documentKeydown), document.removeEventListener("keyup", documentKeyup),
6301
6326
  document.removeEventListener("mouseup", documentMouseup), canvas.removeEventListener("mousedown", canvasMousedown),
6302
6327
  canvas.removeEventListener("mousemove", canvasMousemove), canvas.removeEventListener("mouseup", canvasMouseup);
6303
6328
  }
6304
6329
  };
6305
- })(canvasRectRef.value, ((rect, {endX: endX, endY: endY}) => {
6330
+ })({
6331
+ canvas: canvasRectRef.value,
6332
+ originWidth: originWidth,
6333
+ originHeight: originHeight
6334
+ }, ((rect, {endX: endX, endY: endY}) => {
6306
6335
  activate_add_label.value = rect, drawBaseCanvas.value.addDrawRect(rect), updateContextmenuLabelFixed(endX, endY, rect);
6307
6336
  }), (() => {
6308
6337
  onCloseDraggableRectFixed();
@@ -6319,11 +6348,14 @@
6319
6348
  updateContextmenuLabelFixed(x, y, hit_rect);
6320
6349
  }));
6321
6350
  })), canvasBaseRef.value.addEventListener("click", (e => {
6351
+ if (e.ctrlKey) return;
6322
6352
  const x = e.offsetX, y = e.offsetY, {hit_rect: hit_rect, hit_index: hit_index, color: color} = drawBaseCanvas.value.hitCanvasLabel(x, y);
6323
6353
  onCloseDraggableRectFixed(), onCloseContentmenuLabel(), hit_rect && vue.nextTick((() => {
6324
6354
  updateDraggableRectFixed(x, y, hit_rect, hit_index, color);
6325
6355
  }));
6326
6356
  }));
6357
+ }, onWindowWheel = e => {
6358
+ e.ctrlKey && e.preventDefault();
6327
6359
  };
6328
6360
  vue.onMounted((() => {
6329
6361
  vue.watch((() => props.rowInfo), (info => {
@@ -6332,15 +6364,20 @@
6332
6364
  }), {
6333
6365
  deep: !0,
6334
6366
  immediate: !0
6335
- }), vue.watch((() => props.contextClientHeight), (height => {
6367
+ }), vue.watch((() => props.classes), (() => {
6368
+ const rowInfo = vue.toRaw(props.rowInfo);
6369
+ renderImageLabel(rowInfo);
6370
+ })), vue.watch((() => props.contextClientHeight), (height => {
6336
6371
  if (valueExist(height)) {
6337
6372
  canvasMainRef.value.style.height = height + "px";
6338
6373
  const rowInfo = vue.toRaw(props.rowInfo);
6339
6374
  renderImageLabel(rowInfo);
6340
6375
  }
6341
- }));
6376
+ })), window.addEventListener("wheel", onWindowWheel, {
6377
+ passive: !1
6378
+ });
6342
6379
  })), vue.onUnmounted((() => {
6343
- drawBaseCanvas.value.removeEventAll();
6380
+ drawBaseCanvas.value.removeEventAll?.(), window.removeEventListener("wheel", onWindowWheel);
6344
6381
  }));
6345
6382
  const contextmenuLabelFixed = vue.ref({
6346
6383
  show: !1,
@@ -6384,9 +6421,9 @@
6384
6421
  draggableRectFixed.value.width = 0, draggableRectFixed.value.height = 0, draggableRectFixed.value.activateRect = null,
6385
6422
  draggableRectFixed.value.activateIndex = null, draggableRectFixed.value.color = null;
6386
6423
  }, onDraggleRectResize = rect => {
6387
- draggableRectFixed.value.activateRect = rect, drawBaseCanvas.value.updateLabels();
6424
+ draggableRectFixed.value.activateRect = rect;
6388
6425
  const i = labels.value.findIndex((o => isEqual(o, rect)));
6389
- i > -1 && labels.value.splice(i, 1, rect);
6426
+ i > -1 && labels.value.splice(i, 1, rect), drawBaseCanvas.value.updateLabels();
6390
6427
  const {rects: rects, label_txt: label_txt} = formatLabelsType();
6391
6428
  _emit("change", rects, label_txt), emit("change", rects, label_txt);
6392
6429
  }, onContextmenuDraggable = (e, rect) => {
@@ -6430,6 +6467,7 @@
6430
6467
  }
6431
6468
  });
6432
6469
  return () => vue.createVNode(vue.Fragment, null, [ vue.createVNode(NextSpinLoading, {
6470
+ ref: mainBasaeRef,
6433
6471
  loading: loadingImage.value,
6434
6472
  class: [ ns.b("loading") ]
6435
6473
  }, {
@@ -6474,13 +6512,15 @@
6474
6512
  },
6475
6513
  emits: [ "delete", "select" ],
6476
6514
  setup(props, {emit: emit}) {
6477
- const {t: t} = useLocale(), ns = vue.inject("ns", {}), labels = vue.ref([]);
6478
- vue.watch((() => props.labels), (rects => {
6515
+ const {t: t} = useLocale(), ns = vue.inject("ns", {}), labels = vue.ref([]), formatLabelsTypeName = labels => labels.length ? labels.map((rect => {
6516
+ const typeName = props.classes[rect.type];
6517
+ return typeName && (rect.typeName = typeName), rect;
6518
+ })) : [];
6519
+ vue.watch((() => props.classes), (() => {
6520
+ labels.value = formatLabelsTypeName(labels.value);
6521
+ })), vue.watch((() => props.labels), (rects => {
6479
6522
  const _rects = vue.toRaw(rects);
6480
- labels.value = (labels => labels.length ? labels.map((rect => {
6481
- const typeName = props.classes[rect.type];
6482
- return typeName && (rect.typeName = typeName), rect;
6483
- })) : [])(_rects);
6523
+ labels.value = formatLabelsTypeName(_rects);
6484
6524
  }), {
6485
6525
  deep: !0,
6486
6526
  immediate: !0
@@ -7042,15 +7082,17 @@
7042
7082
  canvasWidth;
7043
7083
  canvasHeight;
7044
7084
  paths;
7085
+ scaleX;
7086
+ scaleY;
7045
7087
  editDrawPolygon;
7046
7088
  createPolygonVertexes;
7047
7089
  editVertexes;
7048
7090
  editPolygonObservers=[];
7049
7091
  constructor(options) {
7050
- const {canvas: canvas, ctx: ctx, image: image, canvasWidth: canvasWidth, canvasHeight: canvasHeight, paths: paths} = options;
7092
+ const {canvas: canvas, ctx: ctx, image: image, canvasWidth: canvasWidth, canvasHeight: canvasHeight, paths: paths, scaleX: scaleX, scaleY: scaleY} = options;
7051
7093
  this.canvas = canvas, this.ctx = ctx, this.image = image, this.canvasWidth = canvasWidth,
7052
- this.canvasHeight = canvasHeight, this.paths = paths || [], this.editVertexes = [],
7053
- this.render(), this.createPolygonVertexes = new CreatePolygonVertexes(canvas, ctx),
7094
+ this.canvasHeight = canvasHeight, this.paths = paths || [], this.scaleX = scaleX || 1,
7095
+ this.scaleY = scaleY || 1, this.editVertexes = [], this.render(), this.createPolygonVertexes = new CreatePolygonVertexes(canvas, ctx),
7054
7096
  this.editDrawPolygon = new EditPolygonPath(canvas, ctx), this.createPolygonVertexes.vertexesChangeEventListener(((vertexes, mouseOffset) => {
7055
7097
  this.render(), this.editDrawPolygon.drawPolygon(vertexes, mouseOffset), this.editVertexes = vertexes,
7056
7098
  this.notifyObservers();
@@ -7071,12 +7113,14 @@
7071
7113
  }
7072
7114
  drawPolygons(paths) {
7073
7115
  const ctx = this.ctx;
7116
+ ctx.scale(this.scaleX, this.scaleY);
7074
7117
  for (let i = 0; i < paths.length; i++) {
7075
7118
  const path = paths[i].path;
7076
7119
  if (!path.length) return;
7077
7120
  const color = colors[i % colors.length];
7078
- ctx.beginPath(), ctx.lineWidth = 2, ctx.strokeStyle = color, ctx.fillStyle = hexToRgba(color, .2),
7079
- ctx.moveTo(path[0][0], path[0][1]);
7121
+ ctx.beginPath(), ctx.lineWidth = 2, ctx.strokeStyle = color, ctx.fillStyle = hexToRgba(color, .2);
7122
+ const startX = path[0][0], startY = path[0][1];
7123
+ ctx.moveTo(startX, startY);
7080
7124
  for (let i = 1; i < path.length; i++) {
7081
7125
  const [x, y] = path[i];
7082
7126
  ctx.lineTo(x, y);
@@ -7086,7 +7130,7 @@
7086
7130
  }
7087
7131
  initCanvas=() => {
7088
7132
  this.ctx.clearRect(0, 0, this.canvasWidth, this.canvasHeight), this.ctx.drawImage(this.image, 0, 0, this.canvasWidth, this.canvasHeight),
7089
- this.drawPolygons(this.paths);
7133
+ this.ctx.save(), this.drawPolygons(this.paths), this.ctx.restore();
7090
7134
  };
7091
7135
  render=() => {
7092
7136
  this.initCanvas();
@@ -7112,22 +7156,40 @@
7112
7156
  },
7113
7157
  emits: [ "editPolygon" ],
7114
7158
  setup(props, {emit: emit, expose: expose}) {
7115
- const ns = vue.inject("ns", {}), canvasMainRef = vue.ref(), canvasBaseRef = vue.ref(), drawCanvas = vue.ref(), setContainerWidthHeight = (canvasWidth, canvasHeight) => {
7159
+ const ns = vue.inject("ns", {}), mainBasaeRef = vue.ref(), canvasMainRef = vue.ref(), canvasBaseRef = vue.ref(), drawCanvas = vue.ref(), setContainerWidthHeight = (canvasWidth, canvasHeight) => {
7116
7160
  canvasMainRef.value.style.width = canvasWidth + "px", canvasMainRef.value.style.height = canvasHeight + "px",
7117
7161
  canvasBaseRef.value.width = canvasWidth, canvasBaseRef.value.height = canvasHeight,
7118
7162
  canvasBaseRef.value.style.width = canvasWidth + "px", canvasBaseRef.value.style.height = canvasHeight + "px";
7119
7163
  }, loadingImage = vue.ref(!1), renderImageLabel = rowInfo => {
7120
- const clientHeight = canvasMainRef.value?.clientHeight, ctx = canvasBaseRef.value?.getContext("2d");
7164
+ const ctx = canvasBaseRef.value?.getContext("2d");
7121
7165
  if (rowInfo?.imageSrc) {
7122
7166
  const image = new Image;
7123
7167
  image.src = rowInfo.imageSrc, loadingImage.value = !0, image.onload = () => {
7124
7168
  loadingImage.value = !1;
7125
- let {width: width, height: height} = image;
7126
- if (height > clientHeight) {
7127
- const scale = height / clientHeight;
7128
- height = clientHeight, image.style.height = height + "px", width /= scale;
7129
- }
7130
- const canvasHeight = height, scaleFactor = parseFloat((canvasHeight / height).toFixed(3)), canvasWidth = Math.ceil(width * scaleFactor);
7169
+ const {canvasWidth: canvasWidth, canvasHeight: canvasHeight, scaleFactor: scaleFactor, scaleX: scaleX, scaleY: scaleY} = (image => {
7170
+ const clientWidth = mainBasaeRef.value?.elementInstance.clientWidth, clientHeight = mainBasaeRef.value?.elementInstance.clientHeight;
7171
+ let {width: width, height: height} = image, scaleFactor = 1;
7172
+ const aspect_ratio = width / height;
7173
+ if (aspect_ratio > 1 ? (width = clientWidth, height = clientWidth / aspect_ratio) : (width = clientHeight * aspect_ratio,
7174
+ height = clientHeight), height > clientHeight) {
7175
+ const scale = height / clientHeight;
7176
+ height = clientHeight, width /= scale;
7177
+ } else if (width > clientWidth) {
7178
+ const scale = width / clientWidth;
7179
+ width = clientWidth, height /= scale;
7180
+ }
7181
+ const canvasWidth = parseInt(width.toString()), canvasHeight = parseInt(height.toString());
7182
+ scaleFactor = Number((canvasWidth / canvasHeight).toFixed(2));
7183
+ const scaleX = (canvasWidth / image.width).toFixed(8), scaleY = (canvasHeight / image.height).toFixed(8);
7184
+ return {
7185
+ canvasWidth: canvasWidth,
7186
+ canvasHeight: canvasHeight,
7187
+ scaleFactor: scaleFactor,
7188
+ scaleX: Number(scaleX),
7189
+ scaleY: Number(scaleY)
7190
+ };
7191
+ })(image);
7192
+ image.style.width = canvasWidth + "px", image.style.height = canvasHeight + "px",
7131
7193
  setContainerWidthHeight(canvasWidth, canvasHeight), drawCanvas.value = new CreateDrawCanvas({
7132
7194
  canvas: canvasBaseRef.value,
7133
7195
  ctx: ctx,
@@ -7135,7 +7197,9 @@
7135
7197
  canvasWidth: canvasWidth,
7136
7198
  canvasHeight: canvasHeight,
7137
7199
  scaleFactor: scaleFactor,
7138
- paths: rowInfo.labels
7200
+ paths: rowInfo.labels,
7201
+ scaleX: scaleX,
7202
+ scaleY: scaleY
7139
7203
  }), drawCanvas.value.updatePolygon((vertexes => {
7140
7204
  emit("editPolygon", {
7141
7205
  vertexes: vertexes,
@@ -7171,6 +7235,7 @@
7171
7235
  }));
7172
7236
  }
7173
7237
  }), () => vue.createVNode(vue.Fragment, null, [ vue.createVNode(NextSpinLoading, {
7238
+ ref: mainBasaeRef,
7174
7239
  loading: loadingImage.value,
7175
7240
  class: [ ns.b("loading") ],
7176
7241
  style: {
@@ -7204,7 +7269,7 @@
7204
7269
  emits: [ "fullscreen", "save" ],
7205
7270
  setup(props, {emit: emit}) {
7206
7271
  const _ns = vue.inject("ns", {}), {t: t} = useLocale(), switchFillscreen = val => {
7207
- emit("fullscreen", val);
7272
+ emit("fullscreen", val), document.body.style.overflow = val ? "hidden" : "auto";
7208
7273
  };
7209
7274
  return () => vue.createVNode(vue.Fragment, null, [ vue.createVNode(vue.Fragment, null, [ vue.createVNode("ul", {
7210
7275
  class: [ _ns.be("header", "tool") ]
@@ -7424,20 +7489,25 @@
7424
7489
  if (loading.value) return;
7425
7490
  loading.value = !0;
7426
7491
  const node = currentNode.value;
7427
- emit("save", {
7492
+ return emit("save", {
7428
7493
  node: node
7429
7494
  }, (imageItem => {
7430
7495
  labelImages.value[activateNodeIndex.value] = imageItem || node, activateNodeIndex.value = index,
7431
7496
  loading.value = !1;
7432
7497
  }), (() => {
7433
7498
  loading.value = !1;
7434
- }));
7499
+ })), !0;
7435
7500
  }, isFullscreen = vue.ref(!1), onSwitchFillscreen = val => {
7436
7501
  isFullscreen.value = val, updateMainContentHeight(), vue.nextTick((() => {
7437
7502
  canvasContextRef.value.rerenderImage();
7438
7503
  }));
7439
7504
  }, onEditPlygonChange = plygon => {
7440
- emit("edit-polygon", plygon);
7505
+ currentNode.value.labels = plygon, emit("edit-polygon", plygon);
7506
+ }, onToolHeaderSave = () => {
7507
+ onChangeActivateNode(activateNodeIndex.value) || elementPlus.ElMessage({
7508
+ type: "info",
7509
+ message: t("next.labelimg.labelNoUpdate")
7510
+ });
7441
7511
  };
7442
7512
  return () => vue.createVNode(vue.Fragment, null, [ vue.createVNode("div", {
7443
7513
  ref: layoutLabelRef,
@@ -7458,7 +7528,8 @@
7458
7528
  isFullscreen: isFullscreen.value,
7459
7529
  imageIndex: activateNodeIndex.value,
7460
7530
  imageLength: labelImages.value.length,
7461
- onFullscreen: onSwitchFillscreen
7531
+ onFullscreen: onSwitchFillscreen,
7532
+ onSave: onToolHeaderSave
7462
7533
  }, null) ]), vue.createVNode("div", {
7463
7534
  ref: mainRef,
7464
7535
  class: [ ns.b("main") ]
@@ -7576,7 +7647,7 @@
7576
7647
  })(app);
7577
7648
  };
7578
7649
  var index = {
7579
- version: "0.3.5",
7650
+ version: "0.3.6",
7580
7651
  install: install
7581
7652
  };
7582
7653
  exports.NextContainer = NextContainer, exports.NextCrudTable = NextCrudTable, exports.NextCrudTableVirtualized = NextCrudTableVirtualized,
@@ -7623,7 +7694,7 @@
7623
7694
  }), exports.useGetDerivedNamespace = useGetDerivedNamespace, exports.useLanguage = (locale, lang) => {
7624
7695
  const localeRef = vue.isRef(locale) ? locale : vue.ref(locale), nextLang = localeLang[lang] || localeLang["zh-cn"];
7625
7696
  localeRef.value.name = lang, localeRef.value.next = nextLang.next;
7626
- }, exports.useLocale = useLocale, exports.useNamespace = useNamespace, exports.version = "0.3.5",
7697
+ }, exports.useLocale = useLocale, exports.useNamespace = useNamespace, exports.version = "0.3.6",
7627
7698
  Object.defineProperty(exports, "__esModule", {
7628
7699
  value: !0
7629
7700
  });