瀏覽代碼

Renamed eventbus

Luis Figueiredo 8 年之前
父節點
當前提交
825e39007a

+ 3 - 0
frontend/vue-web/src/common/eventbus.js

@@ -0,0 +1,3 @@
+import Vue from "vue"
+
+export const EventBus = new Vue()

+ 6 - 8
frontend/vue-web/src/components/Output.vue

@@ -1,22 +1,21 @@
 <template>
 	<div class="output">
-		<pre><code v-html="msg">
-		</code>
-		</pre>	
+		<pre><code v-html="msg"></code> </pre>	
 	</div>
 </template>
 
 <script>
 import Vue from "vue"
 import editor from "vue2-ace"
-import { globalEvt } from "../store/console"
+import { EventBus } from "../common/eventbus"
 
 export default {
 	mounted() {
-		globalEvt.$on("log", this.dolog)
+		EventBus.$on("log", this.dolog) // place this elsewhere?
 	},
 	data: () => {
 		return {
+			counter: 0,
 			msg: ""
 		}
 	},
@@ -25,13 +24,12 @@ export default {
 			var doscroll = false
 			var tolerance = 10
 			var innerHeight = parseInt(getComputedStyle(this.$el).getPropertyValue("height"))
-			console.log("Element:", this.$el.scrollTop, " hieght:", this.$el.scrollHeight, "innerHeight:", innerHeight)
-
 			if (this.$el.scrollTop + innerHeight >= this.$el.scrollHeight - tolerance) {
 				doscroll = true
 			}
 
-			this.msg += msg.join(" ") + "\n"
+			this.msg += "[" + this.counter + "] " + msg.join(" ") + "\n"
+			this.counter++
 
 			if (doscroll) {
 				Vue.nextTick(() => { // This should be in the next tick

+ 2 - 4
frontend/vue-web/src/components/Requester.vue

@@ -19,7 +19,7 @@ import "brace/mode/json"
 import "brace/theme/chrome"
 import Prism from "prismjs/prism"
 
-import { globalEvt } from "../store/console"
+import { EventBus } from "../common/eventbus"
 
 export default {
 	name: "requester",
@@ -39,14 +39,12 @@ export default {
 				url: this.url,
 				body: this.body
 			}
-			console.log("Prism:", Prism.languages)
-			// var highlighted = JSON.stringify(simObj, " ", " ") // Prism.highlight(JSON.stringify(simObj), Prism.languages)
 			var highlighted = Prism.highlight(JSON.stringify(simObj, null, "  "), Prism.languages.js)
 			this.log(method + "-\n" + highlighted)
 		},
 		// Mixin future or global thingy
 		log: function(...msg) {
-			globalEvt.$emit("log", "method:", ...msg)
+			EventBus.$emit("log", "method:", ...msg)
 		}
 	},
 	components: {

+ 0 - 3
frontend/vue-web/src/store/console.js

@@ -1,3 +0,0 @@
-import Vue from "vue"
-
-export const globalEvt = new Vue()