2018-07-21 05:34:30 +00:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<div class="text-xs font-mono">
|
2018-07-21 22:20:37 +00:00
|
|
|
<div class="rounded-t p-2 bg-black overflow-scroll w-full" style="min-height: 16rem;max-height:64rem;">
|
|
|
|
<div class="mb-2 text-grey-light" ref="terminal"></div>
|
2018-07-21 07:04:56 +00:00
|
|
|
</div>
|
|
|
|
<div class="rounded-b bg-grey-darkest text-white flex">
|
|
|
|
<div class="flex-no-shrink p-2">
|
|
|
|
<span class="font-bold">$</span>
|
|
|
|
</div>
|
|
|
|
<div class="w-full">
|
2018-07-21 22:20:37 +00:00
|
|
|
<input type="text" aria-label="Send console command" class="bg-transparent text-white p-2 pl-0 w-full" placeholder="enter command and press enter to send"
|
|
|
|
ref="command"
|
|
|
|
v-model="command"
|
|
|
|
v-on:keyup.enter="sendCommand"
|
|
|
|
>
|
2018-07-21 07:04:56 +00:00
|
|
|
</div>
|
2018-07-21 05:34:30 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2018-07-21 22:20:37 +00:00
|
|
|
import { Terminal } from 'xterm';
|
|
|
|
import * as TerminalFit from 'xterm/lib/addons/fit/fit';
|
|
|
|
|
|
|
|
Terminal.applyAddon(TerminalFit);
|
2018-07-21 06:45:07 +00:00
|
|
|
|
2018-07-21 05:34:30 +00:00
|
|
|
export default {
|
|
|
|
name: 'console-page',
|
|
|
|
|
2018-07-21 22:20:37 +00:00
|
|
|
mounted: function () {
|
|
|
|
this.terminal.open(this.$refs.terminal);
|
|
|
|
this.terminal.fit();
|
|
|
|
|
|
|
|
this.$parent.$on('console', data => {
|
|
|
|
this.terminal.writeln(data);
|
|
|
|
});
|
2018-07-21 06:45:07 +00:00
|
|
|
},
|
2018-07-21 22:20:37 +00:00
|
|
|
|
|
|
|
data: function () {
|
|
|
|
return {
|
|
|
|
terminal: new Terminal({
|
|
|
|
disableStdin: true,
|
|
|
|
allowTransparency: true,
|
|
|
|
fontSize: 12,
|
|
|
|
fontFamily: 'Menlo,Monaco,Consolas,monospace',
|
|
|
|
rows: 30,
|
|
|
|
theme: {
|
|
|
|
background: 'transparent',
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
command: '',
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
sendCommand: function () {
|
|
|
|
this.$parent.$emit('send-command', this.command);
|
|
|
|
this.command = '';
|
|
|
|
}
|
|
|
|
}
|
2018-07-21 05:34:30 +00:00
|
|
|
};
|
|
|
|
</script>
|
2018-07-21 22:20:37 +00:00
|
|
|
|
|
|
|
<style lang="postcss">
|
|
|
|
@import "~xterm/src/xterm.css";
|
|
|
|
</style>
|