From d10022c9e874eee49c835cb38da86990a2b2b8bd Mon Sep 17 00:00:00 2001 From: unanmed <1319491857@qq.com> Date: Mon, 20 Nov 2023 21:32:35 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AE=9E=E7=8E=B0=E6=8C=89=E9=94=AE?= =?UTF-8?q?=E6=97=B6=E7=9A=84id=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- idea.md | 2 +- src/core/main/custom/hotkey.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/idea.md b/idea.md index b145405..f6f05c8 100644 --- a/idea.md +++ b/idea.md @@ -81,7 +81,7 @@ dam4.png ---- 存档 59 [] 优化插件加载系统 [] 优化 Scroll 组件 [] 重写技能控制系统 -[] 自定义快捷键 +[x] 自定义快捷键 [x] 优化 ui 控制系统 [] 优化游戏进程与渲染进程间的通讯 [] 优化资源分离,音乐放到 bgm 目录下 diff --git a/src/core/main/custom/hotkey.ts b/src/core/main/custom/hotkey.ts index 37c6034..f632d57 100644 --- a/src/core/main/custom/hotkey.ts +++ b/src/core/main/custom/hotkey.ts @@ -99,7 +99,9 @@ export class Hotkey extends EventEmitter { */ realize(id: string, func: HotkeyFunc) { const toSet = Object.values(this.data).filter(v => { - return v.id === id || v.id.split('_').slice(0, -1).join('_') === id; + const split = v.id.split('_'); + const last = !isNaN(Number(split.at(-1))); + return v.id === id || (last && split.slice(0, -1).join('_') === id); }); if (toSet.length === 0) { throw new Error(`Realize nonexistent key '${id}'.`);