From 228f10cc72549da6f216638dda2c9138bfdf5cdb Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Sat, 21 May 2016 21:42:46 +0200 Subject: [PATCH] :arrow_up: tray. --- tray/main.js | 91 +++++++++++++++++++++++------------------------ tray/package.json | 2 +- 2 files changed, 45 insertions(+), 48 deletions(-) diff --git a/tray/main.js b/tray/main.js index f9c00d1..b1a36ac 100644 --- a/tray/main.js +++ b/tray/main.js @@ -1,47 +1,44 @@ -var app = require('app'); -var Tray = require('tray'); -var Menu = require('menu'); -var path = require('path'); -var BrowserWindow = require('browser-window'); - -var iconPath = path.join(__dirname, 'icon.png'); -var appIcon = null; -var win = null; - -app.on('ready', function(){ - win = new BrowserWindow({show: false}); - appIcon = new Tray(iconPath); - var contextMenu = Menu.buildFromTemplate([ - { - label: 'Item1', - type: 'radio', - icon: iconPath - }, - { - label: 'Item2', - submenu: [ - { label: 'submenu1' }, - { label: 'submenu2' } - ] - }, - { - label: 'Item3', - type: 'radio', - checked: true - }, - { - label: 'Toggle DevTools', - accelerator: 'Alt+Command+I', - click: function() { - win.show(); - win.toggleDevTools(); - } - }, - { label: 'Quit', - accelerator: 'Command+Q', - selector: 'terminate:', - } - ]); - appIcon.setToolTip('This is my application.'); - appIcon.setContextMenu(contextMenu); -}); +const {app, Tray, Menu, BrowserWindow} = require('electron'); +const path = require('path'); + +const iconPath = path.join(__dirname, 'icon.png'); +let appIcon = null; +let win = null; + +app.on('ready', function(){ + win = new BrowserWindow({show: false}); + appIcon = new Tray(iconPath); + var contextMenu = Menu.buildFromTemplate([ + { + label: 'Item1', + type: 'radio', + icon: iconPath + }, + { + label: 'Item2', + submenu: [ + { label: 'submenu1' }, + { label: 'submenu2' } + ] + }, + { + label: 'Item3', + type: 'radio', + checked: true + }, + { + label: 'Toggle DevTools', + accelerator: 'Alt+Command+I', + click: function() { + win.show(); + win.toggleDevTools(); + } + }, + { label: 'Quit', + accelerator: 'Command+Q', + selector: 'terminate:', + } + ]); + appIcon.setToolTip('This is my application.'); + appIcon.setContextMenu(contextMenu); +}); diff --git a/tray/package.json b/tray/package.json index 1dedb6b..7114df2 100644 --- a/tray/package.json +++ b/tray/package.json @@ -1,5 +1,5 @@ { "name" : "tray-demo", - "version" : "0.1.0", + "version" : "1.1.0", "main" : "main.js" }