Harvester: Refactor Novnc

This commit is contained in:
yuzeng 2022-06-23 11:42:28 +08:00 committed by n313893254
parent abad506537
commit f3ee98c33d
5 changed files with 19 additions and 19 deletions

View File

@ -5865,7 +5865,7 @@ harvester:
down: No events in the past hour down: No events in the past hour
console: console:
down: This Virtual Machine is down. Please start it to access its console. down: This Virtual Machine is down. Please start it to access its console.
shortKeys: Short Keys shortKeys: Shortcut Keys
volume: volume:
label: Volumes label: Volumes

View File

@ -28,16 +28,16 @@ export default {
methods: { methods: {
keysDown(key, pos) { keysDown(key, pos) {
this.addKeys(key, pos); this.addKeys({ key, pos });
this.$emit('sendKeys', this.path); this.$emit('sendKeys');
}, },
addKeys(key, pos) { addKeys({ key, pos }) {
this.path.splice(pos, this.path.length - pos, key); this.$emit('update', { key, pos });
}, },
sendKeys() { sendKeys() {
this.$emit('sendKeys', this.path); this.$emit('sendKeys');
}, },
getOpenStatus(key, pos) { getOpenStatus(key, pos) {
@ -56,10 +56,10 @@ export default {
trigger="click" trigger="click"
:container="false" :container="false"
> >
<span :class="{ open: getOpenStatus(key, pos) }" class="p-10 hand" @click="addKeys(key, pos)">{{ item.label }}</span> <span :class="{ open: getOpenStatus(key, pos) }" class="p-10 hand" @click="addKeys({ key, pos })">{{ item.label }}</span>
<template slot="popover"> <template slot="popover">
<novnc-console-item :items="item.keys" :path="path" :pos="pos+1" @sendKeys="sendKeys" /> <novnc-console-item :items="item.keys" :path="path" :pos="pos+1" @update="addKeys" @sendKeys="sendKeys" />
</template> </template>
</v-popover> </v-popover>
@ -68,7 +68,7 @@ export default {
</ul> </ul>
</template> </template>
<style lang="scss"> <style lang="scss" scoped>
.combination-keys__container { .combination-keys__container {
max-width: 60px; max-width: 60px;

View File

@ -1,7 +1,7 @@
<script> <script>
import KeyTable from '@novnc/novnc/core/input/keysym'; import KeyTable from '@novnc/novnc/core/input/keysym';
import NovncConsole from '@/shell/components/NovncConsole'; import NovncConsole from '@/shell/components/novnc/NovncConsole';
import NovncConsoleItem from '@/shell/components/NovncConsoleItem'; import NovncConsoleItem from '@/shell/components/novnc/NovncConsoleItem';
import { HCI } from '@/shell/config/types'; import { HCI } from '@/shell/config/types';
const SHORT_KEYS = { const SHORT_KEYS = {
@ -173,6 +173,10 @@ export default {
this.$refs.novncConsole.disconnect(); this.$refs.novncConsole.disconnect();
}, },
update({ key, pos }) {
this.keysRecord.splice(pos, this.keysRecord.length - pos, key);
},
sendKeys() { sendKeys() {
this.keysRecord.forEach((key) => { this.keysRecord.forEach((key) => {
this.$refs.novncConsole.sendKey(this.allKeys[key].value, key, true); this.$refs.novncConsole.sendKey(this.allKeys[key].value, key, true);
@ -209,7 +213,7 @@ export default {
</button> </button>
<template slot="popover"> <template slot="popover">
<novnc-console-item :items="keymap" :path="keysRecord" :pos="0" @sendKeys="sendKeys" /> <novnc-console-item :items="keymap" :path="keysRecord" :pos="0" @update="update" @sendKeys="sendKeys" />
</template> </template>
</v-popover> </v-popover>
@ -225,17 +229,13 @@ export default {
</div> </div>
</template> </template>
<style lang="scss"> <style lang="scss" scoped>
.vm-console { .vm-console {
height: 100%; height: 100%;
display: grid; display: grid;
grid-template-rows: 30px auto; grid-template-rows: 30px auto;
} }
.vm-console, .vm-console > DIV, .vm-console > DIV > DIV {
height: 100%;
}
.combination-keys { .combination-keys {
background: rgb(40, 40, 40); background: rgb(40, 40, 40);
} }

View File

@ -1,6 +1,6 @@
<script> <script>
import { HCI } from '@shell/config/types'; import { HCI } from '@shell/config/types';
import NovncConsoleWrapper from '@shell/components/NovncConsoleWrapper'; import NovncConsoleWrapper from '@shell/components/novnc/NovncConsoleWrapper';
import Loading from '@shell/components/Loading'; import Loading from '@shell/components/Loading';
export default { export default {
@ -46,7 +46,7 @@ export default {
</template> </template>
<style> <style>
HTML, BODY, MAIN, #__nuxt, #__layout, #app { HTML, BODY, MAIN, #__nuxt, #__layout, #app, .vm-console, .vm-console > DIV, .vm-console > DIV > DIV {
height: 100%; height: 100%;
} }
</style> </style>