我有带有 main.js 的电子应用程序,其中包含
const electron = require('electron')
const { app, BrowserWindow } = require('electron')
function createWindow(){
let win = new BrowserWindow({width: 800, height: 600})
console.log("loading file index1");
win.loadFile('index1.html')
}
app.on('ready',createWindow);
和 main2.js
const electron = require('electron')
const { app, BrowserWindow } = require('electron')
function createWindow(){
let win = new BrowserWindow({width: 400, height: 400})
console.log("loading file index2");
win.loadFile('index2.html');
}
app.on('ready',createWindow);
两个 main.js 几乎相同,它们应该显示不同的页面。我想用 main.js 默认启动应用程序,并提供一个使用 main2.js 启动应用程序的选项。在我的 package.json 中我介绍了
{
"name": "mytestapp",
"version": "1.0.0",
"description": "",
"main": "main.js",
"scripts": {
"start": "electron .",
"test:e2e": "./node_modules/mocha/bin/mocha tests/test.js",
"main2": "npm run start ./main2.js",
"debug": "./node_modules/.bin/electron ./main2.js"
},
"author": "",
"license": "ISC",
"devDependencies": {
"electron": "^4.0.8",
"mocha": "^3.5.3",
"spectron": "^5.0.0"
},
"dependencies": {
"start": "^5.1.0"
}
}