electron/default_app/default_app.js

52 lines
1.2 KiB
JavaScript
Raw Normal View History

2016-07-31 20:05:36 +00:00
const {app, BrowserWindow} = require('electron')
2016-07-06 18:47:21 +00:00
const path = require('path')
2016-07-31 20:05:36 +00:00
let mainWindow = null
2016-07-27 23:58:23 +00:00
app.commandLine.appendSwitch('--disable-gpu');
app.commandLine.appendSwitch('--disable-gpu-compositing');
// Quit when all windows are closed.
app.on('window-all-closed', () => {
app.quit()
})
exports.load = (appUrl) => {
app.on('ready', () => {
2016-07-31 20:05:36 +00:00
mainWindow = new BrowserWindow({
width: 800,
height: 600,
autoHideMenuBar: true,
backgroundColor: '#FFFFFF',
useContentSize: true,
webPreferences: {
offscreen: true,
nodeIntegration: false
}
})
2016-07-31 20:05:36 +00:00
mainWindow.loadURL('file:///Volumes/Elements/dev/electron/spec/fixtures/api/offscreen-rendering.html')
mainWindow.focus()
2016-07-29 12:50:27 +00:00
2016-07-31 20:05:36 +00:00
mainWindow.webContents.on('dom-ready', () => {
let ping = true
setInterval(() => {
if (ping) {
mainWindow.webContents.startPainting()
} else {
mainWindow.webContents.stopPainting()
}
2016-07-29 12:50:27 +00:00
2016-07-31 20:05:36 +00:00
ping = !ping
}, 3000)
})
2016-07-29 12:50:27 +00:00
2016-07-31 20:05:36 +00:00
setInterval(() => {
console.log(mainWindow.webContents.isPainting())
}, 500)
2016-07-29 12:50:27 +00:00
2016-07-31 20:05:36 +00:00
mainWindow.webContents.on('paint', (e, rect, data) => {
console.log('painting', data.length)
})
})
}