Procházet zdrojové kódy

update: 内容编辑首次渲染优化速度

wzl před 1 měsícem
rodič
revize
de0255516e

+ 4 - 2
packages/core/src/editor/content_container.js

@@ -415,7 +415,8 @@ export class ContentContainer {
           scale: this.pageViewer.scale,
           messageHandler: this.messageHandler,
           pageViewer: this.pageViewer,
-          hidden: this.tool === 'addImage'
+          hidden: this.tool === 'addImage',
+          isUpdate: true
         })
       } else if (await this.messageHandler.sendWithPromise('IsImageArea', editAreaPtr)) {
         frameEditor = new ImageEditor({
@@ -431,7 +432,8 @@ export class ContentContainer {
           messageHandler: this.messageHandler,
           pageViewer: this.pageViewer,
           $t: this.$t,
-          hidden: this.tool === 'addText'
+          hidden: this.tool === 'addText',
+          isUpdate: true
         })
       }
       frameEditor && newFrameEditorList.push(frameEditor)

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

@@ -16,7 +16,8 @@ export class ImageEditor {
     newAdd,
     pageViewer,
     $t,
-    hidden
+    hidden,
+    isUpdate = false
   }) {
     this.eventBus = eventBus
     this.contentContainer = contentContainer
@@ -32,6 +33,7 @@ export class ImageEditor {
     this.pageViewer = pageViewer
     this.$t = $t
     this.hidden = hidden
+    this.isUpdate = isUpdate
 
     this.type = 'image'
     this.deleteSvgStr = `<rect width="30" height="30" rx="2" fill="#DDE9FF"/>
@@ -78,7 +80,9 @@ export class ImageEditor {
     this.eventBus._on('imagePropertyChanged', this.onHandlePropertyPanelChanged)
     this.eventBus._on('showContentEditorType', this.onShowContentEditorType)
 
-    await this.updateCanvas()
+    if (this.isUpdate) await this.updateCanvas()
+    else await this.getRect()
+
     this.opacity = await this.messageHandler.sendWithPromise('GetImageTransparency', this.editAreaPtr)
 
     let frameContainer = createElement(

+ 4 - 2
packages/core/src/editor/text_editor.js

@@ -17,7 +17,8 @@ export class TextEditor {
     messageHandler,
     newAdd,
     pageViewer,
-    hidden
+    hidden,
+    isUpdate = false
   }) {
     this.eventBus = eventBus
     this.contentContainer = contentContainer
@@ -32,6 +33,7 @@ export class TextEditor {
     this.newAdd = newAdd
     this.pageViewer = pageViewer
     this.hidden = hidden
+    this.isUpdate = isUpdate
 
     this.type = 'text'
     this.frame = null
@@ -321,7 +323,7 @@ export class TextEditor {
       this.newAdd = false
     }
     
-    await this.updateCanvas()
+    this.isUpdate && await this.updateCanvas()
   }
 
   getActualRect (viewport, s, frame) {