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/main.js

59 lines
2.1 KiB
JavaScript
Raw Permalink Normal View History

2017-07-02 15:18:11 +00:00
const {app, Menu, BrowserWindow} = require('electron')
const path = require('path')
const url = require('url')
2017-07-03 11:55:23 +00:00
const themenu = require('./menu')
const setdock = require('./dock')
const ipc = require('electron').ipcMain;
2017-07-02 15:18:11 +00:00
2017-07-03 11:55:23 +00:00
require('electron-debug')();
2017-07-02 15:18:11 +00:00
// 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
2017-07-03 11:55:23 +00:00
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'};
2017-07-02 15:18:11 +00:00
function createWindow () {
// Create the browser window.
2017-07-07 07:57:43 +00:00
win = new BrowserWindow({width: 480, height: 600,icon: path.join(__dirname, 'icon.png')})
2017-07-03 11:55:23 +00:00
setdock.setdock(win)
2017-07-07 07:53:35 +00:00
if(process.platform == 'darwin') { Menu.setApplicationMenu(themenu(win)); }
else { win.setMenu(themenu(win));
}
2017-07-02 15:18:11 +00:00
// and load the index.html of the app.
2017-07-03 11:55:23 +00:00
win.loadURL('http://pf.gree.net/58737',options);
2017-07-02 15:18:11 +00:00
// Open the DevTools.
// Emitted when the window is closed.
win.on('closed', () => {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
win = null
})
}
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', createWindow)
2017-07-03 16:56:29 +00:00
ipc.on('log-out',function(){
console.log("logging out");
win.webContents.session.clearStorageData({storages: "cookies"});win.loadURL("http://pf.gree.net/58737",options);
});
2017-07-03 17:02:52 +00:00
app.on('window-all-closed', function () {
// On OS X it is common for applications and their menu bar
2017-07-02 15:18:11 +00:00
// to stay active until the user quits explicitly with Cmd + Q
2017-07-03 17:02:52 +00:00
if (process.platform !== 'darwin') {
2017-07-02 15:18:11 +00:00
app.quit()
2017-07-03 17:02:52 +00:00
}
})
app.on('activate', function () {
// On OS X it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
2017-07-03 17:06:51 +00:00
if (win === null) {
2017-07-03 17:02:52 +00:00
createWindow()
}
2017-07-02 15:18:11 +00:00
})