electron

webContents.send and ipcRenderer.on Not Working

末鹿安然 提交于 2019-12-02 02:44:49
问题 I'm pretty new to NodeJS, but I do have quite a bit of experience with vanilla JS. In the following code, what exactly am I doing wrong here? It doesn't console.log anything in the app's developer console, so I'm assuming the channel of communication is broken somehow? Does it have anything to do with the fact that readdir is asynchronous? index.js fs.readdir(__dirname, (err, files)=>{ files.forEach((file, index)=>{ console.log('display', __dirname+'\\'+file) // this prints everything as

Communicate directly between two renderer processes in Electron

冷暖自知 提交于 2019-12-02 01:03:42
问题 I create multiple windows from Electron's main process and need to pass messages between them. The only way I have come across to send messages from rendererA to rendererB is by bouncing it to main process. Is there any way to directly send a message from rendererA to renderB? 回答1: In a way or another, the main process has to get involved, but communicating between the renderer processes of two windows can be achieved in some kind of straightforward way: In the main process, define the window

opening pdf files in electron

橙三吉。 提交于 2019-12-02 00:45:20
I need to build an app where the user can open PDF files within the app -- i.e. not by opening a new browser window. I would need to implement a back button and possibly some overlays over the PDF. Does anyone know if there's a good way to do this in Electron? If you're OK with UI provided by chrome PDF extension you can use it from electron. See this question const {app, BrowserWindow} = require('electron') app.once('ready', () => { let win = new BrowserWindow({ webPreferences: { plugins: true } }) win.loadURL(__dirname + '/test.pdf') }) Note, that electron's native PDF support is available

Module version mismatch. Expected 49, got 48

落爺英雄遲暮 提交于 2019-12-02 00:44:38
I am using Electron module mdns and I am getting this error A JavaScript error occurred in the main process Uncaught Exception: Error: Module version mismatch. Expected 49, got 48. at Error (native) at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:167:20) at Object.Module._extensions..node (module.js:568:18) at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:167:20) at Module.load (module.js:458:32) at tryModuleLoad (module.js:417:12) at Function.Module._load (module.js:409:3) at Module.require (module.js:468:17) at require (internal/module.js:20:19) at

Electron global variable garbage collected if renderer process closes?

只愿长相守 提交于 2019-12-02 00:25:52
In Electron, I have my main process opening a BrowserWindow. The BrowserWindow loads one html page and then the same window eventually loads another html page. main.js var mainWindow; global.mainState = { settings: {} } mainWindow = createWindow('main', { width: 1000, height: 800, }); if (curState == 'load') { mainWindow.loadURL(`file://${__dirname}/interface/load.html`, {}) } if (curState == 'login') { mainWindow.loadURL(`file://${__dirname}/interface/login.html`, {}) } load.html const remote = require('electron').remote; var testGlobal = remote.getGlobal('mainState') testGlobal.settings =

Print: How to stick footer on every page to the bottom?

喜夏-厌秋 提交于 2019-12-02 00:17:33
I'm trying to print a generated HTML document to PDF. The document itself can hold multiple pages. Every page is built up like this: <!-- Header --> <!-- Content --> <!-- Footer --> All three look fine on every page. The only problem is that the footer won't stick at the bottom... The footer will always catch up with the last element of the page. As long as the page is filled with enough content the footer will be at the bottom as you would expect it to be. Here is my CSS: .docFooter{ display: -webkit-box; display: -ms-flexbox; display: flex; -webkit-box-pack: justify; -ms-flex-pack: justify;

Background image not loading in Electron Application

Deadly 提交于 2019-12-01 21:34:08
问题 I have an image file in the same directory as my login.vue component (which is where the following code is located). But, when I try this code, the image will not load: <div background="benjamin-child-17946.jpg" class="login" style="height:100%;"> I'm getting this error: Failed to load resource: the server responded with a status of 404 (Not Found) This is strange, because I can see in my terminal that my image is in the same directory as login.vue. I am using webpack to compile. What might

How to enable a pop up for authentication for electron?

寵の児 提交于 2019-12-01 20:51:19
I am creating an electron app that accesses a url. And when navigated to the URL the user clicks on a button and are redirected to a URL that displays this pop up in Chrome. How can I enable/show this popup in electron? It doesn't seem to enable it by default. What you see on the picture is that Chrome opens a popup for handle authentication event. However, Electron doesn't make such popup by default, as it stated in the documentation of 'login' event The default behavior is to cancel all authentications, to override this you should prevent the default behavior with event.preventDefault() and

Background image not loading in Electron Application

馋奶兔 提交于 2019-12-01 20:03:06
I have an image file in the same directory as my login.vue component (which is where the following code is located). But, when I try this code, the image will not load: <div background="benjamin-child-17946.jpg" class="login" style="height:100%;"> I'm getting this error: Failed to load resource: the server responded with a status of 404 (Not Found) This is strange, because I can see in my terminal that my image is in the same directory as login.vue. I am using webpack to compile. What might be causing this? Your primary issue is that single file components are compiled and the compiled script

Pass arguments to packaged electron application

南笙酒味 提交于 2019-12-01 19:57:49
We're using electron-packager to bundle up and distribute the front-end of our web application. We need to be able to pass in the host and port of the server to the electron front-end for connecting. When we launch via electron main.js --host blah --port 8080 it works. Once it's packaged, we run via ./MyApp --host blah --port 8080 and it doesn't work. This is bad because we don't want customers to need to install electron/npm itself. Also worth noting is that this happens whether we package the app in an asar archive or not. Any ideas on things we could try, or if we're trying to go about this