This repository has been archived on 2019-03-08. You can view files and clone it, but cannot push or open issues or pull requests.
MillionHopes/menu.js
2017-07-03 23:56:29 +07:00

95 lines
2.3 KiB
JavaScript

const { app, Menu } = require('electron');
const navi = require('./dock');
const prefman = require('./preferencemanager');
const ipc = require('electron').ipcMain;
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'};
module.exports = function(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'}
]
},
{
label: 'Go',
submenu: navi.navitemplate(win)
},
{
role: 'window',
submenu: [
{role: 'minimize'},
{role: 'close'}
]
}
]
if (process.platform === 'darwin') {
template.unshift({
label: app.getName(),
submenu: [
{label: 'About Million Hopes',click(){prefman.showAbout()}},
{label: "Clear Cookies / Log Out",click(){win.webContents.session.clearStorageData({storages: "cookies"});win.loadURL("http://pf.gree.net/58737",options)}},
{type: 'separator'},
{label: 'Preferences',click(){prefman.showPreferences()}},
{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[4].submenu = [
{role: 'close'},
{role: 'minimize'},
{role: 'zoom'},
{type: 'separator'},
{role: 'front'}
]
}
const themenu = Menu.buildFromTemplate(template);
return themenu;
}