Jelajahi Sumber

V 1.0.0 Released.

zry 4 tahun lalu
induk
melakukan
72d4598fbe
3 mengubah file dengan 17 tambahan dan 14 penghapusan
  1. 14 12
      XtermVue.vue
  2. 1 1
      index.js
  3. 2 1
      package.json

+ 14 - 12
XtermVue.vue

@@ -5,26 +5,22 @@
 import 'xterm/css/xterm.css'
 import { Terminal } from 'xterm'
 import { FitAddon } from 'xterm-addon-fit'
-
-Terminal.applyAddon(FitAddon)
+import { WebLinksAddon } from 'xterm-addon-web-links'
 
 export default {
     mounted() {
         this.$term = new Terminal({})
+        this.$fitAddon = new FitAddon()
+        this.$term.loadAddon(this.$fitAddon)
+        this.$term.loadAddon(new WebLinksAddon())
         this.$term.open(this.$el)
-        this.$term.fit()
-        this.$term.on('blur', () => this.$emit('blur'))
-        this.$term.on('focus', () => this.$emit('focus'))
-        this.$term.on('title', title => this.$emit('title-change', title))
+        this.$fitAddon.fit()
+        this.$term.onTitleChange((title) => this.$emit('title-change', title))
     },
     
-    beforeDestroy () {
-        this.$term.destroy()
-    },
-
     methods: {
         fit() {
-            this.$term.fit()
+            this.$fitAddon.fit()
         },
         focus() {
             this.$term.focus()
@@ -37,4 +33,10 @@ export default {
         }
     }
 }
-</script>
+</script>
+<style scoped>
+.xterm {
+    height: 100%;
+    width: 100%;
+}
+</style>

+ 1 - 1
index.js

@@ -1,7 +1,7 @@
 import XtermVue from './XtermVue.vue'
 
 
-module.exports = {
+export default {
     install(Vue, options){
         Vue.component("xterm-vue", XtermVue)
     }

+ 2 - 1
package.json

@@ -8,6 +8,7 @@
     "license": "MIT",
     "dependencies": {
         "xterm": "^4.5.0",
-        "xterm-addon-fit": "^0.3.0"
+        "xterm-addon-fit": "^0.3.0",
+        "xterm-addon-web-links": "^0.3.0"
     }
 }