ソースを参照

增加打包时模板,解决报错image not defined 无法打包问题;
现在为报错 但可以打包 并可以正常访问

haojianlong 4 年 前
コミット
898b7e603a

+ 25 - 27
docs/.vuepress/components/example/web/graph/scene/TextItem.vue

@@ -12,16 +12,14 @@
 	</div>
 </template>
 
-<script lang="ts">
-	import { SUndoStack } from "@saga-web/base";
-    import { SFont } from "@saga-web/draw";
-	import { SGraphItem, SGraphScene, SGraphView, SGraphPropertyCommand, SGraphMoveCommand } from "@saga-web/graph";
-	import { SPoint } from "@saga-web/draw/lib";
-	import {STextItem} from "@saga-web/big/lib";
+<script>
+	import { SUndoStack } from "@saga-web/base/lib";
+    import { SFont } from "@saga-web/draw/lib";
+	import { SGraphScene, SGraphView, SGraphPropertyCommand, SGraphMoveCommand, STextItem } from "@saga-web/graph/lib";
 
 	class SScene extends SGraphScene {
 		undoStack = new SUndoStack();
-		textItem: STextItem = new STextItem(null);
+		textItem = new STextItem(null);
 
 		constructor() {
 			super();
@@ -32,7 +30,7 @@
 			this.textItem.connect("onMove", this, this.onItemMove.bind(this));
 		}
 
-		updateText(str: string): void {
+		updateText(str) {
 			if (this.textItem.text !== str) {
 				let old = this.textItem.text;
 				this.textItem.text = str;
@@ -40,7 +38,7 @@
 			}
 		}
 
-		updateColor(color: string): void {
+		updateColor(color) {
 			if (this.textItem.color !== color) {
 				let old = this.textItem.color;
 				this.textItem.color = color;
@@ -48,7 +46,7 @@
 			}
 		}
 
-		updateSize(size: number): void {
+		updateSize(size) {
 			if (this.textItem.font.size !== size) {
 				let old = new SFont(this.textItem.font);
 				let font = new SFont(this.textItem.font);
@@ -58,8 +56,8 @@
 			}
 		}
 
-		onItemMove(item: SGraphItem, ...arg: any): void {
-            this.undoStack.push(new SGraphMoveCommand(this, item, arg[0][0] as SPoint, arg[0][1] as SPoint));
+		onItemMove(item, ...arg) {
+            this.undoStack.push(new SGraphMoveCommand(this, item, arg[0][0], arg[0][1]));
         }
 
 	}
@@ -71,13 +69,6 @@
 	}
 
     export default {
-        mounted(): void {
-			let view = new TestView();
-			this.scene.updateText(this.text);
-			this.scene.updateColor(this.color);
-			this.scene.updateSize(this.size);
-			view.scene = this.scene;
-		},
 		data() {
 			return {
 				scene: new SScene(),
@@ -86,23 +77,30 @@
 				color: "#333333",
 			}
 		},
+        mounted() {
+			let view = new TestView();
+			this.scene.updateText(this.text);
+			this.scene.updateColor(this.color);
+			this.scene.updateSize(this.size);
+			view.scene = this.scene;
+		},
 		methods: {
-			handleChangeText(text): void {
-				this.scene.updateText(this.text);
+			handleChangeText(text) {
+				this.scene.updateText(text);
 			},
-			handleChangeColor(color): void {
+			handleChangeColor(color) {
 				this.scene.updateColor(color);
 			},
-			handleChangeSize(size): void {
+			handleChangeSize(size) {
 				this.scene.updateSize(size);
 			},
-			undo(): void {
+			undo() {
 				this.scene.undoStack.undo();
 			},
-			redo(): void {
+			redo() {
 				this.scene.undoStack.redo();
 			},
-			reset(): void {
+			reset() {
 				this.text = "测试文本";
 				this.size = 20;
 				this.color = "#333333";
@@ -116,4 +114,4 @@
 
 <style scoped>
 
-</style>
+</style>

+ 14 - 0
docs/.vuepress/templates/dev.html

@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="utf-8">
+    <meta name="viewport" content="width=device-width,initial-scale=1">
+    <title></title>
+</head>
+<body>
+<script>
+    const Image = window.Image;//定义global
+</script>
+<div id="app"></div>
+</body>
+</html>

+ 20 - 0
docs/.vuepress/templates/ssr.html

@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html lang="{{ lang }}">
+<head>
+    <meta charset="utf-8">
+    <meta name="viewport" content="width=device-width,initial-scale=1">
+    <title>{{ title }}</title>
+    <meta name="generator" content="VuePress {{ version }}">
+    {{{ userHeadTags }}}
+    {{{ pageMeta }}}
+    {{{ renderResourceHints() }}}
+    {{{ renderStyles() }}}
+    <script>
+        const Image = window.Image;//定义global变量
+    </script>
+</head>
+<body>
+<!--vue-ssr-outlet-->
+{{{ renderScripts() }}}
+</body>
+</html>

+ 1 - 1
docs/dev/saga-graphy/scene-manage/align.md

@@ -7,5 +7,5 @@
 <example-web-graph-scene-Align />
 
 ::: details 查看代码
-<<< @/docs/.vuepress/components/example/web/graph/scene/Undo1.vue
+<<< @/docs/.vuepress/components/example/web/graph/scene/Align.vue
 :::