コードスタイルの修正
This commit is contained in:
28
app-menu.js
28
app-menu.js
@@ -2,12 +2,8 @@
|
|||||||
|
|
||||||
var Menu = require('menu');
|
var Menu = require('menu');
|
||||||
|
|
||||||
var createMenu = function(mainWindow){
|
|
||||||
return Menu.buildFromTemplate(createTemplate(mainWindow));
|
|
||||||
}
|
|
||||||
|
|
||||||
var createTemplate = function(mainWindow){
|
var createTemplate = function(mainWindow){
|
||||||
var first_menu_name = (process.platform == 'darwin') ? require('app').getName() : 'File';
|
var first_menu_name = (process.platform === 'darwin') ? require('app').getName() : 'File';
|
||||||
var template = [];
|
var template = [];
|
||||||
template.push({
|
template.push({
|
||||||
label: first_menu_name,
|
label: first_menu_name,
|
||||||
@@ -79,32 +75,40 @@ var createTemplate = function(mainWindow){
|
|||||||
{
|
{
|
||||||
label: 'Toggle Full Screen',
|
label: 'Toggle Full Screen',
|
||||||
accelerator: (function() {
|
accelerator: (function() {
|
||||||
if (process.platform == 'darwin')
|
if (process.platform === 'darwin'){
|
||||||
return 'Ctrl+Command+F';
|
return 'Ctrl+Command+F';
|
||||||
else
|
} else {
|
||||||
return 'F11';
|
return 'F11';
|
||||||
|
}
|
||||||
})(),
|
})(),
|
||||||
click: function(item, focusedWindow) {
|
click: function(item, focusedWindow) {
|
||||||
if (focusedWindow)
|
if (focusedWindow) {
|
||||||
focusedWindow.setFullScreen(!focusedWindow.isFullScreen());
|
focusedWindow.setFullScreen(!focusedWindow.isFullScreen());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Toggle Developer Tools',
|
label: 'Toggle Developer Tools',
|
||||||
accelerator: (function() {
|
accelerator: (function() {
|
||||||
if (process.platform == 'darwin')
|
if (process.platform === 'darwin') {
|
||||||
return 'Alt+Command+I';
|
return 'Alt+Command+I';
|
||||||
else
|
} else {
|
||||||
return 'Ctrl+Shift+I';
|
return 'Ctrl+Shift+I';
|
||||||
|
}
|
||||||
})(),
|
})(),
|
||||||
click: function(item, focusedWindow) {
|
click: function(item, focusedWindow) {
|
||||||
if (focusedWindow)
|
if (focusedWindow) {
|
||||||
focusedWindow.toggleDevTools();
|
focusedWindow.toggleDevTools();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
return template;
|
return template;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
var createMenu = function(mainWindow){
|
||||||
|
return Menu.buildFromTemplate(createTemplate(mainWindow));
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = { createMenu: createMenu };
|
module.exports = { createMenu: createMenu };
|
||||||
|
8
main.js
8
main.js
@@ -14,7 +14,7 @@ var willAppQuit = false;
|
|||||||
app.on('window-all-closed', function() {
|
app.on('window-all-closed', function() {
|
||||||
// On OS X it is common for applications and their menu bar
|
// On OS X it is common for applications and their menu bar
|
||||||
// to stay active until the user quits explicitly with Cmd + Q
|
// to stay active until the user quits explicitly with Cmd + Q
|
||||||
if (process.platform != 'darwin') {
|
if (process.platform !== 'darwin') {
|
||||||
app.quit();
|
app.quit();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -34,7 +34,7 @@ app.on('activate', function(event){
|
|||||||
|
|
||||||
app.on('before-quit', function(){
|
app.on('before-quit', function(){
|
||||||
willAppQuit = true;
|
willAppQuit = true;
|
||||||
})
|
});
|
||||||
|
|
||||||
// This method will be called when Electron has finished
|
// This method will be called when Electron has finished
|
||||||
// initialization and is ready to create browser windows.
|
// initialization and is ready to create browser windows.
|
||||||
@@ -79,12 +79,12 @@ app.on('ready', function() {
|
|||||||
// Drag&drop is allowed in webview of index.html.
|
// Drag&drop is allowed in webview of index.html.
|
||||||
mainWindow.webContents.on('will-navigate', function(event, url){
|
mainWindow.webContents.on('will-navigate', function(event, url){
|
||||||
var dirname = __dirname;
|
var dirname = __dirname;
|
||||||
if (process.platform == 'win32'){
|
if (process.platform === 'win32'){
|
||||||
dirname = '/' + dirname.replace(/\\/g, '/');
|
dirname = '/' + dirname.replace(/\\/g, '/');
|
||||||
}
|
}
|
||||||
|
|
||||||
var index = url.indexOf('file://' + dirname);
|
var index = url.indexOf('file://' + dirname);
|
||||||
if(index != 0){
|
if(index !== 0){
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user