Browse Source

更新包

haojianlong 4 years ago
parent
commit
2b7c73c3d9

+ 2 - 1
docs/.vuepress/components/example/web/graph/scene/PolylineItem.vue

@@ -9,7 +9,7 @@
 
 <script>
     import {SGraphScene, SGraphView} from "@saga-web/graph/lib";
-    import {SPolylineItem} from "@saga-web/big/lib";
+    import {SPolylineItem,SItemStatus} from "@saga-web/big/lib";
     export default {
         name: "editPolyline",
         data() {
@@ -29,6 +29,7 @@
             init(){
                 this.scene.root.children = [];
                 this.item = new SPolylineItem(null,[]);
+                this.item.status = SItemStatus.Create;
                 this.scene.addItem(this.item);
                 this.scene.grabItem = this.item;
                 this.view.update();

+ 8 - 71
docs/.vuepress/components/example/web/graph/scene/Undo1.vue

@@ -5,6 +5,7 @@
         <el-button @click="deleteItem">Delete</el-button>
         <el-button @click="undo">Undo</el-button>
         <el-button @click="redo">Redo</el-button>
+        <el-button @click="log">日志</el-button>
         <canvas id="undoFrame" width="800" height="400" />
     </div>
 </template>
@@ -12,15 +13,13 @@
 <script lang="ts">
     import { SMouseEvent, SUndoStack } from "@saga-web/base";
     import { SColor, SPainter, SRect } from "@saga-web/draw";
-    import { SGraphItem, SGraphScene, SGraphView } from "@saga-web/graph";
-    import {SGraphCommand} from "@saga-web/graph/lib";
-    import {SUndoCommand} from "@saga-web/base/lib";
+    import { SGraphItem, SGraphScene, SGraphView, SGraphAddCommand, SGraphMoveCommand } from "@saga-web/graph";
     import {SPoint} from "@saga-web/draw/lib";
 
     class RectItem extends SGraphItem {
         width = 100;
         height = 100;
-
+        id = new Date().getTime()
         constructor(parent: SGraphItem | null) {
             super(parent);
             this.moveable = true;
@@ -42,6 +41,7 @@
 
     class CircleItem extends SGraphItem {
         r = 50;
+        id = new Date().getTime()
 
         constructor(parent: SGraphItem | null) {
             super(parent);
@@ -113,72 +113,6 @@
         }
     }
 
-    class SGraphAddCommand extends SGraphCommand {
-        item: SGraphItem;
-        parent: SGraphItem | null;
-
-        constructor(scene: SGraphScene, item: SGraphItem) {
-            super(scene);
-            this.item = item;
-            this.parent = item.parent;
-        }
-        mergeWith(command: SUndoCommand): boolean {
-            return false;
-        }
-
-        redo(): void {
-            this.item.parent = this.parent;
-            this.parent.update();
-        }
-
-        undo(): void {
-            this.item.parent = null;
-            this.parent.update();
-        }
-    }
-
-    class SGraphDeleteCommand extends SGraphCommand {
-        mergeWith(command: SUndoCommand): boolean {
-            return false;
-        }
-
-        redo(): void {
-        }
-
-        undo(): void {
-        }
-    }
-
-    class SGraphMoveCommand extends SGraphCommand {
-        item: SGraphItem;
-        old: SPoint;
-        pos: SPoint;
-
-        constructor(scene: SGraphScene, item: SGraphItem, old: SPoint, pos: SPoint) {
-            super(scene);
-            this.item = item;
-            this.old = old;
-            this.pos = pos;
-        }
-        mergeWith(command: SUndoCommand): boolean {
-            if (command instanceof  SGraphMoveCommand && command.item == this.item) {
-                command.pos = this.pos;
-                return true;
-            }
-            return false;
-        }
-
-        redo(): void {
-            this.item.pos = new SPoint(this.pos.x, this.pos.y);
-            this.item.update();
-        }
-
-        undo(): void {
-            this.item.pos = new SPoint(this.old.x, this.old.y);
-            this.item.update();
-        }
-    }
-
     export default {
         data() {
             return {
@@ -200,11 +134,14 @@
 
             },
             undo() {
-                console.log("undo");
                 this.scene.undoStack.undo();
             },
             redo() {
                 this.scene.undoStack.redo();
+            },
+            log() {
+                let str = this.scene.undoStack.toLog();
+                console.log(str)
             }
         }
     }

+ 2 - 3
docs/.vuepress/components/example/web/graph/style/shadow.vue

@@ -9,16 +9,14 @@
 </template>
 
 <script>
-    import {SGraphScene, SGraphView} from "@saga-web/graph/lib";
     import { SCanvasView, SColor, SPainter } from "@saga-web/draw/lib";
 
     class shadowView extends SCanvasView {
 
         constructor(id) {
             super(id);
-            this.blurArr = [1,2,3,4,5,6,7,8,9,10];
             this.shadowBlur = 10;
-            this.shadowColor = new SColor('#CCCCCC');
+            this.shadowColor = new SColor('#00000060');
             this.shadowOffsetX = 10;
             this.shadowOffsetY = 10;
         }
@@ -33,6 +31,7 @@
             canvas.shadow.shadowColor = this.shadowColor;
             canvas.shadow.shadowOffsetX = this.shadowOffsetX;
             canvas.shadow.shadowOffsetY = this.shadowOffsetY;
+            canvas.drawRect(300,50,100,100);
             canvas.drawRect(270,100,100,100);
         }
     }

+ 5 - 5
package.json

@@ -12,11 +12,11 @@
     "publish": "node publish.js"
   },
   "dependencies": {
-    "@saga-web/base": "2.1.16",
-    "@saga-web/big": "1.0.35",
-    "@saga-web/draw": "2.1.90",
-    "@saga-web/graph": "2.1.78",
-    "@saga-web/feng-map": "1.0.6",
+    "@saga-web/base": "2.1.22",
+    "@saga-web/big": "1.0.65",
+    "@saga-web/draw": "2.1.100",
+    "@saga-web/graph": "2.1.101",
+    "@saga-web/feng-map": "1.0.16",
     "axios": "^0.18.1",
     "element-ui": "^2.12.0",
     "vue": "^2.6.10",