mirror of
https://github.com/unanmed/HumanBreak.git
synced 2026-11-15 19:34:32 +08:00
fix: 实现按键时的id判断
This commit is contained in:
1 parent
a2639e63db
commit
d10022c9e8
2 files changed
+4
-2
No files matched your search
@@ -99,7 +99,9 @@ export class Hotkey extends EventEmitter<HotkeyEvent> {
|
||||
*/
|
||||
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}'.`);
|
||||
|
||||
Reference in new issue
Block a user