Untitled

 avatar
unknown
javascript
4 years ago
1.2 kB
5
Indexable
const electron = require("electron");
const url = require("url");
const path = require("path");

const { app, BrowserWindow } = electron;

let win;

function createWindow() {
    win = new BrowserWindow({
        width: 800,
        height: 700,
        webPreferences: {
            nodeIntegration: true,
            contextIsolation: false,
            traceProcessWarnings: true
        },
    });
    win.loadFile('src/index.html')

    win.loadURL(
        url.format({
            pathname: path.join(__dirname, "main.html"),
            protocol: "file:",
            slashes: true
        })
    );
    win.on('closed', () => {
        win = null;
    })
}

app.on("ready", createWindow);

app.on('window-all-closed', () => {
    if (process.platform !== 'darwin') {
        app.quit()
    }
});

app.on('activate', () => {
    if (win === null) {
        createWindow()
    }
});

ipcMain.handle('new', async (e, arg) => {
    const newUser = new user(arg)

    const userSaved = await newUser.save()
    console.log(userSaved)

})



module.exports = { createWindow }
app.whenReady().then(createWindow)
Editor is loading...