This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const controlKeys = ['control', 'option', 'meta', 'shift'] | |
| const KeyBindingMapKey = 'keyBindings' | |
| /** | |
| * @typedef {(e: KeyboardEvent) => void} KeyboardEventHandler | |
| * @typedef {Map<string, KeyboardEventHandler> } BindingMap 按键映射表 | |
| */ | |
| /** | |
| * 使用快捷键 | |
| * |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { useMemo, useSyncExternalStore } from 'React' | |
| const useDark = () => { | |
| const match = useMemo(() => window.matchMedia('(prefers-color-scheme: dark)'), []) | |
| // Handlers | |
| const subscribe = (cb: () => void) => { | |
| match.addEventListener('change', cb) | |
| return () => match.removeEventListener('change', cb) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| print("Hello, world") | |
| // Prints "Hello, world | |
| // Simple Values | |
| var myVariable = 18 | |
| myVariable = 33 | |
| let myConstant = 18 | |
| //print(myVariable, myConstant) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const nodes = [ | |
| { id: 1 }, | |
| { id: 2, pid: 1 }, | |
| { id: 3, pid: 1 }, | |
| { id: 4, pid: 2 }, | |
| { id: 5, pid: 2 }, | |
| { id: 6, pid: 3 }, | |
| { id: 7, pid: 3 }, | |
| { id: 8, pid: 3 }, | |
| ] |