๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๐Ÿ–ฅ๏ธํ”„๋ก ํŠธ์—”๋“œ/Electron.js

Electron - ์ดˆ๊ธฐ ์„ค์ • ๋ฐ ์‹คํ–‰

by Janger 2022. 3. 27.
728x90
๋ฐ˜์‘ํ˜•

[์„ค์น˜]

npm init
npm i electron

 

[package.json]

{
    "main": "main.js",
    "scripts": {
        "start": "electron ."
    }
}

 

[main.js]

const { app, BrowserWindow, Menu } = require('electron');

Menu.setApplicationMenu(false); // ๋ฉ”๋‰ด ๋น„ํ™œ์„ฑํ™”

function createWindow(){
    let win = new BrowserWindow({
        frame: true,
        width: 600,
        height: 400,
        minWidth: 400,
        minHeight: 200,
        maxWidth: 700,
        maxHeight: 500,
        resizable: true,
        webPreferences:{
            nodeIntegration: true,
            contextIsolation: false,
            devTools: true           
        }
    });

    win.loadFile('./index.html');

}

app.on('ready', createWindow);

 

[index.html]

<html>
    <head>
        <title>window</title>
    </head>

    <body>
        
        <h1>Hello world!</h1>

    </body>
</html>

 

 

[์‹คํ–‰]

npm start
728x90
๋ฐ˜์‘ํ˜•