NodeJS Electron app.on('ready', ...) 问题

NodeJS Electron app.on('ready', ...) question

我有一个应用程序可以从模块调用此函数。

// APP READY
app.on('ready', createWindow.main);

没有任何问题。

然而当我尝试

app.on('ready', () => {
  console.log('Ready');
  createWindow.main;
});

控制台显示 "Ready" 但之后什么也没有发生。

我的想法是,一旦应用准备就绪,我就需要调用不同的函数。

这可能是什么问题?

我这样调用 windows.js 文件:

const createWindow = require('./windows');

windows.js

const {session} = require('electron');
const app = require('electron').app;
const BrowserWindow = require('electron').BrowserWindow;
const url = require('url');
const path = require('path');
const settings = require('electron-settings');

// Windows Variables
let mainWindow;

// Functions container
var createWindow = {};

// MAIN WINDOW
createWindow.main = function() {
    console.log('Creating main window');
    mainWindow = new BrowserWindow({
      width: 800,
      height: 600
    });

    mainWindow.loadURL(url.format({
      protocole: 'file:',
      slashes: true,
      pathname: path.join(__dirname, 'html/index.html')
    }));

    mainWindow.on('closed', () => {
      mainWindow = null;
      app.quit();
    });

};

module.exports = createWindow;

第二种情况你必须调用main

app.on('ready', () => {
  console.log('Ready');
  createWindow.main(); // <-- !
});