mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-04-11 04:19:26 -07:00
feat(core): add Electron runtime, services, and app composition
This commit is contained in:
48
src/main/runtime/global-shortcuts.ts
Normal file
48
src/main/runtime/global-shortcuts.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import type { Config } from '../../types';
|
||||
import type { ConfiguredShortcuts } from '../../core/utils/shortcut-config';
|
||||
import type { RegisterGlobalShortcutsServiceOptions } from '../../core/services/shortcut';
|
||||
|
||||
export function createGetConfiguredShortcutsHandler(deps: {
|
||||
getResolvedConfig: () => Config;
|
||||
defaultConfig: Config;
|
||||
resolveConfiguredShortcuts: (
|
||||
config: Config,
|
||||
defaultConfig: Config,
|
||||
) => ConfiguredShortcuts;
|
||||
}) {
|
||||
return (): ConfiguredShortcuts =>
|
||||
deps.resolveConfiguredShortcuts(deps.getResolvedConfig(), deps.defaultConfig);
|
||||
}
|
||||
|
||||
export function createRegisterGlobalShortcutsHandler(deps: {
|
||||
getConfiguredShortcuts: () => RegisterGlobalShortcutsServiceOptions['shortcuts'];
|
||||
registerGlobalShortcutsCore: (options: RegisterGlobalShortcutsServiceOptions) => void;
|
||||
onToggleVisibleOverlay: () => void;
|
||||
onToggleInvisibleOverlay: () => void;
|
||||
onOpenYomitanSettings: () => void;
|
||||
isDev: boolean;
|
||||
getMainWindow: RegisterGlobalShortcutsServiceOptions['getMainWindow'];
|
||||
}) {
|
||||
return (): void => {
|
||||
deps.registerGlobalShortcutsCore({
|
||||
shortcuts: deps.getConfiguredShortcuts(),
|
||||
onToggleVisibleOverlay: deps.onToggleVisibleOverlay,
|
||||
onToggleInvisibleOverlay: deps.onToggleInvisibleOverlay,
|
||||
onOpenYomitanSettings: deps.onOpenYomitanSettings,
|
||||
isDev: deps.isDev,
|
||||
getMainWindow: deps.getMainWindow,
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export function createRefreshGlobalAndOverlayShortcutsHandler(deps: {
|
||||
unregisterAllGlobalShortcuts: () => void;
|
||||
registerGlobalShortcuts: () => void;
|
||||
syncOverlayShortcuts: () => void;
|
||||
}) {
|
||||
return (): void => {
|
||||
deps.unregisterAllGlobalShortcuts();
|
||||
deps.registerGlobalShortcuts();
|
||||
deps.syncOverlayShortcuts();
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user