Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. export const isMac = () => {
  2. return navigator.userAgent.toUpperCase().includes('MAC')
  3. }
  4. const specialKeysNameMap: Record<string, string | undefined> = {
  5. ctrl: '⌘',
  6. alt: '⌥',
  7. shift: '⇧',
  8. }
  9. export const getKeyboardKeyNameBySystem = (key: string) => {
  10. if (isMac())
  11. return specialKeysNameMap[key] || key
  12. return key
  13. }
  14. const specialKeysCodeMap: Record<string, string | undefined> = {
  15. ctrl: 'meta',
  16. }
  17. export const getKeyboardKeyCodeBySystem = (key: string) => {
  18. if (isMac())
  19. return specialKeysCodeMap[key] || key
  20. return key
  21. }
  22. export const isEventTargetInputArea = (target: HTMLElement) => {
  23. if (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA')
  24. return true
  25. if (target.contentEditable === 'true')
  26. return true
  27. }
  28. /**
  29. * Format workflow run identifier using finished_at timestamp
  30. * @param finishedAt - Unix timestamp in seconds
  31. * @param fallbackText - Text to show when finishedAt is not available (default: 'Running')
  32. * @returns Formatted string like " (14:30:25)" or " (Running)"
  33. */
  34. export const formatWorkflowRunIdentifier = (finishedAt?: number, fallbackText = 'Running'): string => {
  35. if (!finishedAt)
  36. return ` (${fallbackText})`
  37. const date = new Date(finishedAt * 1000)
  38. const timeStr = date.toLocaleTimeString([], {
  39. hour: '2-digit',
  40. minute: '2-digit',
  41. second: '2-digit',
  42. })
  43. return ` (${timeStr})`
  44. }