2 Star 1 Fork 1

小飞 / weixin-linux

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
main.js 1.85 KB
一键复制 编辑 原始数据 按行查看 历史
fengfei 提交于 2016-06-26 16:51 . init
const electron = require('electron');
// 控制应用生命周期的模块。
const {app} = electron;
// 创建原生浏览器窗口的模块。
const {BrowserWindow} = electron;
// 保持一个对于 window 对象的全局引用,如果你不这样做,
// 当 JavaScript 对象被垃圾回收, window 会被自动地关闭
let mainWindow;
function createWindow() {
// 创建浏览器窗口
mainWindow = new BrowserWindow({webPreferences: {
nodeIntegration: false
},width: 900, height: 650});
mainWindow.loadURL("https://wx.qq.com/");
// 当 window 被关闭,这个事件会被触发。
mainWindow.on('closed', () => {
// 取消引用 window 对象,如果你的应用支持多窗口的话,
// 通常会把多个 window 对象存放在一个数组里面,
// 与此同时,你应该删除相应的元素。
mainWindow = null;
});
//mainWindow.webContents.on("new-window", function(event, url) {
//event.preventDefault();
//mainWindow.loadURL(url);
//});
mainWindow.webContents.on("did-finish-load", function() {
mainWindow.webContents.executeJavaScript("Notification.permission = 'granted';", true, function(data){});
});
}
// 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);
// Quit when all windows are closed.
app.on('window-all-closed', () => {
// On macOS it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('activate', () => {
// On macOS it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (mainWindow === null) {
createWindow();
}
});
JavaScript
1
https://gitee.com/fengfei/weixin-ubuntu.git
git@gitee.com:fengfei/weixin-ubuntu.git
fengfei
weixin-ubuntu
weixin-linux
master

搜索帮助