mirror of
https://github.com/cheeaun/phanpy.git
synced 2024-11-25 18:55:44 +03:00
Another guard
This commit is contained in:
parent
a27bdbc69b
commit
72068d9d46
1 changed files with 21 additions and 18 deletions
|
@ -23,26 +23,29 @@ function Shortcuts() {
|
||||||
|
|
||||||
const menuRef = useRef();
|
const menuRef = useRef();
|
||||||
|
|
||||||
const formattedShortcuts = shortcuts.map((pin, i) => {
|
const formattedShortcuts = shortcuts
|
||||||
const { type, ...data } = pin;
|
.map((pin, i) => {
|
||||||
let { path, title, icon } = SHORTCUTS_META[type];
|
const { type, ...data } = pin;
|
||||||
|
if (!SHORTCUTS_META[type]) return null;
|
||||||
|
let { path, title, icon } = SHORTCUTS_META[type];
|
||||||
|
|
||||||
if (typeof path === 'function') {
|
if (typeof path === 'function') {
|
||||||
path = path(data, i);
|
path = path(data, i);
|
||||||
}
|
}
|
||||||
if (typeof title === 'function') {
|
if (typeof title === 'function') {
|
||||||
title = title(data);
|
title = title(data);
|
||||||
}
|
}
|
||||||
if (typeof icon === 'function') {
|
if (typeof icon === 'function') {
|
||||||
icon = icon(data);
|
icon = icon(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
path,
|
path,
|
||||||
title,
|
title,
|
||||||
icon,
|
icon,
|
||||||
};
|
};
|
||||||
});
|
})
|
||||||
|
.filter(Boolean);
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
useHotkeys(['1', '2', '3', '4', '5', '6', '7', '8', '9'], (e, handler) => {
|
useHotkeys(['1', '2', '3', '4', '5', '6', '7', '8', '9'], (e, handler) => {
|
||||||
|
|
Loading…
Reference in a new issue