Browse Source

删除object.tojson;更新包

haojianlong 5 years ago
parent
commit
fa42e90062

+ 1 - 1
saga-web-base/package.json

@@ -1,6 +1,6 @@
 {
     "name": "@saga-web/base",
-    "version": "2.1.15",
+    "version": "2.1.16",
     "description": "上格云Web基础库。",
     "main": "lib/index.js",
     "types": "lib/index.d.js",

+ 0 - 23
saga-web-base/src/extensions/SObjectExtension.ts

@@ -1,23 +0,0 @@
-/**
- * 定义与实现 Object 扩展方法
- *
- * @author  庞利祥
- */
-declare global {
-    /**
-     * 定义 Object 对象扩展方法
-     */
-    interface Object {
-        /** 定义 Object 对象 toJson() 扩展方法 */
-        toJson(): string;
-    }
-}
-
-/**
- * 实现 Object 对象 toJson() 扩展方法
- */
-Object.prototype.toJson = function (): string {
-    return JSON.stringify(this);
-};
-
-export {};

+ 0 - 2
saga-web-base/src/index.ts

@@ -1,5 +1,3 @@
-import "./extensions/SObjectExtension";
-
 import { SMouseButton } from "./enums/SMouseButton";
 import { STouchState } from "./enums/STouchState";
 export { SMouseButton, STouchState };

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

@@ -1,6 +1,6 @@
 {
     "name": "@saga-web/big",
-    "version": "1.0.28",
+    "version": "1.0.29",
     "description": "上格云建筑信息化库",
     "main": "lib/index.js",
     "types": "lib/index.d.js",
@@ -42,6 +42,6 @@
         "typescript": "^3.9.3"
     },
     "dependencies": {
-        "@saga-web/graph": "2.1.71"
+        "@saga-web/graph": "2.1.72"
     }
 }

+ 9 - 9
saga-web-draw/__tests__/types/SPoint.test.ts

@@ -1,33 +1,33 @@
 import { SPoint } from "../../src";
 
 test("构造函数", () => {
-    expect(new SPoint().toJson()).toBe("{\"x\":0,\"y\":0}");
-    expect(new SPoint(10, 10).toJson()).toBe("{\"x\":10,\"y\":10}");
+    expect(JSON.stringify(new SPoint())).toBe('{"x":0,"y":0}');
+    expect(JSON.stringify(new SPoint(10, 10))).toBe('{"x":10,"y":10}');
 });
 
 test("属性修改", () => {
     const p = new SPoint();
-    expect(p.toJson()).toBe("{\"x\":0,\"y\":0}");
+    expect(JSON.stringify(p)).toBe('{"x":0,"y":0}');
 
     p.y = 10;
-    expect(p.toJson()).toBe("{\"x\":0,\"y\":10}");
+    expect(JSON.stringify(p)).toBe('{"x":0,"y":10}');
     p.x = -10;
-    expect(p.toJson()).toBe("{\"x\":-10,\"y\":10}");
+    expect(JSON.stringify(p)).toBe('{"x":-10,"y":10}');
 
     p.setPoint(-100, -30);
-    expect(p.toJson()).toBe("{\"x\":-100,\"y\":-30}");
+    expect(JSON.stringify(p)).toBe('{"x":-100,"y":-30}');
 
     p.setPoint(new SPoint(-5, -12));
-    expect(p.toJson()).toBe("{\"x\":-5,\"y\":-12}");
+    expect(JSON.stringify(p)).toBe('{"x":-5,"y":-12}');
 });
 
 test("setPoint()", () => {
     const p = new SPoint();
     p.setPoint(-100, -30);
-    expect(p.toJson()).toBe("{\"x\":-100,\"y\":-30}");
+    expect(JSON.stringify(p)).toBe('{"x":-100,"y":-30}');
 
     p.setPoint(new SPoint(-5, -12));
-    expect(p.toJson()).toBe("{\"x\":-5,\"y\":-12}");
+    expect(JSON.stringify(p)).toBe('{"x":-5,"y":-12}');
 });
 
 test("manhattanLength()", () => {

+ 2 - 2
saga-web-draw/package.json

@@ -1,6 +1,6 @@
 {
     "name": "@saga-web/draw",
-    "version": "2.1.85",
+    "version": "2.1.86",
     "description": "上格云绘制引擎。",
     "main": "lib/index.js",
     "types": "lib/index.d.js",
@@ -33,7 +33,7 @@
         "typescript": "^3.5.3"
     },
     "dependencies": {
-        "@saga-web/base": "^2.1.15"
+        "@saga-web/base": "^2.1.16"
     },
     "jest": {
         "setupFiles": [

+ 59 - 0
saga-web-draw/src/SShadow.ts

@@ -0,0 +1,59 @@
+import { SColor } from "./SColor";
+
+/**
+ * 阴影
+ *
+ * @author  hoajianlong(1061851420@qq.com)
+ */
+
+export class SShadow {
+    /** 阴影扩散距离  */
+    shadowBlur: number = 0;
+    /** 阴影颜色    */
+    shadowColor: SColor | null = null;
+    /** 阴影x轴偏移量 */
+    shadowOffsetX: number = 0;
+    /** 阴影y轴偏移量 */
+    shadowOffsetY: number = 0;
+
+    /**
+     * 构造函数
+     */
+    constructor();
+
+    /**
+     * 构造函数
+     *
+     * @param   shadow  阴影画刷
+     */
+    constructor(shadow: SShadow);
+
+    /**
+     * 构造函数
+     *
+     * @param   blur    扩散距离
+     * @param   color   颜色
+     */
+    constructor(blur: number, color: SColor);
+
+    /**
+     * 构造函数
+     *
+     * @param   blur    阴影|扩散距离
+     * @param   color   阴影颜色
+     * */
+    constructor(blur?: number | SShadow, color?: SColor) {
+        if (blur == undefined) {
+            return;
+        }
+        if (blur instanceof SShadow) {
+            this.shadowBlur = blur.shadowBlur;
+            this.shadowColor = blur.shadowColor;
+            this.shadowOffsetX = blur.shadowOffsetX;
+            this.shadowOffsetY = blur.shadowOffsetY;
+        } else {
+            this.shadowBlur = blur;
+            this.shadowColor = color || SColor.Black;
+        }
+    }
+} // Class SShadow

+ 2 - 2
saga-web-graph/package.json

@@ -1,6 +1,6 @@
 {
     "name": "@saga-web/graph",
-    "version": "2.1.71",
+    "version": "2.1.72",
     "description": "上格云二维图形引擎。",
     "main": "lib/index.js",
     "types": "lib/index.d.js",
@@ -41,6 +41,6 @@
         "typescript": "^3.5.3"
     },
     "dependencies": {
-        "@saga-web/draw": "2.1.85"
+        "@saga-web/draw": "2.1.86"
     }
 }