3939
4040<script >
4141import { Terminal } from ' xterm'
42- import * as fit from ' xterm/dist/addons/fit/fit'
43- import * as webLinks from ' xterm/dist/addons/webLinks/webLinks'
44-
45- Terminal .applyAddon (fit)
46- Terminal .applyAddon (webLinks)
42+ import { FitAddon } from ' xterm-addon-fit'
43+ import { WebLinksAddon } from ' xterm-addon-web-links'
4744
4845const defaultTheme = {
4946 foreground: ' #2c3e50' ,
@@ -154,7 +151,7 @@ export default {
154151 },
155152
156153 beforeDestroy () {
157- this .$_terminal .destroy ()
154+ this .$_terminal .dispose ()
158155 },
159156
160157 methods: {
@@ -165,11 +162,19 @@ export default {
165162 theme: this .theme ,
166163 ... this .options
167164 })
168- webLinks .webLinksInit (term, this .handleLink )
165+
166+ const fitAddon = new FitAddon ()
167+ const webLinksAddon = new WebLinksAddon (this .handleLink )
168+
169+ this .$_fitAddon = fitAddon
170+
171+ term .loadAddon (fitAddon)
172+ term .loadAddon (webLinksAddon)
173+
169174 term .open (this .$refs .render )
170175
171- term .on ( ' blur ' , () => this .$emit (' blur' ))
172- term .on ( ' focus ' , () => this .$emit (' focus' ))
176+ term .onBlur ( () => this .$emit (' blur' ))
177+ term .onFocus ( () => this .$emit (' focus' ))
173178
174179 if (this .autoSize ) {
175180 this .$nextTick (this .fit )
@@ -226,6 +231,7 @@ export default {
226231 },
227232
228233 handleLink (event , uri ) {
234+ console .log (' aaa' )
229235 if (this .openLinks ) {
230236 window .open (uri, ' _blank' )
231237 }
@@ -238,7 +244,7 @@ export default {
238244
239245 await this .$nextTick ()
240246
241- term .fit ()
247+ this . $_fitAddon .fit ()
242248 term .element .style .display = ' '
243249 term .refresh (0 , term .rows - 1 )
244250 },
@@ -255,7 +261,7 @@ export default {
255261 </script >
256262
257263<style lang="stylus">
258- @import "~xterm/dist /xterm.css"
264+ @import "~xterm/css /xterm.css"
259265 </style >
260266
261267<style lang="stylus" scoped>
0 commit comments