guoxiaohuan 4 년 전
부모
커밋
5eb9372fc0
2개의 변경된 파일23개의 추가작업 그리고 9개의 파일을 삭제
  1. 10 4
      src/lib/items/SImageLegendItem.js
  2. 13 5
      src/lib/items/SImageLegendItem.ts

+ 10 - 4
src/lib/items/SImageLegendItem.js

@@ -32,9 +32,6 @@ export class SImageLegendItem extends SIconTextItem {
             this.width = data.Size.Width
             this.height = data.Size.Height
         }
-        if (data.Num) {
-            this.text = `${data.Name}${data.Num > 1 ? ` × ${data.Num}` : ''}`
-        }
         if (data.Properties && data.Properties.Url) {
             this.img.url = data.Properties.Url
         }
@@ -78,7 +75,16 @@ export class SImageLegendItem extends SIconTextItem {
             this.data.Num = 1
         }
         this.data.Properties.Num = this._num
-        this.text = `${this.data.Name}${this.data.Num > 1 ? ` × ${this.data.Num}` : ''}`
+        this.textItem.text = `${this.name}${this.num > 1 ? ` × ${this.num}` : ''}`
+        this.update()
+    }
+    get text() {
+        return this.textItem.text
+    }
+    set text(v) {
+        this.name = v
+        this.data.Name = v
+        this.textItem.text = `${this.name}${this.num > 1 ? ` × ${this.num}` : ''}`
         this.update()
     }
     get maskFlag() {

+ 13 - 5
src/lib/items/SImageLegendItem.ts

@@ -25,7 +25,17 @@ export class SImageLegendItem extends SIconTextItem {
             this.data.Num = 1
         }
         this.data.Properties.Num = this._num
-        this.text = `${this.data.Name}${this.data.Num > 1 ? ` × ${this.data.Num}` : ''}`
+        this.textItem.text = `${this.name}${this.num > 1 ? ` × ${this.num}` : ''}`
+        this.update()
+    }
+
+    get text(): string {
+        return this.textItem.text
+    }
+    set text(v: string) {
+        this.name = v
+        this.data.Name = v
+        this.textItem.text = `${this.name}${this.num > 1 ? ` × ${this.num}` : ''}`
         this.update()
     }
 
@@ -55,17 +65,15 @@ export class SImageLegendItem extends SIconTextItem {
         this.data = data
         this.id = data.ID
         this.name = data.Name
+        this.text = data.Name
         this.moveTo(data.Pos.X, data.Pos.Y)
         if (data.Num) {
-            this._num = data.Num
+            this.num = data.Num
         }
         if (data.Size) {
             this.width = data.Size.Width
             this.height = data.Size.Height
         }
-        if (data.Num) {
-            this.text = `${data.Name}${data.Num > 1 ? ` × ${data.Num}` : ''}`
-        }
         if (data.Properties && data.Properties.Url) {
             this.img.url = data.Properties.Url
         }