add electron-debug

This commit is contained in:
Damillora 2017-07-03 18:55:23 +07:00
parent 49be67aae6
commit 68a352120d
2 changed files with 11 additions and 82 deletions

90
main.js
View File

@ -1,98 +1,24 @@
const {app, Menu, BrowserWindow} = require('electron')
const path = require('path')
const url = require('url')
const themenu = require('./menu')
const setdock = require('./dock')
const ipc = require('electron').ipcMain;
require('electron-debug')();
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let win
const template = [
{
label: 'Edit',
submenu: [
{role: 'undo'},
{role: 'redo'},
{type: 'separator'},
{role: 'cut'},
{role: 'copy'},
{role: 'paste'},
{role: 'pasteandmatchstyle'},
{role: 'delete'},
{role: 'selectall'}
]
},
{
label: 'View',
submenu: [
{role: 'reload'},
{role: 'forcereload'},
{type: 'separator'},
{role: 'resetzoom'},
{role: 'zoomin'},
{role: 'zoomout'},
{type: 'separator'},
{role: 'togglefullscreen'}
]
},
{
role: 'window',
submenu: [
{role: 'minimize'},
{role: 'close'}
]
},
]
if (process.platform === 'darwin') {
template.unshift({
label: app.getName(),
submenu: [
{role: 'about'},
{type: 'separator'},
{role: 'services', submenu: []},
{type: 'separator'},
{role: 'hide'},
{role: 'hideothers'},
{role: 'unhide'},
{type: 'separator'},
{role: 'quit'}
]
})
// Edit menu
template[1].submenu.push(
{type: 'separator'},
{
label: 'Speech',
submenu: [
{role: 'startspeaking'},
{role: 'stopspeaking'}
]
}
)
// Window menu
template[3].submenu = [
{role: 'close'},
{role: 'minimize'},
{role: 'zoom'},
{type: 'separator'},
{role: 'front'}
]
}
const dockMenu = Menu.buildFromTemplate([
{label: 'Reload', click () { win.reload() }}
])
const options = {userAgent: 'Mozilla/5.0 (Linux; Android 7.1.1; Nexus 6 Build/N6F27E) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.83 Mobile Safari/537.36'};
function createWindow () {
// Create the browser window.
const menu = Menu.buildFromTemplate(template)
app.dock.setMenu(dockMenu);
Menu.setApplicationMenu(menu);
win = new BrowserWindow({width: 480, height: 600,icon: path.join(__dirname, 'ic_launcher.png')})
setdock.setdock(win)
Menu.setApplicationMenu(themenu(win));
// and load the index.html of the app.
win.loadURL('http://pf.gree.net/58737',{userAgent: 'Mozilla/5.0 (Linux; Android 7.1.1; Nexus 6 Build/N6F27E) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.83 Mobile Safari/537.36'});
win.loadURL('http://pf.gree.net/58737',options);
// Open the DevTools.
// Emitted when the window is closed.

View File

@ -6,5 +6,8 @@
"main": "main.js",
"devDependencies": {
"electron": "^1.6.11"
},
"dependencies": {
"electron-debug": "^1.2.0"
}
}