From 5b74a22494c0f055b2d69bb78af7efb73b196881 Mon Sep 17 00:00:00 2001 From: unanmed <1319491857@qq.com> Date: Mon, 22 Apr 2024 12:14:14 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=87=AA=E5=AE=9A=E4=B9=89=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=E7=9A=84=E5=BF=AB=E6=8D=B7=E9=94=AE=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/main/init/toolbar.tsx | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/core/main/init/toolbar.tsx b/src/core/main/init/toolbar.tsx index a7d36da..9e89058 100644 --- a/src/core/main/init/toolbar.tsx +++ b/src/core/main/init/toolbar.tsx @@ -55,9 +55,32 @@ function DefaultTool(props: CustomToolbarProps) { function KeyTool(props: CustomToolbarProps<'hotkey'>) { const { item, toolbar } = props; + + const unwarpAssist = (assist: number) => { + let res = ''; + if (assist & (1 << 0)) { + res += 'Ctrl + '; + } + if (assist & (1 << 1)) { + res += 'Shift + '; + } + if (assist & (1 << 2)) { + res += 'Alt + '; + } + return res; + }; + + const getKeyShow = (key: KeyCode, assist: number) => { + return unwarpAssist(assist) + KeyCodeUtils.toString(key); + }; + return ( - toolbar.emitTool(item.id)}> - {KeyCodeUtils.toString(item.key)} + toolbar.emitTool(item.id)} + > + {getKeyShow(item.key, item.assist)} ); }