您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

actions.any.ts 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import { AnyAction } from 'redux';
  2. import {
  3. DISABLE_KEYBOARD_SHORTCUTS,
  4. ENABLE_KEYBOARD_SHORTCUTS,
  5. REGISTER_KEYBOARD_SHORTCUT,
  6. UNREGISTER_KEYBOARD_SHORTCUT
  7. } from './actionTypes';
  8. import { IKeyboardShortcut } from './types';
  9. /**
  10. * Action to register a new shortcut.
  11. *
  12. * @param {IKeyboardShortcut} shortcut - The shortcut to register.
  13. * @returns {AnyAction}
  14. */
  15. export const registerShortcut = (shortcut: IKeyboardShortcut): AnyAction => {
  16. return {
  17. type: REGISTER_KEYBOARD_SHORTCUT,
  18. shortcut
  19. };
  20. };
  21. /**
  22. * Action to unregister a shortcut.
  23. *
  24. * @param {string} character - The character of the shortcut to unregister.
  25. * @param {boolean} altKey - Whether the shortcut used altKey.
  26. * @returns {AnyAction}
  27. */
  28. export const unregisterShortcut = (character: string, altKey = false): AnyAction => {
  29. return {
  30. alt: altKey,
  31. type: UNREGISTER_KEYBOARD_SHORTCUT,
  32. character
  33. };
  34. };
  35. /**
  36. * Action to enable keyboard shortcuts.
  37. *
  38. * @returns {AnyAction}
  39. */
  40. export const enableKeyboardShortcuts = (): AnyAction => {
  41. return {
  42. type: ENABLE_KEYBOARD_SHORTCUTS
  43. };
  44. };
  45. /**
  46. * Action to enable keyboard shortcuts.
  47. *
  48. * @returns {AnyAction}
  49. */
  50. export const disableKeyboardShortcuts = (): AnyAction => {
  51. return {
  52. type: DISABLE_KEYBOARD_SHORTCUTS
  53. };
  54. };