mirror of
https://github.com/antebudimir/feishin.git
synced 2026-01-02 10:53:33 +00:00
Add browser forward/back hotkeys (#155)
This commit is contained in:
parent
0cba405b45
commit
8cbc25a932
4 changed files with 17 additions and 2 deletions
|
|
@ -11,6 +11,8 @@ import { SettingsOptions } from '/@/renderer/features/settings/components/settin
|
||||||
const ipc = isElectron() ? window.electron.ipc : null;
|
const ipc = isElectron() ? window.electron.ipc : null;
|
||||||
|
|
||||||
const BINDINGS_MAP: Record<BindingActions, string> = {
|
const BINDINGS_MAP: Record<BindingActions, string> = {
|
||||||
|
browserBack: 'Browser back',
|
||||||
|
browserForward: 'Browser forward',
|
||||||
globalSearch: 'Global search',
|
globalSearch: 'Global search',
|
||||||
localSearch: 'In-page search',
|
localSearch: 'In-page search',
|
||||||
next: 'Next track',
|
next: 'Next track',
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,17 @@
|
||||||
import { Divider, Stack } from '@mantine/core';
|
import { Divider, Stack } from '@mantine/core';
|
||||||
|
import isElectron from 'is-electron';
|
||||||
import { WindowHotkeySettings } from './window-hotkey-settings';
|
import { WindowHotkeySettings } from './window-hotkey-settings';
|
||||||
import { HotkeyManagerSettings } from '/@/renderer/features/settings/components/hotkeys/hotkey-manager-settings';
|
import { HotkeyManagerSettings } from '/@/renderer/features/settings/components/hotkeys/hotkey-manager-settings';
|
||||||
|
|
||||||
export const HotkeysTab = () => {
|
export const HotkeysTab = () => {
|
||||||
return (
|
return (
|
||||||
<Stack spacing="md">
|
<Stack spacing="md">
|
||||||
|
{isElectron() && (
|
||||||
|
<>
|
||||||
<WindowHotkeySettings />
|
<WindowHotkeySettings />
|
||||||
<Divider />
|
<Divider />
|
||||||
|
</>
|
||||||
|
)}
|
||||||
<HotkeyManagerSettings />
|
<HotkeyManagerSettings />
|
||||||
</Stack>
|
</Stack>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import { lazy } from 'react';
|
import { lazy } from 'react';
|
||||||
import isElectron from 'is-electron';
|
import isElectron from 'is-electron';
|
||||||
|
import { useNavigate } from 'react-router';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import {
|
import {
|
||||||
useWindowSettings,
|
useWindowSettings,
|
||||||
|
|
@ -54,6 +55,7 @@ export const DefaultLayout = ({ shell }: DefaultLayoutProps) => {
|
||||||
const { windowBarStyle } = useWindowSettings();
|
const { windowBarStyle } = useWindowSettings();
|
||||||
const { opened, ...handlers } = useCommandPalette();
|
const { opened, ...handlers } = useCommandPalette();
|
||||||
const { bindings } = useHotkeySettings();
|
const { bindings } = useHotkeySettings();
|
||||||
|
const navigate = useNavigate();
|
||||||
const localSettings = isElectron() ? window.electron.localSettings : null;
|
const localSettings = isElectron() ? window.electron.localSettings : null;
|
||||||
const settings = useGeneralSettings();
|
const settings = useGeneralSettings();
|
||||||
const { setSettings } = useSettingsStoreActions();
|
const { setSettings } = useSettingsStoreActions();
|
||||||
|
|
@ -78,6 +80,8 @@ export const DefaultLayout = ({ shell }: DefaultLayoutProps) => {
|
||||||
|
|
||||||
useHotkeys([
|
useHotkeys([
|
||||||
[bindings.globalSearch.hotkey, () => handlers.open()],
|
[bindings.globalSearch.hotkey, () => handlers.open()],
|
||||||
|
[bindings.browserBack.hotkey, () => navigate(-1)],
|
||||||
|
[bindings.browserForward.hotkey, () => navigate(1)],
|
||||||
...(isElectron() ? zoomHotkeys : []),
|
...(isElectron() ? zoomHotkeys : []),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -81,6 +81,8 @@ type MpvSettings = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export enum BindingActions {
|
export enum BindingActions {
|
||||||
|
BROWSER_BACK = 'browserBack',
|
||||||
|
BROWSER_FORWARD = 'browserForward',
|
||||||
GLOBAL_SEARCH = 'globalSearch',
|
GLOBAL_SEARCH = 'globalSearch',
|
||||||
LOCAL_SEARCH = 'localSearch',
|
LOCAL_SEARCH = 'localSearch',
|
||||||
MUTE = 'volumeMute',
|
MUTE = 'volumeMute',
|
||||||
|
|
@ -221,6 +223,8 @@ const initialState: SettingsState = {
|
||||||
},
|
},
|
||||||
hotkeys: {
|
hotkeys: {
|
||||||
bindings: {
|
bindings: {
|
||||||
|
browserBack: { allowGlobal: false, hotkey: '', isGlobal: false },
|
||||||
|
browserForward: { allowGlobal: false, hotkey: '', isGlobal: false },
|
||||||
globalSearch: { allowGlobal: false, hotkey: 'mod+k', isGlobal: false },
|
globalSearch: { allowGlobal: false, hotkey: 'mod+k', isGlobal: false },
|
||||||
localSearch: { allowGlobal: false, hotkey: 'mod+f', isGlobal: false },
|
localSearch: { allowGlobal: false, hotkey: 'mod+f', isGlobal: false },
|
||||||
next: { allowGlobal: true, hotkey: '', isGlobal: false },
|
next: { allowGlobal: true, hotkey: '', isGlobal: false },
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue