main.js
975 字节
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const {app, BrowserWindow} = require('electron');
var subarg = require('subarg');
var argv = subarg(process.argv.slice(2));
if (argv.v || argv.version) {
console.log('electron v' + process.versions.electron);
console.log('chrome v' + process.versions.chrome);
return app.quit();
}
if (argv.d) {
var args = "args: ";
for (var i in argv) {
args += i + " = " + argv[i] + "\n";
}
console.log(args);
}
if(!argv.u){
console.log("you must input the web url to record with : -u ");
return app.quit();
}
app.disableHardwareAcceleration()
let win
app.once('ready', () => {
win = new BrowserWindow({
webPreferences: {
offscreen: true
}
})
win.loadURL(argv.u)
var now = Date.now()
win.webContents.on("paint", function(event, dirty, image){
console.log(
"painting",
Date.now() - now,
win.webContents.isOffscreen(),
win.webContents.getFrameRate()
)
now = Date.now()
})
win.webContents.setFrameRate(20)
})