Ver código fonte

graph,big:fix:修改错误引入问题

haojianlong 4 anos atrás
pai
commit
9151b1d0b3

+ 2 - 2
persagy-web-big/package.json

@@ -1,6 +1,6 @@
 {
     "name": "@persagy-web/big",
-    "version": "2.2.25",
+    "version": "2.2.27",
     "description": "博锐尚格建筑信息化库",
     "main": "lib/index.js",
     "types": "lib/index.d.js",
@@ -41,7 +41,7 @@
         "typescript": "^3.9.3"
     },
     "dependencies": {
-        "@persagy-web/graph": "2.2.29",
+        "@persagy-web/graph": "2.2.30",
         "axios": "^0.18.0",
         "pako": "^1.0.10",
         "crypto-js": "^4.0.0",

+ 28 - 23
persagy-web-big/src/items/SEquipItem.ts

@@ -24,11 +24,11 @@
  * *********************************************************************************************************************
  */
 
-import { SGraphItem, SAnchorItem } from "@persagy-web/graph/lib";
-import { SIconTextItem } from "@persagy-web/big";
-import { STextItem, } from "@persagy-web/graph"
-import { SColor } from '@persagy-web/draw/lib';
-import { svgTobase64 } from "./../until/svgTobase64"
+import { SGraphItem } from "@persagy-web/graph/lib";
+import { STextItem } from "@persagy-web/graph";
+import { SColor } from "@persagy-web/draw/lib";
+import { SIconTextItem } from "./SIconTextItem";
+import { svgTobase64 } from "../utils/svgTobase64";
 
 /**
  * 编辑基础设备类
@@ -40,26 +40,26 @@ export class SEquipItem extends SIconTextItem {
     nodeId: string | null = null;
 
     /** 信息点存储 */
-    _infoPointList: any[] = []
+    _infoPointList: any[] = [];
     set infoPointList(val) {
         this._infoPointList = val;
     } // set infoPointList()
     get infoPointList(): any[] {
-        return this._infoPointList
+        return this._infoPointList;
     } // get infoPointList()
 
     /** 图得url */
-    _url: string = '';
+    _url: string = "";
     set url(val) {
         this._url = val;
-        this.initUrl()
+        this.initUrl();
     } // set url()
     get url(): string {
-        return this._url
+        return this._url;
     } // get url()
 
     //  设备附加数据
-    anotherMsg: string = ''
+    anotherMsg: string = "";
 
     /**
      * 构造函数
@@ -69,7 +69,7 @@ export class SEquipItem extends SIconTextItem {
      */
     constructor(parent: SGraphItem | null) {
         super(parent);
-        this.showSelect = false
+        this.showSelect = false;
     } // Constructor
 
     /**
@@ -77,11 +77,14 @@ export class SEquipItem extends SIconTextItem {
      *
      */
     initUrl() {
-        svgTobase64(this.url).then((res) => {
-            this.img.url = res ? res : '';
-        }).catch((res) => {
-            this.img.url = res;
-        })
+        svgTobase64(this.url)
+            .then(res => {
+                // @ts-ignore
+                this.img.url = res ? res : "";
+            })
+            .catch(res => {
+                this.img.url = res;
+            });
     }
 
     /**
@@ -96,22 +99,24 @@ export class SEquipItem extends SIconTextItem {
             item.data = val;
             item.text = val.name;
             if (val.pos) {
-                item.moveTo(val.pos.x, val.pos.x)
+                item.moveTo(val.pos.x, val.pos.x);
             } else {
                 item.moveTo(
                     this.img.width * 0.5,
-                    -(this.font.size * 1.25 * 0.5) + (index) * 10
+                    -(this.font.size * 1.25 * 0.5) + index * 10
                 );
             }
 
             item.font.size = val.font ? val.font : 12;
             item.isTransform = false;
             item.showSelect = false;
-            item.color = val.color ? new SColor(val.color) : new SColor('#000000');
-            this.textItemList.push(item)
+            item.color = val.color
+                ? new SColor(val.color)
+                : new SColor("#000000");
+            this.textItemList.push(item);
         } else {
-            this.textItemList.splice(index, 1)
-            this.scene ? this.scene.removeItem(this.textItemList[index]) : '';
+            this.textItemList.splice(index, 1);
+            this.scene ? this.scene.removeItem(this.textItemList[index]) : "";
         }
     }
 }

+ 21 - 17
persagy-web-big/src/utils/svgTobase64.ts

@@ -1,4 +1,5 @@
 import axios from "axios";
+// @ts-ignore
 import crypto from "crypto-js";
 /**
  * svg流转换为base64字符串
@@ -6,25 +7,28 @@ import crypto from "crypto-js";
  * @param url 获取base的路径
  */
 export function svgTobase64(url: string) {
-    let baseUrl: string = ''
+    let baseUrl = "";
     return new Promise((relve, res) => {
         if (url.includes(".svg")) {
-            axios.get(url).then((res) => {
-                if (res.data) {
-                    const index = res.data.indexOf('"UTF-8"?>');
-                    const str = res.data.substr(index + 9);
-                    const a = crypto.enc.Utf8.parse(str);
-                    baseUrl =
-                        "data:image/svg+xml;base64," + crypto.enc.Base64.stringify(a);
-                }
-                relve(baseUrl)
-            }).catch((err) => {
-                res(err)
-            });
+            axios
+                .get(url)
+                .then(res => {
+                    if (res.data) {
+                        const index = res.data.indexOf('"UTF-8"?>');
+                        const str = res.data.substr(index + 9);
+                        const a = crypto.enc.Utf8.parse(str);
+                        baseUrl =
+                            "data:image/svg+xml;base64," +
+                            crypto.enc.Base64.stringify(a);
+                    }
+                    relve(baseUrl);
+                })
+                .catch(err => {
+                    res(err);
+                });
         } else {
             baseUrl = url;
-            relve(baseUrl)
+            relve(baseUrl);
         }
-    })
-
-}
+    });
+}

+ 1 - 1
persagy-web-graph/package.json

@@ -1,6 +1,6 @@
 {
     "name": "@persagy-web/graph",
-    "version": "2.2.29",
+    "version": "2.2.30",
     "description": "博锐尚格二维图形引擎。",
     "main": "lib/index.js",
     "types": "lib/index.d.js",

+ 11 - 0
persagy-web-graph/src/SGraphItem.ts

@@ -148,6 +148,16 @@ export class SGraphItem extends SObject {
         this.update();
     }
 
+    /** 透明度 */
+    private _globalAlpha = 1;
+    get globalAlpha(): number {
+        return this._globalAlpha;
+    } // Get number
+    set globalAlpha(v: number) {
+        this._globalAlpha = v;
+        this.update();
+    } // Set number
+
     /** 是否可以移动 */
     moveable: boolean = false;
     /** 是否正在移动 */
@@ -251,6 +261,7 @@ export class SGraphItem extends SObject {
                 painter.translate(item.x, item.y);
                 painter.scale(item.scale, item.scale);
                 painter.rotate(item.rotate);
+                // painter.globalAlpha = item.globalAlpha;
 
                 // 如果不进行变形处理,则取消 painter 的变型操作
                 if (!item.isTransform) {

+ 1 - 1
persagy-web-graph/src/index.ts

@@ -95,5 +95,5 @@ export {
     SGraphSvg,
     SGraphLineItem,
     SGraphStyleItem,
-    SGraphCircleItem,
+    SGraphCircleItem
 };

+ 2 - 1
persagy-web-graph/src/items/SGraphCircleItem.ts

@@ -26,8 +26,9 @@
 
 import { SGraphItem } from "../SGraphItem";
 import { SPainter, SRect } from "@persagy-web/draw";
-import { SLineStyle, SGraphStyleItem } from "..";
+import { SLineStyle } from "..";
 import { SPoint } from "@persagy-web/draw/lib";
+import { SGraphStyleItem } from "./SGraphStyleItem";
 
 /**
  * 圆 item

+ 2 - 1
persagy-web-graph/src/items/SGraphPolyGroupItem.ts

@@ -26,7 +26,8 @@
 
 import { SGraphItem } from "../SGraphItem";
 import { SPainter, SPoint, SPolygonUtil, SRect } from "@persagy-web/draw/lib";
-import { PolyGroup, SGraphStyleItem } from "..";
+import { PolyGroup } from "..";
+import { SGraphStyleItem } from "./SGraphStyleItem";
 
 /**
  * 多边形组

+ 2 - 1
persagy-web-graph/src/items/SGraphRectItem.ts

@@ -26,8 +26,9 @@
 
 import { SGraphItem } from "../SGraphItem";
 import { SPainter, SRect } from "@persagy-web/draw";
-import { SGraphStyleItem, SLineStyle } from "..";
+import { SLineStyle } from "..";
 import { SPoint } from "@persagy-web/draw/lib";
+import { SGraphStyleItem } from "./SGraphStyleItem";
 
 /**
  * 矩形(包含圆角矩形) item

+ 4 - 0
persagy-web-graph/src/items/SGraphStyleItem.ts

@@ -73,4 +73,8 @@ export class SGraphStyleItem extends SGraphItem {
         this._lineWidth = v;
         this.update();
     } // Set lineWidth
+
+    constructor(parent: SGraphItem | null = null) {
+        super(parent);
+    }
 }