score:3

my code

    const electron = require('electron');
// module to control application life.
const app = electron.app;
// module to create native browser window.
const browserwindow = electron.browserwindow;

const path = require('path');
const url = require('url');

// keep a global reference of the window object, if you don't, the window will
// be closed automatically when the javascript object is garbage collected.
let mainwindow;
function load() {

  mainwindow.loadurl('http://127.0.0.1:8080');
}
function createwindow() {
    // create the browser window.
    mainwindow = new browserwindow({width: 800, height: 600});

    // and load the index.html of the app.
    mainwindow.loadurl('http://127.0.0.1:8080');
    mainwindow.loadfile('index.html');


    // open the devtools.
    mainwindow.webcontents.opendevtools();

    // emitted when the window is closed.
    mainwindow.on('closed', function () {
        // dereference the window object, usually you would store windows
        // in an array if your app supports multi windows, this is the time
        // when you should delete the corresponding element.
        mainwindow = null
    })
}

// this method will be called when electron has finished
// initialization and is ready to create browser windows.
// some apis can only be used after this event occurs.
app.on('ready', createwindow);

// quit when all windows are closed.
app.on('window-all-closed', function () {
    // on os x it is common for applications and their menu bar
    // to stay active until the user quits explicitly with cmd + q
    if (process.platform !== 'darwin') {
        app.quit()
    }
});

app.on('activate', function () {
    // on os x it's common to re-create a window in the app when the
    // dock icon is clicked and there are no other windows open.
    if (mainwindow === null) {
        createwindow()
    }
});

// in this file you can include the rest of your app's specific main process

and this is package.json

{
    "version": "1.0.0",
    "name": "idena-pocket",
    "private": true,
    "main": "public/main.js",
    "scripts": {
        "dev": "export node_env=development && webpack-dev-server --https --host 127.0.0.1 --open",
        "electron-dev": "concurrently \"browser=none npm run dev\" \"electron .\"",
        "electron-dev1": "concurrently \"browser=none\" \"electron .\"",
        "electron-dev2": "concurrently \"browser=none npm run dev\" \"wait-on https://10.0.2.2:8080/ && electron .\"",
        "electron-package": "./node_modules/.bin/electron-builder -c.extrametadata.main=build/start-electron.js",
        "preelectron-package": "npm run build",

        "i18-scanner": "i18next-scanner src/**/*.{js,jsx,ts,tsx,html}",
        "format": "prettier-standard --format"
    },
    "dependencies": {
        "react-scripts": "0.8.5",
        "bip39": "^3.0.2",
        "concurrently": "^6.0.2",
        "connected-react-router": "^6.8.0",
        "crypto-js": "^4.0.0",
        "electron": "^12.0.6",
        "electron-builder": "^22.11.1",
        "electron-is-dev": "^2.0.0",
        "history": "^4.10.1",
        "i18next": "^19.4.4",
        "i18next-browser-languagedetector": "^4.1.1",
        "i18next-scanner": "^2.11.0",
        "idena-js": "1.1.5",
        "react": "^16.13.1",
        "react-copy-to-clipboard": "^5.0.2",
        "react-dom": "^16.13.1",
        "react-hook-form": "^5.5.3",
        "react-i18next": "^11.4.0",
        "react-redux": "^7.2.0",
        "react-router-dom": "^5.1.2",
        "react-tooltip": "^4.2.5",
        "redux": "^4.0.5",
        "styled-components": "^5.0.1",
        "sweetalert": "^2.1.2",
        "wait-on": "^5.3.0"
    },
    "devdependencies": {
        "@types/react": "^16.9.25",
        "@types/react-dom": "^16.9.5",
        "@types/react-redux": "^7.1.7",
        "@types/react-router-dom": "^5.1.3",
        "@types/styled-components": "^5.1.0",
        "clean-webpack-plugin": "^3.0.0",
        "copy-webpack-plugin": "^5.1.1",
        "css-loader": "^3.4.2",
        "file-loader": "^6.0.0",
        "html-webpack-plugin": "^3.2.0",
        "pre-commit": "^1.2.2",
        "prettier-standard": "^16.3.0",
        "react-hot-loader": "^4.12.20",
        "ts-loader": "^6.2.1",
        "typescript": "^3.8.3",
        "url-loader": "^4.1.0",
        "webpack": "^4.43.0",
        "webpack-bundle-analyzer": "^3.7.0",
        "webpack-cli": "^3.3.11",
        "webpack-dev-server": "^3.11.0",
        "workbox-webpack-plugin": "^5.1.3"
    },
    "pre-commit": [
        "format"
    ]
}


Related Query

More Query from same tag