Parcourir la source

fix: 修改透明度后替换图片问题

wzl il y a 7 mois
Parent
commit
c98e29b00b
1 fichiers modifiés avec 7 ajouts et 2 suppressions
  1. 7 2
      packages/core/src/editor/image_editor.js

+ 7 - 2
packages/core/src/editor/image_editor.js

@@ -1024,7 +1024,12 @@ export class ImageEditor {
         this.needUndoRec = true
       }
 
-      if (item === 'opacity' && this.opacity !== props.opacity / 100) {
+      if (item === 'opacity') {
+        if (this.opacity * 100 === props.opacity) return
+
+        const opacity = await this.messageHandler.sendWithPromise('GetImageTransparency', this.editAreaPtr)
+        if (opacity * 100 === props.opacity) return
+
         await this.messageHandler.sendWithPromise('SetImageTransparency', {
           editAreaPtr: this.editAreaPtr,
           opacity: props.opacity / 100
@@ -1262,7 +1267,7 @@ export class ImageEditor {
     })
 
     this.imageUrl = this.imageArrayToUrl(imageArray, width, height)
-    this.eventBus.dispatch('contentPropertyChange', { type: 'image', imageUrl: this.imageUrl })
+    this.eventBus.dispatch('contentPropertyChange', { type: 'image', imageUrl: this.imageUrl, opacity: this.opacity * 100 })
   }
 
   // 更新点的位置