🔨 添加长按操作.

This commit is contained in:
lijiahangmax
2025-07-08 17:27:35 +08:00
parent ef146cdaef
commit bf04e8eace
4 changed files with 59 additions and 3 deletions

View File

@@ -47,9 +47,6 @@ public class TerminalSessionVncConfig extends VncConnectConfig implements ITermi
@Schema(description = "logId")
private Long logId;
@Schema(description = "录屏文件路径")
private String recordPath;
@Schema(description = "")
private Integer width;

View File

@@ -0,0 +1,44 @@
<template>
<a-space>
<a-tag v-for="item in GuacdKeyboardItems"
:key="item.name"
:default-checked="session.displayHandler.keyboardDownKeys.includes(item.key)"
checkable
bordered
@check="(checked: boolean) => setChecked(item.key, checked)">
{{ item.name }}
</a-tag>
</a-space>
</template>
<script lang="ts">
export default {
name: 'triggerKeyAction'
};
</script>
<script lang="ts" setup>
import type { IGuacdSession } from '@/views/terminal/interfaces';
import { GuacdKeyboardItems } from '@/views/terminal/types/const';
const props = defineProps<{
session: IGuacdSession;
}>();
// 设置选中
const setChecked = (key: number, checked: boolean) => {
const keys = props.session.displayHandler.keyboardDownKeys;
if (checked) {
keys.push(key);
} else {
const index = keys.findIndex(s => s === key);
if (index !== -1) {
keys.splice(index, 1);
}
}
};
</script>
<style lang="less" scoped>
</style>

View File

@@ -86,6 +86,7 @@ export interface IGuacdSessionDisplayHandler {
displayDpi: number;
autoFit: boolean;
localCursor: boolean;
keyboardDownKeys: number[];
// 初始化
init: () => void;

View File

@@ -12,6 +12,7 @@ export default class GuacdSessionDisplayHandler implements IGuacdSessionDisplayH
public displayDpi: number;
public autoFit: boolean;
public localCursor: boolean;
public keyboardDownKeys: Array<number>;
private display?: Guacamole.Display;
private sink?: Guacamole.InputSink;
@@ -28,6 +29,7 @@ export default class GuacdSessionDisplayHandler implements IGuacdSessionDisplayH
this.displayDpi = 96;
this.autoFit = true;
this.localCursor = true;
this.keyboardDownKeys = [];
this.focusSink = useDebounceFn(() => this.sink?.focus(), 300).bind(this);
}
@@ -187,6 +189,12 @@ export default class GuacdSessionDisplayHandler implements IGuacdSessionDisplayH
return;
}
this.session.client.sendKeyEvent(0, key);
// 触发长按键
if (this.keyboardDownKeys) {
this.keyboardDownKeys.forEach(key => {
this.session.client.sendKeyEvent(0, key);
});
}
}
// 键盘按下事件
@@ -195,6 +203,12 @@ export default class GuacdSessionDisplayHandler implements IGuacdSessionDisplayH
if (!this.session.isWriteable()) {
return;
}
// 触发长按键
if (this.keyboardDownKeys) {
this.keyboardDownKeys.forEach(key => {
this.session.client.sendKeyEvent(1, key);
});
}
this.session.client.sendKeyEvent(1, key);
// // 处理退格
// if (key === 65288) {