-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from fukajun/set_icon
Set icon and version up electron
- Loading branch information
Showing
19 changed files
with
212 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
node_modules | ||
/main.js | ||
/index.js | ||
/preload.js | ||
.DS_Store | ||
/245cloud* | ||
/dist/* | ||
/build/* | ||
/*.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/bash | ||
DIST_DIR=./dist | ||
BUILD_DIR=./build | ||
|
||
PKG_VERSION=`node -pe 'require("./package.json").version'` | ||
APP_NAME=`node -pe 'require("./package.json").name'` | ||
|
||
echo "version: ${PKG_VERSION}" | ||
|
||
# Clean npm_modules, *.js, *.html ... | ||
rm -rf ${BUILD_DIR}/* | ||
|
||
gulp build | ||
|
||
cp ./package.json ${BUILD_DIR} | ||
pushd ${BUILD_DIR} && npm install --production && popd | ||
|
||
electron-packager ${BUILD_DIR} "${APP_NAME}" \ | ||
--overwrite \ | ||
--prune \ | ||
--platform=darwin \ | ||
--arch=x64 \ | ||
--electron-version=1.6.6 \ | ||
--build-version=${PKG_VERSION} \ | ||
--icon=./icon.icns \ | ||
--out=./${DIST_DIR} | ||
|
||
cd ${DIST_DIR} && zip -r -y -q \ | ||
"../${APP_NAME}-${PKG_VERSION}-darwin-x64.zip" \ | ||
"./${APP_NAME}-darwin-x64" |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,132 @@ | ||
import { ipcRenderer } from 'electron'; | ||
// | ||
// Renderer | ||
|
||
document.addEventListener("DOMContentLoaded", ()=> { | ||
var quitIcon = document.querySelector('.js-quit-icon') | ||
var reloadIcon = document.querySelector('.js-reload-icon') | ||
quitIcon.addEventListener('click', ()=> { | ||
if(!confirm('終了しますか?')) { | ||
return | ||
} | ||
ipcRenderer.send('quit') | ||
// MainProcess | ||
'use strict'; | ||
|
||
const ACTIVE_MENUBAR_ICON = __dirname + '/images/active.png' | ||
const INACTIVE_MENUBAR_ICON = __dirname + '/images/inactive.png' | ||
const NOTIFY_ICON = __dirname + '/images/notify_icon.png' | ||
import menubar from 'menubar'; | ||
import { app, ipcMain, globalShortcut, Menu } from 'electron'; | ||
import notifier from 'node-notifier'; | ||
import path from 'path' | ||
|
||
const request = require('request'); | ||
const mb = menubar({ icon: ACTIVE_MENUBAR_ICON, dir: __dirname }); | ||
console.log(__dirname) | ||
|
||
//const mb = menubar({ icon: ACTIVE_MENUBAR_ICON }); | ||
mb.setOption('width', 500) | ||
|
||
const switchIconUnread = ()=> { | ||
mb.tray.setImage(ACTIVE_MENUBAR_ICON ) | ||
} | ||
const switchIconRead = ()=> { | ||
mb.tray.setImage(ACTIVE_MENUBAR_ICON ) | ||
} | ||
const setTrayTitle = (title)=> { | ||
mb.tray.setTitle(title) | ||
} | ||
const initMenu = ()=> { | ||
var template = [{ | ||
label: "Application", | ||
submenu: [ | ||
{ label: "About Application", selector: "orderFrontStandardAboutPanel:" }, | ||
{ type: "separator" }, | ||
{ label: "Quit", accelerator: "Command+Q", click: function() { app.quit(); }} | ||
]}, { | ||
label: "Edit", | ||
submenu: [ | ||
{ label: "Undo", accelerator: "CmdOrCtrl+Z", selector: "undo:" }, | ||
{ label: "Redo", accelerator: "Shift+CmdOrCtrl+Z", selector: "redo:" }, | ||
{ type: "separator" }, | ||
{ label: "Cut", accelerator: "CmdOrCtrl+X", selector: "cut:" }, | ||
{ label: "Copy", accelerator: "CmdOrCtrl+C", selector: "copy:" }, | ||
{ label: "Paste", accelerator: "CmdOrCtrl+V", selector: "paste:" }, | ||
{ label: "Select All", accelerator: "CmdOrCtrl+A", selector: "selectAll:" } | ||
]} | ||
]; | ||
|
||
Menu.setApplicationMenu(Menu.buildFromTemplate(template)); | ||
} | ||
|
||
const KEY_POMO_START = 'ctrl+shift+m' | ||
const KEY_TOGGLE_WINDOW = 'ctrl+shift+p' | ||
|
||
mb.on('ready', function ready () { | ||
|
||
var closeWindow = ()=> { | ||
mb.hideWindow(); | ||
} | ||
var openWindow = ()=> { | ||
mb.showWindow(mb.tray.getBounds()); | ||
} | ||
|
||
ipcMain.on('renderer_init', function(event, arg) { | ||
|
||
var sender = event.sender | ||
|
||
// | ||
// Toggle window show and hide | ||
// | ||
// NOTE: Unregister shorcut key event. | ||
// Shortcut key is not left to the old webview after reload. | ||
globalShortcut.unregister(KEY_TOGGLE_WINDOW); | ||
globalShortcut.register(KEY_TOGGLE_WINDOW, ()=> { | ||
if(mb.window.isVisible()) { | ||
closeWindow(); | ||
} else { | ||
openWindow(); | ||
} | ||
}); | ||
|
||
// | ||
// Start pomodoro recently track | ||
globalShortcut.unregister(KEY_POMO_START); | ||
globalShortcut.register(KEY_POMO_START, ()=> { | ||
sender.send('pomo_start') | ||
}); | ||
}); | ||
|
||
// | ||
// Setting ipc event | ||
ipcMain.on('notify', (event, title, message)=> { | ||
notifier.notify({ | ||
title: title, | ||
icon: NOTIFY_ICON, | ||
message: message | ||
}) | ||
}); | ||
ipcMain.on('show_window', (event, arg)=> { | ||
openWindow(); | ||
}); | ||
ipcMain.on('set_title', (event, text)=> { | ||
setTrayTitle(text.trim()) | ||
}); | ||
ipcMain.on('mark_unread', (event, arg)=> { | ||
switchIconUnread(); | ||
}); | ||
ipcMain.on('quit', (event, arg)=> { | ||
app.quit(); | ||
}); | ||
ipcMain.on('reload', (event, arg)=> { | ||
let browserWindow = event.sender; | ||
browserWindow.reload() | ||
}); | ||
notifier.on('click', (event, arg)=> { | ||
mb.showWindow(); | ||
}); | ||
mb.on('show', ()=> { | ||
setTimeout(()=> { | ||
switchIconRead(); | ||
}, 1000); | ||
}) | ||
reloadIcon.addEventListener('click', ()=> { | ||
if(!confirm('リロードしますか?')) { | ||
return | ||
} | ||
ipcRenderer.send('reload') | ||
mb.on('hide', ()=> { | ||
switchIconRead(); | ||
}) | ||
console.log('init') | ||
|
||
mb.showWindow(); | ||
mb.hideWindow(); | ||
// NOTE: Comment out for display Dev tool | ||
initMenu(); | ||
switchIconUnread(); | ||
}) |
Oops, something went wrong.