@@ -181,6 +181,34 @@ export default {
181181 },
182182 sink: null ,
183183 keyboard: null ,
184+ // 按键阻塞相关变量
185+ commandKeySym: 65511 ,
186+ controlKeySym: 65507 ,
187+ pressedKeys: new Set (),
188+ // 被阻塞的组合键
189+ BLOCKED_KEY_COMBINATIONS : [
190+ [65511 , 112 ], // command + p
191+ [65511 , 117 ], // command + u
192+ [65511 , 105 ], // command + i
193+ [65511 , 107 ], // command + k
194+ [65511 , 108 ], // command + l
195+ [65511 , 120 ], // command + x
196+ [65511 , 65505 , 112 ], // command + shift + p
197+ [65511 , 65505 , 80 ], // command + shift + p 中文输入下
198+ [65507 , 65511 , 109 ], // control + command + m
199+ [65511 , 80 ] // command + shift + p 中文输入下
200+ ],
201+ // 禁用 HTTP 协议下的组合键
202+ HttpBlockedKeys: [
203+ [65507 , 104 ], // control + h
204+ [65507 , 106 ], // control + j
205+ [65507 , 110 ], // control + n
206+ [65507 , 116 ], // control + t
207+ [65507 , 117 ], // control + u
208+ // [65507, 65505, 80], // control+shift + p
209+ [65507 , 65505 , 79 ], // control+shift + o
210+ [65507 , 65505 , 78 ] // control+shift + n
211+ ],
184212 combinationKeys: [
185213 {
186214 keys: [' 65307' ],
@@ -277,6 +305,11 @@ export default {
277305 isRemoteApp : function () {
278306 return this .session ? this .session .remote_app : false
279307 },
308+ isHttpProtocol : function () {
309+ // 判断是否为HTTP协议,这里需要根据实际情况修改判断逻辑
310+ // 例如可以从session信息或者其他地方获取协议信息
311+ return this .session ? this .session .protocol === ' http' || this .session .protocol === ' https' : false
312+ },
280313 title : function () {
281314 if (this .isRemoteApp ) {
282315 return this .session .remote_app .name
@@ -398,6 +431,33 @@ export default {
398431 }
399432 return ` ${ item} ${ minuteLabel} `
400433 },
434+ // 检查是否为被阻塞的组合键
435+ isBlockedCombination (keysym ) {
436+ if (! this .isRemoteApp ) {
437+ return false
438+ }
439+ if (this .pressedKeys .size < 1 ) {
440+ return false
441+ }
442+ const allPressedKeys = Array .from (this .pressedKeys ).concat (keysym)
443+
444+ if (this .pressedKeys .has (this .commandKeySym )) {
445+ for (const combination of this .BLOCKED_KEY_COMBINATIONS ) {
446+ if (combination .every ((key ) => allPressedKeys .includes (key))) {
447+ return true
448+ }
449+ }
450+ }
451+
452+ if (this .isHttpProtocol && this .pressedKeys .has (this .controlKeySym )) {
453+ for (const combination of this .HttpBlockedKeys ) {
454+ if (combination .every ((key ) => allPressedKeys .includes (key))) {
455+ return true
456+ }
457+ }
458+ }
459+ return false
460+ },
401461 shareDialogClosed () {
402462 this .$log .debug (' share dialog closed' )
403463 this .loading = false
@@ -502,6 +562,8 @@ export default {
502562 window .onblur = () => {
503563 if (this .keyboard !== null ) {
504564 this .keyboard .reset ()
565+ // 清空按下的键记录
566+ this .pressedKeys .clear ()
505567 }
506568 }
507569 },
@@ -1028,10 +1090,22 @@ export default {
10281090 // Keyboard
10291091 const keyboard = new Guacamole.Keyboard (sink .getElement ())
10301092 keyboard .onkeydown = (keysym ) => {
1093+ // 检查是否为被阻塞的组合键
1094+ if (this .isBlockedCombination (keysym)) {
1095+ this .$log .debug (' Blocked key combination detected, keysym:' , keysym)
1096+ return
1097+ }
1098+
1099+ // 记录按下的键
1100+ this .pressedKeys .add (keysym)
1101+
10311102 this .sendEventToLuna (' KEYBOARDEVENT' , ' ' )
10321103 this .client .sendKeyEvent (1 , keysym)
10331104 }
10341105 keyboard .onkeyup = (keysym ) => {
1106+ // 移除释放的键
1107+ this .pressedKeys .delete (keysym)
1108+
10351109 this .sendEventToLuna (' KEYBOARDEVENT' , ' ' )
10361110 this .client .sendKeyEvent (0 , keysym)
10371111 }
0 commit comments