我正在尝试通过创建充当窗口的 class 的函数来简化代码遍历。这样做时,我的脸上会沾上以下东西:
windows.Main.initialize不是函数
如果您对此有任何简单提示,也请告诉我。这意味着我要编写干净,可读,可访问的代码。
main.js
const electron = require('electron');
const { app, BrowserWindow, ipcMain } = require('electron');
const windows = require('./windowmanager');
function initialize() {
windows.Main.initialize(app);
}
// Initialize
app.on("ready", initialize);
windowmanager.js
const { app, BrowserWindow } = require('electron');
const path = require('path');
exports.__esModule = true;
function Main() {
function Main() { };
this.initialize = function (_app) {
Main.app = _app;
Main.window = new BrowserWindow({
frame: false,
minWidth: 800,
minHeight: 600,
height: 600,
width: 800,
show: true
});
Main.window.loadFile(path.join(__dirname, "../content/index.html"));
Main.window.on('closed', () => {
Main.app.quit();
});
};
return Main;
}
exports.Main = Main;