shortcuts dev...

This commit is contained in:
Gabe Yuan
2023-09-07 18:12:45 +08:00
parent da13f5e218
commit d8b0cc4834
8 changed files with 11006 additions and 15315 deletions

22
src/hooks/Shortcut.js Normal file
View File

@@ -0,0 +1,22 @@
import { useCallback } from "react";
import { DEFAULT_SHORTCUTS } from "../config";
import { useSetting } from "./Setting";
export function useShortcut(action) {
const { setting, updateSetting } = useSetting();
const shortcuts = setting?.shortcuts || DEFAULT_SHORTCUTS;
const setShortcut = useCallback(
async (val) => {
await updateSetting({
shortcuts: {
...shortcuts,
[action]: val,
},
});
},
[action, shortcuts, updateSetting]
);
return { shortcut: shortcuts[action] || [], setShortcut };
}