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"
]
}
Source: stackoverflow.com
Related Query
- Next.js background-image css property cant load the image
- Electron Builder: Not allowed to load local resource: app.asar/build/index.html
- Cant load a react app after starting server
- React Router v4: Cant load page on GitHub pages
- Creating an installer for Electron React JS app - reactJS component doesn't load when run after install
- electron & react: No resource with given URL found, DevTools failed to load SourceMap
- Unable to load react dev tools in electron
- Get Electron production window to load a route with loadURL?
- Electron for React cannot load custom cursor
- Cant load images dynamically imported with webpack-image-loader and called from a JSON file
- Problem with card image load in Electron ReactJS and Material-Ui
- React- HTTP request is firing on page load
- How to load a URL into a BrowserView in an Electron React Boilerplate app that uses MemoryRouter?
- Cannot load local files in electron js
- Unable to load script.Make sure you are either running a Metro server or that your bundle 'index.android.bundle' is packaged correctly for release
- React won't load local images
- How to load image files with webpack file-loader
- Refused to load the font 'data:font/woff.....'it violates the following Content Security Policy directive: "default-src 'self'". Note that 'font-src'
- ESlint - Error: Must use import to load ES Module
- ES6 modules implementation, how to load a json file
- Load local images in React.js
- (node:9374) Warning: To load an ES module, set "type": "module"
- How do I load a markdown file into a react component?
- How to load library source maps using webpack?
- Load fonts with Webpack and font-face
- How do I create configuration for axios for default request headers in every http call?
- how to use webpack to load CDN or external vendor javascript lib in js file, not in html file
- React: how to load and render external html file?
- Failed to load config "react" to extend from
- Electron IPC and nodeIntegration
More Query from same tag
- Cannot set properties of undefined (setting 'player') ReactPlayer
- FontAwesome 5 icons not showing in React App
- How to customize button css in react-admin
- My React front-end is unable to call my node-express backend server, the fullstack app is deployed in heroku
- Too many re-renders when trying to change array of components on click on React
- react context rerenders every child of Provider?
- How to achieve tag agnostic styled components?
- How to route exact string in reactJS
- React testing library form submit event is different from the real browser
- Not getting request body when using Fetch API but JQuery AJAX works.
- React control the order of text inputs in a form
- Too much rerendering happeing in React with APIs
- loosing old data when updating the array in zustand
- Handle Multiple Calls Correctly in Javascript
- react-data-table-component: access the selected row and assign it to setState
- I want stop rendering in react-hooks
- Find arrays in db linked with a user through routes in React?
- how to redirect new page in react js
- useState variable not holding its state during onChange event
- Enzyme expects an adapter to be configured
- When does webpack cli comes into play
- How to make a file of functions in React?
- "startIndex" of Recharts Brush does not change even though using setState and state was changed
- MUI KeyboardDatePicker change styles of date input box
- React Hooks: State Is Not Updating in Function
- How to pass parent value to child on first render and change parent component value from Child?
- 'openArea' is not defined no-undef Unexpected use of 'event' no-restricted-globals
- react app 404 error after clear cache in browser
- Reset State on Props Change
- react-select don't show keyboard on mobile devices and prevent zoom