39
39
40
40
<script >
41
41
import { 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'
47
44
48
45
const defaultTheme = {
49
46
foreground: ' #2c3e50' ,
@@ -154,7 +151,7 @@ export default {
154
151
},
155
152
156
153
beforeDestroy () {
157
- this .$_terminal .destroy ()
154
+ this .$_terminal .dispose ()
158
155
},
159
156
160
157
methods: {
@@ -165,11 +162,19 @@ export default {
165
162
theme: this .theme ,
166
163
... this .options
167
164
})
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
+
169
174
term .open (this .$refs .render )
170
175
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' ))
173
178
174
179
if (this .autoSize ) {
175
180
this .$nextTick (this .fit )
@@ -226,6 +231,7 @@ export default {
226
231
},
227
232
228
233
handleLink (event , uri ) {
234
+ console .log (' aaa' )
229
235
if (this .openLinks ) {
230
236
window .open (uri, ' _blank' )
231
237
}
@@ -238,7 +244,7 @@ export default {
238
244
239
245
await this .$nextTick ()
240
246
241
- term .fit ()
247
+ this . $_fitAddon .fit ()
242
248
term .element .style .display = ' '
243
249
term .refresh (0 , term .rows - 1 )
244
250
},
@@ -255,7 +261,7 @@ export default {
255
261
</script >
256
262
257
263
<style lang="stylus">
258
- @import "~xterm/dist /xterm.css"
264
+ @import "~xterm/css /xterm.css"
259
265
</style >
260
266
261
267
<style lang="stylus" scoped>
0 commit comments