胡斌

add subarg,use -u to input url

1 -const {app, BrowserWindow} = require('electron') 1 +const {app, BrowserWindow} = require('electron');
  2 +
  3 +var subarg = require('subarg');
  4 +
  5 +var argv = subarg(process.argv.slice(2));
  6 +if (argv.v || argv.version) {
  7 + console.log('electron v' + process.versions.electron);
  8 + console.log('chrome v' + process.versions.chrome);
  9 + return app.quit();
  10 +}
  11 +
  12 +if (argv.d) {
  13 + var args = "args: ";
  14 + for (var i in argv) {
  15 + args += i + " = " + argv[i] + "\n";
  16 + }
  17 + console.log(args);
  18 +}
  19 +
  20 +if(!argv.u){
  21 + console.log("you must input the web url to record with : -u ");
  22 + return app.quit();
  23 +}
2 24
3 app.disableHardwareAcceleration() 25 app.disableHardwareAcceleration()
4 26
@@ -9,10 +31,10 @@ app.once('ready', () => { @@ -9,10 +31,10 @@ app.once('ready', () => {
9 offscreen: true 31 offscreen: true
10 } 32 }
11 }) 33 })
12 - win.loadURL('http://github.com') 34 + win.loadURL(argv.u)
13 35
14 var now = Date.now() 36 var now = Date.now()
15 - 37 +
16 win.webContents.on("paint", function(event, dirty, image){ 38 win.webContents.on("paint", function(event, dirty, image){
17 console.log( 39 console.log(
18 "painting", 40 "painting",
@@ -14,7 +14,8 @@ @@ -14,7 +14,8 @@
14 "author": "hubin", 14 "author": "hubin",
15 "license": "MIT", 15 "license": "MIT",
16 "dependencies": { 16 "dependencies": {
17 - "electron": "^1.6.11" 17 + "electron": "^1.6.11",
  18 + "subarg": "^1.0.0"
18 }, 19 },
19 "devDependencies": { 20 "devDependencies": {
20 "electron-packager": "^8.7.2" 21 "electron-packager": "^8.7.2"