How to use the electron-util.platform function in electron-util

To help you get started, we’ve selected a few electron-util examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github timche / gmail-desktop / src / helpers.ts View on Github external
import * as path from 'path'
import { nativeImage, NativeImage } from 'electron'
import { platform as selectPlatform, is } from 'electron-util'

// URL: `mail.google.com/mail/u/`
export function getUrlAccountId(url: string): null | string {
  const accountIdRegExp = /mail\/u\/(\d+)/
  const res = accountIdRegExp.exec(url)
  return res && res[1]
}

export const platform = selectPlatform({
  macos: 'macos',
  linux: 'linux',
  windows: 'windows'
})

/**
 * Create a tray icon.
 *
 * @param unread True to create the unead icon; false to create the normal icon.
 */
export function createTrayIcon(unread: boolean): NativeImage {
  let iconFileName

  if (is.macos) {
    iconFileName = 'tray-icon.macos.Template.png'
  } else {
github npezza93 / archipelago / app / renderer / app / hamburger-menu.jsx View on Github external
initialState() {
    return platform({
      macos: {},
      default: {backgroundColor: this.backgroundColor}
    })
  }
github npezza93 / archipelago / app / renderer / traffic-lights.jsx View on Github external
render() {
    return platform({
      macos: null,
      default: (
        <div>
          
          
          
        </div>
      )
    })
  }
}
github npezza93 / archipelago / app / common / traffic-lights.js View on Github external
render() {
    return platform({
      macos: null,
      default: createElement(
        'div',
        {},
        createElement(Minimize), createElement(Maximize), createElement(Close)
      )
    })
  }
}
github npezza93 / archipelago / app / main / utils.js View on Github external
newWindow.removeAllListeners('context-menu')
    }
  })

  newWindow.once('ready-to-show', newWindow.show)

  newWindow.webContents.once('did-finish-load', () => {
    if (newWindow.title) {
      newWindow.setTitle(newWindow.title)
    }
  })

  return newWindow
}

export const accelerators = platform({
  macos: darwinAccelerators,
  linux: linuxAccelerators,
  windows: windowsAccelerators
})

const loadUrl = (browserWindow, anchor) => {
  let url

  if (is.development && process.env.ELECTRON_WEBPACK_WDS_PORT) {
    url = `http://localhost:${process.env.ELECTRON_WEBPACK_WDS_PORT}#${anchor}`
  } else if (is.development && !process.env.ELECTRON_WEBPACK_WDS_PORT) {
    url = `file://${__dirname}/../renderer/index.html#${anchor}`
  } else {
    url = `file:///${__dirname}/index.html#${anchor}`
  }
github npezza93 / archipelago / app / traffic-lights / all.js View on Github external
render() {
    return platform({
      macos: null,
      default: createElement(
        'div',
        {},
        createElement(Minimize), createElement(Maximize), createElement(Close)
      )
    })
  }
}
github npezza93 / archipelago / app / renderer / app / hamburger-menu.jsx View on Github external
render() {
    return platform({
      macos: null,
      default: 
        <div style="{{background:"></div>
        <div style="{{background:"></div>
        <div style="{{background:"></div>
      
    })
  }
github npezza93 / archipelago / app / main / profile-manager.js View on Github external
get defaultKeybindings() {
    return platform({
      linux: [
        {keystroke: 'home', command: '\\x1bOH'},
        {keystroke: 'end', command: '\\x1bOF'},
        {keystroke: 'ctrl-backspace', command: '\\x1b\\x08'},
        {keystroke: 'ctrl-del', command: '\\x1bd'},
        {keystroke: 'ctrl-home', command: '\\x1bw'},
        {keystroke: 'ctrl-end', command: '\\x10B'}
      ],
      windows: [
        {keystroke: 'home', command: '\\x1bOH'},
        {keystroke: 'end', command: '\\x1bOF'},
        {keystroke: 'ctrl-backspace', command: '\\x1b\\x08'},
        {keystroke: 'cltr-del', command: '\\x1bd'},
        {keystroke: 'ctrl-home', command: '\\x1bw'},
        {keystroke: 'ctrl-end', command: '\\x10B'}
      ],
github dreamnettech / dreamtime / src / electron / src / modules / tools / fs.js View on Github external
export function extractSeven(path, destinationPath) {
  const def = deferred()

  let pathTo7zip

  if (is.development) {
    pathTo7zip = sevenBin.path7za
  } else {
    const binName = platform({
      macos: '7za',
      linux: '7za',
      windows: '7za.exe',
    })

    pathTo7zip = getAppResourcesPath('7zip-bin', binName)
  }

  const seven = extractFull(path, destinationPath, {
    $bin: pathTo7zip,
    recursive: true,
  })

  seven.on('end', () => {
    def.resolve()
  })