next-element-vue 0.3.7 → 0.3.8

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.css CHANGED
@@ -13,4 +13,4 @@
13
13
  .next-video-player{border-radius:5px;height:100%;min-height:200px;overflow:hidden;position:relative;width:100%}.next-video-player .vjs-default-skin{height:100%!important;left:0;min-height:200px;padding:unset!important;position:absolute;top:0;width:100%}.next-video-player .screemshot-btn{align-items:center;background-color:rgba(0,0,0,.6);border-radius:50%;cursor:pointer;display:inline-flex;height:45px;justify-content:center;opacity:0;position:absolute;right:10px;top:50%;transform:translateY(-50%);transition:all .5s ease-in-out;width:45px}.next-video-player .screemshot-btn i{transition:all .3s ease-in-out}.next-video-player .screemshot-btn:hover i{transform:scale(1.1)}.next-video-player:hover .screemshot-btn{opacity:1}.next-video-player-recongition{height:100%;left:0;pointer-events:none;position:absolute;top:0;width:100%;z-index:99}
14
14
  .next-drag-resize{position:relative}
15
15
  .next-labelimg-loading .next-spin-loading-mask__text{text-shadow:unset}.next-labelimg{border:1px solid #eee;border-radius:3px;box-sizing:border-box;height:100%;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:100%}.next-labelimg-header{box-shadow:0 0 4px 0 rgba(0,0,0,.15);font-size:12px;justify-content:space-between;padding:10px 12px}.next-labelimg-header,.next-labelimg-header__tool,.next-labelimg-header__tool>li{align-items:center;display:flex}.next-labelimg-header__tool>li{cursor:pointer;margin:0 6px}.next-labelimg-header__tool>li.hover:hover{color:var(--el-color-primary)}.next-labelimg-header__tool>li.hover:hover svg{fill:var(--el-color-primary)}.next-labelimg-main{align-items:center;display:flex;justify-content:space-between}.next-labelimg-main__content.el-scrollbar{background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAADZJREFUOE9jZKAQMFKon2HUAAYah8HZs2f/MzAw3DY2NlbDFVt4Y4FiA4hJI6PpgNbpgJhYAAB1/AoRxXg31wAAAABJRU5ErkJggg==)}.next-labelimg-main__content.el-scrollbar .el-scrollbar__wrap{width:100%}.next-labelimg-main__content{align-items:center;display:flex;flex:1 1 100%;justify-content:center}.next-labelimg-main .next-labelimg-loading{align-items:center;display:flex;height:100%;justify-content:center;width:100%}.next-labelimg-main .next-labelimg-canvas{border:1px solid #eee;height:100%;min-height:500px;position:relative;width:100%}.next-labelimg-main .next-labelimg-canvas__context{height:100%;position:absolute;width:100%;z-index:3}.next-labelimg-main .next-labelimg-canvas__rect{height:100%;position:absolute;width:100%;z-index:1}.next-labelimg-main .next-labelimg-right{box-sizing:border-box;flex:0 0 200px;height:inherit;padding:10px;text-align:left}.next-labelimg-main .next-labelimg-right>ul{border-radius:5px;box-shadow:0 0 4px 0 rgba(0,0,0,.15);box-sizing:border-box;height:100%;padding:10px}.next-labelimg-main .next-labelimg-right>ul li{align-items:center;border:1px solid #ddd;border-radius:3px;display:flex;font-size:12px;justify-content:space-between;line-height:20px;margin:5px 0;padding:3px 6px}.next-labelimg-main .next-labelimg-right>ul li .el-icon{cursor:pointer}.next-labelimg-main .next-labelimg-right>ul li:hover{border:1px solid var(--el-color-primary)}.next-labelimg-main .next-labelimg-right>ul li .label-line{border-radius:3px;display:inline-block;height:10px;margin-right:6px;width:3px}.next-labelimg-footer{align-items:center;display:flex;justify-content:space-between;padding:20px 12px 8px}.next-labelimg-footer .left-right,.next-labelimg-footer .next-labelimg-footer__left,.next-labelimg-footer .next-labelimg-footer__right{align-items:center;display:flex;flex:0 0 50px;justify-content:center}.next-labelimg-footer .left-right .el-icon:hover,.next-labelimg-footer .next-labelimg-footer__left .el-icon:hover,.next-labelimg-footer .next-labelimg-footer__right .el-icon:hover{cursor:pointer}.next-labelimg-footer__center{flex:1 1 auto}.next-labelimg-footer__center--list{align-items:center;display:flex;flex-wrap:nowrap;justify-content:flex-start;min-height:80px}.next-labelimg-footer__center--list>li{background-color:#fff;border:1px solid #eee;box-sizing:border-box;cursor:pointer;flex:0 0 100px;height:80px;margin:0 5px;overflow:hidden;text-align:center}.next-labelimg-footer__center--list>li.is-activate,.next-labelimg-footer__center--list>li:hover{border:1px solid var(--el-color-primary)}.next-labelimg .next-labelimg-contextmenu-label{background-color:#fff;border-radius:8px;box-shadow:0 0 50px 3px #ccc;padding:10px 15px;position:fixed;transition:all .3s;white-space:nowrap;z-index:9999}.next-labelimg .next-labelimg-contextmenu-label>.label-head{align-items:center;display:flex;font-size:14px;justify-content:space-between;padding-bottom:10px}.next-labelimg .next-labelimg-contextmenu-label>.label-head .el-icon{transition:all .3s}.next-labelimg .next-labelimg-contextmenu-label>.label-head .el-icon:hover{cursor:pointer;transform:rotate(90deg)}.next-labelimg .next-labelimg-contextmenu-label>.label-main{scrollbar-face-color:transparent;scrollbar-3dlight-color:#aaa;scrollbar-highlight-color:#aaa;scrollbar-shadow-color:#aaa;scrollbar-base-color:#aaa;scrollbar-track-color:transparent;scrollbar-arrow-color:transparent;max-height:300px;overflow-y:auto}.next-labelimg .next-labelimg-contextmenu-label>.label-main::-webkit-scrollbar{background-color:transparent;border-radius:6px;height:10px;max-width:6px;width:6px}.next-labelimg .next-labelimg-contextmenu-label>.label-main::-webkit-scrollbar-thumb{background-color:hsla(0,0%,67%,.2);border-radius:6px}.next-labelimg .next-labelimg-contextmenu-label>.label-main::-webkit-scrollbar-thumb:hover{background-color:#aaa}.next-labelimg .next-labelimg-contextmenu-label>.label-main::-webkit-scrollbar-thumb:inactive{background-color:#eee}.next-labelimg .next-labelimg-contextmenu-label>.label-main:hover::-webkit-scrollbar-thumb{background-color:hsla(0,0%,67%,.5)}.next-labelimg .next-labelimg-contextmenu-label>.label-main::-webkit-scrollbar-track-piece{background-color:transparent;border-radius:6px}.next-labelimg .next-labelimg-contextmenu-label>.label-main::-webkit-resizer,.next-labelimg .next-labelimg-contextmenu-label>.label-main::-webkit-scrollbar-corner{background-color:transparent}.next-labelimg .next-labelimg-contextmenu-label>.label-main>li{align-items:center;display:flex;font-size:12px;padding:3px 0}.next-labelimg .next-labelimg-contextmenu-label>.label-main>li .label-line{border-radius:3px;display:inline-block;height:10px;margin-right:6px;width:3px}.next-labelimg .next-labelimg-contextmenu-label>.label-main>li.activate-label{color:var(--el-color-primary)}.next-labelimg .next-labelimg-draggable-rect{background-color:hsla(0,0%,99%,.5);cursor:move;position:absolute;z-index:999}.next-labelimg .next-labelimg-draggable-rect__resize{height:100%;position:relative;width:100%}.next-labelimg .next-labelimg-draggable-rect__resize .bottom-center,.next-labelimg .next-labelimg-draggable-rect__resize .bottom-left,.next-labelimg .next-labelimg-draggable-rect__resize .bottom-right,.next-labelimg .next-labelimg-draggable-rect__resize .dot,.next-labelimg .next-labelimg-draggable-rect__resize .left-center,.next-labelimg .next-labelimg-draggable-rect__resize .right-center,.next-labelimg .next-labelimg-draggable-rect__resize .top-center,.next-labelimg .next-labelimg-draggable-rect__resize .top-left,.next-labelimg .next-labelimg-draggable-rect__resize .top-right{background-color:var(--el-color-primary);border:1px solid var(--el-color-primary);box-sizing:border-box;height:10px;position:absolute;width:10px}.next-labelimg .next-labelimg-draggable-rect__resize .top-left{cursor:nw-resize;left:-5px;top:-5px}.next-labelimg .next-labelimg-draggable-rect__resize .top-center{cursor:s-resize;left:50%;top:-5px;transform:translateX(-50%)}.next-labelimg .next-labelimg-draggable-rect__resize .top-right{cursor:sw-resize;right:-5px;top:-5px}.next-labelimg .next-labelimg-draggable-rect__resize .left-center{cursor:w-resize;left:-5px;top:50%;transform:translateY(-50%)}.next-labelimg .next-labelimg-draggable-rect__resize .right-center{cursor:w-resize;right:-5px;top:50%;transform:translateY(-50%)}.next-labelimg .next-labelimg-draggable-rect__resize .bottom-left{bottom:-5px;cursor:sw-resize;left:-5px}.next-labelimg .next-labelimg-draggable-rect__resize .bottom-center{bottom:-5px;cursor:s-resize;left:50%;transform:translateX(-50%)}.next-labelimg .next-labelimg-draggable-rect__resize .bottom-right{bottom:-5px;cursor:nw-resize;right:-5px}.next-labelimg-fullscreen{background-color:#fff;bottom:0;left:0;overflow:hidden;position:fixed;right:0;top:0;transition:all .3s;z-index:999}.next-labelimg-preview{display:inline-block;height:100%}
16
- .next-labelme-loading .next-spin-loading-mask__text{text-shadow:unset}.next-labelme-fullscreen{background-color:#fff;bottom:0;left:0;overflow:hidden;position:fixed;right:0;top:0;transition:all .3s;z-index:999}.next-labelme{border:1px solid #eee;border-radius:3px;box-sizing:border-box;height:100%;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:100%}.next-labelme-header{box-shadow:0 0 4px 0 rgba(0,0,0,.15);font-size:12px;justify-content:space-between;padding:10px 12px}.next-labelme-header,.next-labelme-header__tool,.next-labelme-header__tool>li{align-items:center;display:flex}.next-labelme-header__tool>li{cursor:pointer;justify-content:center;margin:0 6px;text-align:center}.next-labelme-header__tool>li>.label-text{line-height:normal;margin:0;padding:5px 8px}.next-labelme-header__tool>li.tool-item{flex-direction:column}.next-labelme-header__tool>li.tool-item:hover{color:var(--el-color-primary)}.next-labelme-header__tool>li.tool-item:hover svg{fill:var(--el-color-primary)}.next-labelme-main{align-items:center;display:flex;justify-content:space-between}.next-labelme-main__content{align-items:center;background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAADZJREFUOE9jZKAQMFKon2HUAAYah8HZs2f/MzAw3DY2NlbDFVt4Y4FiA4hJI6PpgNbpgJhYAAB1/AoRxXg31wAAAABJRU5ErkJggg==);display:flex;flex:1 1 100%;height:100%;justify-content:center}.next-labelme-main .next-labelme-loading{align-items:center;display:flex;justify-content:center;width:100%}.next-labelme-main .next-labelme-canvas{height:100%;min-height:500px;position:relative;width:100%}.next-labelme-main .next-labelme-canvas__context{height:100%;position:absolute;width:100%;z-index:3}.next-labelme-main .next-labelme-canvas__rect{height:100%;position:absolute;width:100%;z-index:1}.next-labelme-footer{align-items:center;display:flex;justify-content:space-between;padding:20px 12px 8px}.next-labelme-footer .left-right,.next-labelme-footer .next-labelme-footer__left,.next-labelme-footer .next-labelme-footer__right{align-items:center;display:flex;flex:0 0 50px;justify-content:center}.next-labelme-footer .left-right .el-icon:hover,.next-labelme-footer .next-labelme-footer__left .el-icon:hover,.next-labelme-footer .next-labelme-footer__right .el-icon:hover{cursor:pointer}.next-labelme-footer__center{flex:1 1 auto}.next-labelme-footer__center--list{align-items:center;display:flex;flex-wrap:nowrap;justify-content:flex-start;min-height:80px}.next-labelme-footer__center--list>li{background-color:#fff;border:1px solid #eee;box-sizing:border-box;cursor:pointer;flex:0 0 100px;height:80px;margin:0 5px;overflow:hidden;text-align:center}.next-labelme-footer__center--list>li.is-activate,.next-labelme-footer__center--list>li:hover{border:1px solid var(--el-color-primary)}
16
+ .next-labelme-loading .next-spin-loading-mask__text{text-shadow:unset}.next-labelme-fullscreen{background-color:#fff;bottom:0;left:0;overflow:hidden;position:fixed;right:0;top:0;transition:all .3s;z-index:999}.next-labelme{border:1px solid #eee;border-radius:3px;box-sizing:border-box;height:100%;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:100%}.next-labelme-header{box-shadow:0 0 4px 0 rgba(0,0,0,.15);font-size:12px;justify-content:space-between;padding:10px 12px}.next-labelme-header,.next-labelme-header__tool,.next-labelme-header__tool>li{align-items:center;display:flex}.next-labelme-header__tool>li{cursor:pointer;justify-content:center;margin:0 6px;text-align:center}.next-labelme-header__tool>li>.label-text{line-height:normal;margin:0;padding:5px 8px}.next-labelme-header__tool>li.tool-item{flex-direction:column}.next-labelme-header__tool>li.tool-item:hover{color:var(--el-color-primary)}.next-labelme-header__tool>li.tool-item:hover svg{fill:var(--el-color-primary)}.next-labelme-main{align-items:center;display:flex;justify-content:space-between}.next-labelme-main__content{align-items:center;background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAADZJREFUOE9jZKAQMFKon2HUAAYah8HZs2f/MzAw3DY2NlbDFVt4Y4FiA4hJI6PpgNbpgJhYAAB1/AoRxXg31wAAAABJRU5ErkJggg==);display:flex;flex:1 1 100%;height:100%;justify-content:center}.next-labelme-main .next-labelme-loading{align-items:center;display:flex;justify-content:center;width:100%}.next-labelme-main .next-labelme-canvas{border:1px solid #eee;height:100%;min-height:500px;position:relative;width:100%}.next-labelme-main .next-labelme-canvas__context{height:100%;position:absolute;width:100%;z-index:3}.next-labelme-main .next-labelme-canvas__rect{height:100%;position:absolute;width:100%;z-index:1}.next-labelme-footer{align-items:center;display:flex;justify-content:space-between;padding:20px 12px 8px}.next-labelme-footer .left-right,.next-labelme-footer .next-labelme-footer__left,.next-labelme-footer .next-labelme-footer__right{align-items:center;display:flex;flex:0 0 50px;justify-content:center}.next-labelme-footer .left-right .el-icon:hover,.next-labelme-footer .next-labelme-footer__left .el-icon:hover,.next-labelme-footer .next-labelme-footer__right .el-icon:hover{cursor:pointer}.next-labelme-footer__center{flex:1 1 auto}.next-labelme-footer__center--list{align-items:center;display:flex;flex-wrap:nowrap;justify-content:flex-start;min-height:80px}.next-labelme-footer__center--list>li{background-color:#fff;border:1px solid #eee;box-sizing:border-box;cursor:pointer;flex:0 0 100px;height:80px;margin:0 5px;overflow:hidden;text-align:center}.next-labelme-footer__center--list>li.is-activate,.next-labelme-footer__center--list>li:hover{border:1px solid var(--el-color-primary)}
package/dist/index.js CHANGED
@@ -2,8 +2,8 @@
2
2
  /**
3
3
  * 作  者:huangteng
4
4
  * 邮  箱:htengweb@163.com
5
- * 当前版本:0.3.7 v
6
- * 发布日期:2024-09-21
5
+ * 当前版本:0.3.8 v
6
+ * 发布日期:2024-09-26
7
7
  * 地  址:https://www.npmjs.com/package/next-element-vue
8
8
  */
9
9
 
@@ -4024,7 +4024,11 @@ var TableColumnOperations = defineComponent({
4024
4024
  const {operationsBtnPlain: operationsBtnPlain, operationsBtnText: operationsBtnText} = options;
4025
4025
  return operationsBtnText || operationsBtnPlain;
4026
4026
  })), renderContent = () => {
4027
- const btnText = options.operationsBtnText, btnPlain = options.operationsBtnPlain, btnSize = options.operationsBtnSize;
4027
+ const btnText = options.operationsBtnText, btnPlain = options.operationsBtnPlain, btnSize = options.operationsBtnSize, btnCfg = {
4028
+ text: btnText,
4029
+ plain: btnPlain,
4030
+ size: btnSize
4031
+ };
4028
4032
  return createVNode(ElTableColumn, {
4029
4033
  fixed: "right",
4030
4034
  label: t("next.table.operation"),
@@ -4032,10 +4036,9 @@ var TableColumnOperations = defineComponent({
4032
4036
  headerAlign: valueExist(options.operationsHeaderAlign, options.headerAlign),
4033
4037
  align: valueExist(options.operationsColumnAlign, options.cellAlign)
4034
4038
  }, {
4035
- default: scoped => createVNode(Fragment, null, [ slots["operation-column-prefix"]?.(scoped, {
4036
- text: btnText,
4037
- plain: btnPlain,
4038
- size: btnSize
4039
+ default: scoped => createVNode(Fragment, null, [ slots["operation-column-prefix"]?.({
4040
+ scoped: scoped,
4041
+ btn: btnCfg
4039
4042
  }), options.editBtn ? createVNode(ElTooltip, {
4040
4043
  enterable: !1,
4041
4044
  effect: "dark",
@@ -4115,10 +4118,9 @@ var TableColumnOperations = defineComponent({
4115
4118
  }),
4116
4119
  default: () => t("next.table.delete")
4117
4120
  }) ]
4118
- }) : null, slots["operation-column-suffix"]?.(scoped, {
4119
- text: btnText,
4120
- plain: btnPlain,
4121
- size: btnSize
4121
+ }) : null, slots["operation-column-suffix"]?.({
4122
+ scoped: scoped,
4123
+ btn: btnCfg
4122
4124
  }) ])
4123
4125
  });
4124
4126
  };
@@ -6604,12 +6606,14 @@ var DraggableRect = defineComponent({
6604
6606
  canvas.width = canvasWidth, scaleOffset.value && (ctx.save(), ctx.translate(scaleOffset.value.x, scaleOffset.value.y),
6605
6607
  ctx.scale(scaleOffset.value.scale, scaleOffset.value.scale)), ctx.clearRect(0, 0, canvasWidth, canvasHeight),
6606
6608
  ctx.drawImage(image, 0, 0, canvasWidth, canvasHeight);
6609
+ const scale = scaleOffset.value?.scale || 1, fontSize = 14 / scale, fontPadding = 6 / scale, lineWidth = 2 / scale;
6607
6610
  for (let i = 0; i < labels.length; i++) {
6608
6611
  const rect = labels[i], {startX: startX, startY: startY, rectWidth: rectWidth, rectHeight: rectHeight, type: type} = rect, color = colors$1[type % colors$1.length];
6609
- if (ctx.font = "bold 14px serif", ctx.textBaseline = "top", ctx.save(), ctx.strokeStyle = color,
6610
- ctx.strokeRect(startX, startY, rectWidth, rectHeight), isValueExist(rect.typeName) || isValueExist(rect.type)) {
6612
+ if (ctx.font = `bold ${fontSize}px serif`, ctx.textBaseline = "top", ctx.save(),
6613
+ ctx.strokeStyle = color, ctx.lineWidth = lineWidth, ctx.strokeRect(startX, startY, rectWidth, rectHeight),
6614
+ isValueExist(rect.typeName) || isValueExist(rect.type)) {
6611
6615
  const text = rect.typeName || rect.type;
6612
- ctx.fillStyle = color, ctx.fillText(text, startX + 6, startY + 6);
6616
+ ctx.fillStyle = color, ctx.fillText(text, startX + fontPadding, startY + fontPadding);
6613
6617
  }
6614
6618
  ctx.restore();
6615
6619
  }
@@ -6617,8 +6621,10 @@ var DraggableRect = defineComponent({
6617
6621
  return updateLabels(), {
6618
6622
  updateLabels: updateLabels,
6619
6623
  addDrawRect: (rect, color = "#f30635") => {
6620
- const {startX: startX, startY: startY, rectWidth: rectWidth, rectHeight: rectHeight} = rect;
6621
- ctx.save(), ctx.strokeStyle = color, ctx.strokeRect(startX, startY, rectWidth, rectHeight),
6624
+ const scale = scaleOffset.value?.scale || 1, {startX: startX, startY: startY, rectWidth: rectWidth, rectHeight: rectHeight} = rect;
6625
+ ctx.save();
6626
+ const lineWidth = 2 / scale;
6627
+ ctx.lineWidth = lineWidth, ctx.strokeStyle = color, ctx.strokeRect(startX, startY, rectWidth, rectHeight),
6622
6628
  ctx.restore();
6623
6629
  },
6624
6630
  hitCanvasLabel: (x, y) => {
@@ -7278,7 +7284,10 @@ var preview = defineComponent({
7278
7284
  }
7279
7285
  });
7280
7286
 
7281
- const NextLabelimg = withInstall(Element$1), NextLabelimgPreview = withInstall(preview), isPointInCircle = (mouseX, mouseY, circleX, circleY, radius) => Math.sqrt(Math.pow(mouseX - circleX, 2) + Math.pow(mouseY - circleY, 2)) < radius, vertexesUnique = vertexes => Array.from(new Set(vertexes.map((item => JSON.stringify(item))))).map((item => JSON.parse(item))), {hexToRgba: hexToRgba} = useChangeColor(), colors = [ "#91cc75", "#fac858", "#ee6666", "#73c0de", "#3ba272", "#fc8452", "#9a60b4", "#ea7ccc" ];
7287
+ const NextLabelimg = withInstall(Element$1), NextLabelimgPreview = withInstall(preview), isPointInCircle = (mouseX, mouseY, circleX, circleY, radius) => Math.sqrt(Math.pow(mouseX - circleX, 2) + Math.pow(mouseY - circleY, 2)) < radius, vertexesUnique = vertexes => Array.from(new Set(vertexes.map((item => JSON.stringify(item))))).map((item => JSON.parse(item))), vertexesToScale = (vertexes, scaleX, scaleY, isMultiply = !0) => vertexes?.length ? vertexes.map((item => ((vertex, scaleX, scaleY, isMultiply = !0) => {
7288
+ const [x, y] = vertex;
7289
+ return isMultiply ? [ x * scaleX, y * scaleY ] : [ x / scaleX, y / scaleY ];
7290
+ })(item, scaleX, scaleY, isMultiply))) : [], {hexToRgba: hexToRgba} = useChangeColor(), colors = [ "#91cc75", "#fac858", "#ee6666", "#73c0de", "#3ba272", "#fc8452", "#9a60b4", "#ea7ccc" ];
7282
7291
 
7283
7292
  class CreatePolygonVertexes {
7284
7293
  canvas;
@@ -7335,9 +7344,9 @@ class CreatePolygonVertexes {
7335
7344
  canvasMouseDblclick(e) {
7336
7345
  e.stopPropagation(), this.isDrawing && (this.canvas.style.cursor = "unset", this.mouseOffset.x = e.offsetX,
7337
7346
  this.mouseOffset.y = e.offsetY, this.vertexes.push([ e.offsetX, e.offsetY ]), this.vertexes = vertexesUnique(this.vertexes)),
7338
- this.notifyDestryedListerers(), this.destroyed();
7347
+ this.notifyDestryedListerers(), this.destroy();
7339
7348
  }
7340
- destroyed() {
7349
+ destroy() {
7341
7350
  this.isDrawing = !1, this.vertexes = [], this.vertexesObservers = [], this.destroyedObservers = () => {
7342
7351
  this.canvas.removeEventListener("click", this.canvasMouseClick);
7343
7352
  }, this.canvas.removeEventListener("mousemove", this.canvasMousemove), this.canvas.removeEventListener("dblclick", this.canvasMouseDblclick);
@@ -7357,11 +7366,18 @@ class EditPolygonPath {
7357
7366
  edgeCentreRadius;
7358
7367
  pointRecover;
7359
7368
  observers=[];
7369
+ editPolygonObserver;
7360
7370
  constructor(canvas, ctx) {
7361
7371
  this.canvas = canvas, this.ctx = ctx, this.vertexes = [], this.isEditing = !1, this.canClickEvent = !0,
7362
7372
  this.isMoveEditing = !1, this.pointVertexIndex = -1, this.pointCentreIndex = -1,
7363
7373
  this.vertexRadius = 8, this.edgeCentreRadius = 5, this.pointRecover = [];
7364
7374
  }
7375
+ notifyEditPolygonObserver() {
7376
+ this.editPolygonObserver?.(this.vertexes);
7377
+ }
7378
+ onEditPolygon(callback) {
7379
+ this.editPolygonObserver = callback;
7380
+ }
7365
7381
  drawPolygonPath(vertexes, mouseX, mouseY) {
7366
7382
  const ctx = this.ctx;
7367
7383
  if (!vertexes.length) return;
@@ -7466,7 +7482,7 @@ class EditPolygonPath {
7466
7482
  this.pointVertexIndex > -1 && this.vertexes.splice(this.pointVertexIndex, 1, [ x, y ]),
7467
7483
  this.pointCentreIndex > -1 && this.vertexes.splice(this.pointCentreIndex, 1, [ x, y ]),
7468
7484
  this.isMoveEditing = !1, this.pointVertexIndex = -1, this.pointCentreIndex = -1,
7469
- this.drawPolygon(this.vertexes), this.notifyObservers();
7485
+ this.drawPolygon(this.vertexes), this.notifyObservers(), this.notifyEditPolygonObserver();
7470
7486
  }
7471
7487
  canvasMouseClick(e) {
7472
7488
  e.stopPropagation();
@@ -7475,7 +7491,8 @@ class EditPolygonPath {
7475
7491
  const i = this.pointInVertexes(x, y);
7476
7492
  if (isValueExist(i)) {
7477
7493
  if (this.vertexes.length <= 3) return;
7478
- this.vertexes.splice(i, 1), this.drawPolygon(this.vertexes), this.notifyObservers();
7494
+ this.vertexes.splice(i, 1), this.drawPolygon(this.vertexes), this.notifyObservers(),
7495
+ this.notifyEditPolygonObserver();
7479
7496
  }
7480
7497
  }
7481
7498
  }
@@ -7486,7 +7503,7 @@ class EditPolygonPath {
7486
7503
  this.pointCentreIndex > -1 && this.vertexes.splice(this.pointCentreIndex, 1, [ x, y ]),
7487
7504
  this.notifyObservers());
7488
7505
  }
7489
- destroyed() {
7506
+ destroy() {
7490
7507
  this.vertexes = [], this.observers = [], this.isEditing = !1, this.canvas.removeEventListener("mousedown", this.canvasMousedown),
7491
7508
  this.canvas.removeEventListener("mouseup", this.canvasMouseup), this.canvas.removeEventListener("click", this.canvasMouseClick),
7492
7509
  this.canvas.removeEventListener("mousemove", this.canvasMousemove);
@@ -7499,26 +7516,32 @@ class CreateDrawCanvas {
7499
7516
  image;
7500
7517
  canvasWidth;
7501
7518
  canvasHeight;
7502
- paths;
7519
+ scaleOffset;
7520
+ labels;
7503
7521
  scaleX;
7504
7522
  scaleY;
7505
7523
  editDrawPolygon;
7506
7524
  createPolygonVertexes;
7507
7525
  editVertexes;
7508
7526
  editPolygonObservers=[];
7527
+ drawnPolygonObserver;
7509
7528
  constructor(options) {
7510
- const {canvas: canvas, ctx: ctx, image: image, canvasWidth: canvasWidth, canvasHeight: canvasHeight, paths: paths, scaleX: scaleX, scaleY: scaleY} = options;
7529
+ const {canvas: canvas, ctx: ctx, image: image, canvasWidth: canvasWidth, canvasHeight: canvasHeight, labels: labels, scaleX: scaleX, scaleY: scaleY, scaleOffset: scaleOffset} = options;
7511
7530
  this.canvas = canvas, this.ctx = ctx, this.image = image, this.canvasWidth = canvasWidth,
7512
- this.canvasHeight = canvasHeight, this.paths = paths || [], this.scaleX = scaleX || 1,
7513
- this.scaleY = scaleY || 1, this.editVertexes = [], this.render(), this.createPolygonVertexes = new CreatePolygonVertexes(canvas, ctx),
7514
- this.editDrawPolygon = new EditPolygonPath(canvas, ctx), this.createPolygonVertexes.vertexesChangeEventListener(((vertexes, mouseOffset) => {
7531
+ this.canvasHeight = canvasHeight, this.scaleOffset = scaleOffset, this.labels = labels || {},
7532
+ this.scaleX = scaleX || 1, this.scaleY = scaleY || 1, this.editVertexes = [], this.render(),
7533
+ this.createPolygonVertexes = new CreatePolygonVertexes(canvas, ctx), this.editDrawPolygon = new EditPolygonPath(canvas, ctx),
7534
+ this.createPolygonVertexes.vertexesChangeEventListener(((vertexes, mouseOffset) => {
7515
7535
  this.render(), this.editDrawPolygon.drawPolygon(vertexes, mouseOffset), this.editVertexes = vertexes,
7516
7536
  this.notifyObservers();
7517
7537
  })), this.createPolygonVertexes.onDestroyed((vertexes => {
7518
- this.render(), this.editDrawPolygon.drawPolygon(vertexes), this.editDrawPolygon.updatePolygon((vertexes => {
7538
+ this.editVertexes = vertexes, this.render(), this.editDrawPolygon.drawPolygon(vertexes),
7539
+ this.editDrawPolygon.updatePolygon((vertexes => {
7519
7540
  this.render(), this.editDrawPolygon.drawPolygon(vertexes), this.editVertexes = vertexes,
7520
7541
  this.notifyObservers();
7521
- }));
7542
+ })), this.editDrawPolygon.onEditPolygon((vertexes => {
7543
+ this.editVertexes = vertexes, this.notifyDrawnPolygonObservers();
7544
+ })), this.notifyDrawnPolygonObservers();
7522
7545
  }));
7523
7546
  }
7524
7547
  notifyObservers() {
@@ -7526,17 +7549,22 @@ class CreateDrawCanvas {
7526
7549
  listener(this.editVertexes);
7527
7550
  }));
7528
7551
  }
7552
+ notifyDrawnPolygonObservers() {
7553
+ this.drawnPolygonObserver?.(this.editVertexes);
7554
+ }
7529
7555
  updatePolygon(callback) {
7530
7556
  this.editPolygonObservers.push(callback);
7531
7557
  }
7532
- drawPolygons(paths) {
7533
- const ctx = this.ctx;
7534
- ctx.scale(this.scaleX, this.scaleY);
7535
- for (let i = 0; i < paths.length; i++) {
7536
- const path = paths[i].path;
7558
+ onDrawnPolygon(callback) {
7559
+ this.drawnPolygonObserver = callback;
7560
+ }
7561
+ drawPolygons(shapes) {
7562
+ const ctx = this.ctx, {scale: scale} = this.scaleOffset.value, scaleX = this.scaleX, scaleY = this.scaleY;
7563
+ for (let i = 0; i < shapes.length; i++) {
7564
+ const item = shapes[i], path = vertexesToScale(item.points, scaleX, scaleY);
7537
7565
  if (!path.length) return;
7538
7566
  const color = colors[i % colors.length];
7539
- ctx.beginPath(), ctx.lineWidth = 2, ctx.strokeStyle = color, ctx.fillStyle = hexToRgba(color, .2);
7567
+ ctx.beginPath(), ctx.lineWidth = 2 / scale, ctx.strokeStyle = color, ctx.fillStyle = hexToRgba(color, .2);
7540
7568
  const startX = path[0][0], startY = path[0][1];
7541
7569
  ctx.moveTo(startX, startY);
7542
7570
  for (let i = 1; i < path.length; i++) {
@@ -7546,15 +7574,18 @@ class CreateDrawCanvas {
7546
7574
  ctx.closePath(), ctx.stroke(), ctx.fill();
7547
7575
  }
7548
7576
  }
7549
- initCanvas=() => {
7577
+ drawCanvas=() => {
7550
7578
  this.ctx.clearRect(0, 0, this.canvasWidth, this.canvasHeight), this.ctx.drawImage(this.image, 0, 0, this.canvasWidth, this.canvasHeight),
7551
- this.ctx.save(), this.drawPolygons(this.paths), this.ctx.restore();
7579
+ this.ctx.save();
7580
+ const shapes = this.labels.shapes;
7581
+ this.drawPolygons(shapes), this.ctx.restore();
7552
7582
  };
7553
7583
  render=() => {
7554
- this.initCanvas();
7584
+ this.canvas.width = this.canvasWidth, this.scaleOffset.value && (this.ctx.translate(this.scaleOffset.value.x, this.scaleOffset.value.y),
7585
+ this.ctx.scale(this.scaleOffset.value.scale, this.scaleOffset.value.scale)), this.drawCanvas();
7555
7586
  };
7556
- destroyed() {
7557
- this.paths = [], this.editDrawPolygon.destroyed(), this.createPolygonVertexes.destroyed();
7587
+ destroy() {
7588
+ this.labels = {}, this.editDrawPolygon.destroy(), this.createPolygonVertexes.destroy();
7558
7589
  }
7559
7590
  }
7560
7591
 
@@ -7573,9 +7604,9 @@ var CanvasContext = defineComponent({
7573
7604
  default: () => ({})
7574
7605
  }
7575
7606
  },
7576
- emits: [ "editPolygon" ],
7607
+ emits: [ "editPolygon", "changePolygon" ],
7577
7608
  setup(props, {emit: emit, expose: expose}) {
7578
- const ns = inject("ns", {}), mainBasaeRef = ref(), canvasMainRef = ref(), canvasBaseRef = ref(), drawCanvas = ref(), setContainerWidthHeight = (canvasWidth, canvasHeight) => {
7609
+ const ns = inject("ns", {}), scaleTranslateManager = inject("scaleTranslateManager", {}), mainBasaeRef = ref(), canvasMainRef = ref(), canvasBaseRef = ref(), drawCanvas = ref(), canvasDragZoom = ref(), setContainerWidthHeight = (canvasWidth, canvasHeight) => {
7579
7610
  canvasMainRef.value.style.width = canvasWidth + "px", canvasMainRef.value.style.height = canvasHeight + "px",
7580
7611
  canvasBaseRef.value.width = canvasWidth, canvasBaseRef.value.height = canvasHeight,
7581
7612
  canvasBaseRef.value.style.width = canvasWidth + "px", canvasBaseRef.value.style.height = canvasHeight + "px";
@@ -7585,7 +7616,7 @@ var CanvasContext = defineComponent({
7585
7616
  const image = new Image;
7586
7617
  image.src = rowInfo.imageSrc, loadingImage.value = !0, image.onload = () => {
7587
7618
  loadingImage.value = !1;
7588
- const {canvasWidth: canvasWidth, canvasHeight: canvasHeight, scaleFactor: scaleFactor, scaleX: scaleX, scaleY: scaleY} = (image => {
7619
+ const {canvasWidth: canvasWidth, canvasHeight: canvasHeight, scaleFactor: scaleFactor, scaleX: scaleX, scaleY: scaleY, originWidth: originWidth, originHeight: originHeight} = (image => {
7589
7620
  const clientWidth = mainBasaeRef.value?.elementInstance.clientWidth, clientHeight = mainBasaeRef.value?.elementInstance.clientHeight;
7590
7621
  let {width: width, height: height} = image, scaleFactor = 1;
7591
7622
  const aspect_ratio = width / height;
@@ -7605,7 +7636,9 @@ var CanvasContext = defineComponent({
7605
7636
  canvasHeight: canvasHeight,
7606
7637
  scaleFactor: scaleFactor,
7607
7638
  scaleX: Number(scaleX),
7608
- scaleY: Number(scaleY)
7639
+ scaleY: Number(scaleY),
7640
+ originWidth: image.width,
7641
+ originHeight: image.height
7609
7642
  };
7610
7643
  })(image);
7611
7644
  image.style.width = canvasWidth + "px", image.style.height = canvasHeight + "px",
@@ -7616,15 +7649,25 @@ var CanvasContext = defineComponent({
7616
7649
  canvasWidth: canvasWidth,
7617
7650
  canvasHeight: canvasHeight,
7618
7651
  scaleFactor: scaleFactor,
7619
- paths: rowInfo.labels,
7652
+ labels: rowInfo.labels,
7620
7653
  scaleX: scaleX,
7621
- scaleY: scaleY
7654
+ scaleY: scaleY,
7655
+ scaleOffset: scaleTranslateManager.scaleTranslate
7622
7656
  }), drawCanvas.value.updatePolygon((vertexes => {
7623
- emit("editPolygon", {
7657
+ emit("changePolygon", {
7624
7658
  vertexes: vertexes,
7625
7659
  canvasWidth: canvasWidth,
7626
7660
  canvasHeight: canvasHeight
7627
7661
  });
7662
+ })), drawCanvas.value.onDrawnPolygon((vertexes => {
7663
+ const new_vertexes = vertexesToScale(vertexes, scaleX, scaleY, !1);
7664
+ emit("editPolygon", {
7665
+ vertexes: new_vertexes,
7666
+ originWidth: originWidth,
7667
+ originHeight: originHeight
7668
+ });
7669
+ })), canvasDragZoom.value = new CanvasSceneDragZoom(canvasBaseRef.value), canvasDragZoom.value.changeZoom((scaleOffset => {
7670
+ scaleTranslateManager.onChangeScaleTranslate(scaleOffset), drawCanvas.value.render();
7628
7671
  }));
7629
7672
  }, image.onerror = () => {
7630
7673
  loadingImage.value = !1;
@@ -7645,6 +7688,8 @@ var CanvasContext = defineComponent({
7645
7688
  renderImageLabel(rowInfo);
7646
7689
  }
7647
7690
  }));
7691
+ })), onUnmounted((() => {
7692
+ drawCanvas.value.destroy(), canvasDragZoom.value.destroy();
7648
7693
  }));
7649
7694
  return expose({
7650
7695
  rerenderImage: () => {
@@ -7652,6 +7697,9 @@ var CanvasContext = defineComponent({
7652
7697
  const rowInfo = toRaw(props.rowInfo);
7653
7698
  renderImageLabel(rowInfo);
7654
7699
  }));
7700
+ },
7701
+ resetScaleOffset: () => {
7702
+ canvasDragZoom.value.reset();
7655
7703
  }
7656
7704
  }), () => createVNode(Fragment, null, [ createVNode(NextSpinLoading, {
7657
7705
  ref: mainBasaeRef,
@@ -7687,7 +7735,7 @@ var CanvasContext = defineComponent({
7687
7735
  },
7688
7736
  emits: [ "fullscreen", "save" ],
7689
7737
  setup(props, {emit: emit}) {
7690
- const _ns = inject("ns", {}), {t: t} = useLocale(), switchFillscreen = val => {
7738
+ const _ns = inject("ns", {}), scaleTranslateManager = inject("scaleTranslateManager", {}), scaleTranslate = scaleTranslateManager.scaleTranslate, {t: t} = useLocale(), switchFillscreen = val => {
7691
7739
  emit("fullscreen", val), document.body.style.overflow = val ? "hidden" : "auto";
7692
7740
  };
7693
7741
  return () => createVNode(Fragment, null, [ createVNode(Fragment, null, [ createVNode("ul", {
@@ -7768,7 +7816,28 @@ var CanvasContext = defineComponent({
7768
7816
  class: "label-text"
7769
7817
  }, [ t("next.labelme.deletePolyton") ]) ]) ]), createVNode("ul", {
7770
7818
  class: [ _ns.be("header", "tool") ]
7771
- }, [ props.imageLength ? createVNode("li", null, [ createVNode("span", null, [ createTextVNode("第 "), props.imageIndex + 1, createTextVNode(" 张") ]), createVNode("em", {
7819
+ }, [ createVNode("li", {
7820
+ class: "hover",
7821
+ onClick: () => scaleTranslateManager.onResetScaleTranslate()
7822
+ }, [ createVNode("svg", {
7823
+ t: "1725840994827",
7824
+ class: "icon",
7825
+ viewBox: "0 0 1024 1024",
7826
+ version: "1.1",
7827
+ xmlns: "http://www.w3.org/2000/svg",
7828
+ "p-id": "6051",
7829
+ width: "18",
7830
+ height: "18"
7831
+ }, [ createVNode("path", {
7832
+ d: "M322.794667 445.205333a34.133333 34.133333 0 0 1 2.218666 45.824l-2.218666 2.432a34.133333 34.133333 0 0 1-45.824 2.218667l-2.432-2.218667-149.333334-149.333333a34.133333 34.133333 0 0 1-2.218666-45.824l2.218666-2.432 149.333334-149.333333a34.133333 34.133333 0 0 1 50.474666 45.824l-2.218666 2.432-91.050667 91.050666L640 285.866667c160.234667 0 290.133333 129.898667 290.133333 290.133333 0 158.016-126.314667 286.506667-283.477333 290.048L640 866.133333H234.666667a34.133333 34.133333 0 0 1-3.114667-68.117333L234.666667 797.866667h405.333333c122.538667 0 221.866667-99.328 221.866667-221.866667 0-120.533333-96.106667-218.602667-215.850667-221.781333L640 354.133333l-408.256-0.021333 91.050667 91.093333z",
7833
+ "p-id": "6052"
7834
+ }, null) ]), createVNode("span", {
7835
+ style: "padding-left: 3px"
7836
+ }, [ t("next.labelimg.zoomRestore") ]) ]), createVNode("li", null, [ createVNode("span", null, [ createTextVNode("缩放比例") ]), createVNode("span", null, [ parseInt((100 * scaleTranslate.value.scale).toString()), createTextVNode("%") ]), createVNode("span", {
7837
+ style: "padding: 0 10px;"
7838
+ }, [ createTextVNode("偏移量") ]), createVNode("span", {
7839
+ style: "min-width: 120px; text-align: left;"
7840
+ }, [ createTextVNode("X: "), scaleTranslate.value.x, createTextVNode(", Y: "), scaleTranslate.value.y ]) ]), props.imageLength ? createVNode("li", null, [ createVNode("span", null, [ createTextVNode("第 "), props.imageIndex + 1, createTextVNode(" 张") ]), createVNode("em", {
7772
7841
  style: "padding: 0 5px;"
7773
7842
  }, [ createTextVNode("/") ]), createVNode("span", null, [ createTextVNode("共 "), props.imageLength, createTextVNode(" 张") ]) ]) : null, createVNode("li", {
7774
7843
  style: "margin-right: 30px;",
@@ -7862,7 +7931,7 @@ var Element = defineComponent({
7862
7931
  default: () => []
7863
7932
  }
7864
7933
  },
7865
- emits: [ "change", "save", "edit-polygon", "prev-click", "next-click" ],
7934
+ emits: [ "change", "save", "edit-polygon", "change-polygon", "prev-click", "next-click" ],
7866
7935
  setup(props, {emit: emit, slots: slots}) {
7867
7936
  const _config = deepClone(defaultConfig), _options = computed((() => {
7868
7937
  const cfg = unref(props.options);
@@ -7922,14 +7991,29 @@ var Element = defineComponent({
7922
7991
  isFullscreen.value = val, updateMainContentHeight(), nextTick((() => {
7923
7992
  canvasContextRef.value.rerenderImage();
7924
7993
  }));
7925
- }, onEditPlygonChange = plygon => {
7926
- currentNode.value.labels = plygon, emit("edit-polygon", plygon);
7994
+ }, onChangePolygon = node => {
7995
+ currentNode.value.labels = node, emit("change-polygon", node);
7996
+ }, onEditPlygon = node => {
7997
+ currentNode.value.labels = node, emit("edit-polygon", node);
7927
7998
  }, onToolHeaderSave = () => {
7928
7999
  onChangeActivateNode(activateNodeIndex.value) || ElMessage({
7929
8000
  type: "info",
7930
8001
  message: t("next.labelimg.labelNoUpdate")
7931
8002
  });
7932
- };
8003
+ }, scaleTranslate = ref({
8004
+ scale: 1,
8005
+ x: 0,
8006
+ y: 0
8007
+ });
8008
+ provide("scaleTranslateManager", {
8009
+ scaleTranslate: scaleTranslate,
8010
+ onChangeScaleTranslate: val => {
8011
+ scaleTranslate.value = val;
8012
+ },
8013
+ onResetScaleTranslate: () => {
8014
+ canvasContextRef.value.resetScaleOffset();
8015
+ }
8016
+ });
7933
8017
  return () => createVNode(Fragment, null, [ createVNode("div", {
7934
8018
  ref: layoutLabelRef,
7935
8019
  class: [ ns.b(), props.className, isFullscreen.value ? ns.b("fullscreen") : "" ],
@@ -7962,7 +8046,8 @@ var Element = defineComponent({
7962
8046
  }, [ createVNode(CanvasContext, {
7963
8047
  ref: canvasContextRef,
7964
8048
  rowInfo: currentNode.value,
7965
- onEditPolygon: onEditPlygonChange
8049
+ onEditPolygon: onEditPlygon,
8050
+ onChangePolygon: onChangePolygon
7966
8051
  }, null) ]) ]), createVNode("footer", {
7967
8052
  ref: footerRef,
7968
8053
  class: [ ns.b("footer") ]
@@ -8062,7 +8147,7 @@ const zoomDialog = app => {
8062
8147
  }));
8063
8148
  }
8064
8149
  });
8065
- }, version = "0.3.7", install = function(app) {
8150
+ }, version = "0.3.8", install = function(app) {
8066
8151
  Object.keys(components).forEach((key => {
8067
8152
  const component = components[key];
8068
8153
  app.component(component.name, component);
@@ -8072,7 +8157,7 @@ const zoomDialog = app => {
8072
8157
  };
8073
8158
 
8074
8159
  var index = {
8075
- version: "0.3.7",
8160
+ version: "0.3.8",
8076
8161
  install: install
8077
8162
  };
8078
8163