electron

ipcRenderer not receiving message from main process

孤者浪人 提交于 2020-07-13 02:08:24
问题 I can see the "Hello from renderer" alert, but not the "Goodbye from renderer" alert. Running in Windows 10. And I can't see the "received!" alert, which I should see it the ipcRenderer.on(...) worked. index.js const { app, BrowserWindow} = require("electron"); app.on('ready', () => { let mainWindow = new BrowserWindow( { width: 800, height: 600, }); mainWindow.loadURL(`file://${__dirname}/index.html`); mainWindow.webContents.on('did-finish-load', () => { mainWindow.webContents.send("from

Sharing an ESM “.js” module within Node / Electron environment

爱⌒轻易说出口 提交于 2020-07-10 05:54:45
问题 In my Electron app I have a large file constants.js that is exported and available throughout the Render Process (Web, ESM Modules). I would like to also import this file in the application's Main Process (Node, CJS Modules). Even with the new experimental modules that are available in the latest versions of Electron/Node, that would require changing my file extension from constants.js to constants.mjs . As this file is heavily references throughout the application changing the file extension

Electron app createWriteStream throwing ENOENT error

自作多情 提交于 2020-07-09 13:55:09
问题 I'm trying to download files to the filesystem in an electron app. My code, in the main thread, looks like this: const dir = `${__dirname}/media`; if (!fs.existsSync(dir)){ fs.mkdirSync(dir); } const file = fs.createWriteStream(`${dir}/${name}`); file.on("open", function() { const request = http.get(url, function(response) { response.pipe(file); response.on('end', function() { file.close(); ... }); }); request.on('error', function(err) { ... }); }); This works when running in development

Ffmpeg gets aborted in an Electron sandboxed application

て烟熏妆下的殇ゞ 提交于 2020-07-06 20:30:08
问题 I have an Electron app, published on the Mac AppStore, and sandboxed. I'm trying to add a new feature that will encode/decode videos on the fly so I can stream more video formats in an Electron context. I'm using fluent-ffmpeg and a static exec of ffmpeg. Everything works awesomely, I've uploaded the sandboxed app to Apple, and got rejected because ffmpeg is using by default a secure transport protocol which is using non-public API, this is what they've sent me with the rejection: Your app

Electron: dialog.showOpenDialog not returning a promise?

巧了我就是萌 提交于 2020-07-06 11:23:29
问题 I would like to show an Open Dialog box from within a rendered script. I am getting conflicting information from different sources, but, as far as I can tell, the documentation at https://electronjs.org/docs/api/dialog suggests I should be able to use: const dialog = require('electron').remote.dialog; dialog.showOpenDialog({ title: '…', defaultPath: '…' }) .then(data=>console.log(data)); The error message I get is: TypeError: dialog.showOpenDialog(...).then is not a function That suggests

Electron: dialog.showOpenDialog not returning a promise?

╄→гoц情女王★ 提交于 2020-07-06 11:23:20
问题 I would like to show an Open Dialog box from within a rendered script. I am getting conflicting information from different sources, but, as far as I can tell, the documentation at https://electronjs.org/docs/api/dialog suggests I should be able to use: const dialog = require('electron').remote.dialog; dialog.showOpenDialog({ title: '…', defaultPath: '…' }) .then(data=>console.log(data)); The error message I get is: TypeError: dialog.showOpenDialog(...).then is not a function That suggests

How to pass parameters from main process to render processes in Electron

烂漫一生 提交于 2020-07-06 09:15:12
问题 I have an Electron app that can open different windows. On app launch the app open a set of window(s) (that load the same HTML and JS files) but with params to change each window displayed infos. Example : app.on('ready', async () => { ... // open window for stuff 1 win1 = new BrowserWindow({ width: 1024, height: 728 }); win1.loadURL(`file://${__dirname}/app/app.html?id=1`); // open window for stuff 2 win2 = new BrowserWindow({ width: 1024, height: 728 }); win2.loadURL(`file://${__dirname}

Electron Builder: Not allowed to load local resource: app.asar/build/index.html

泪湿孤枕 提交于 2020-07-05 06:59:47
问题 I have an issue when using electron builder I got blank page and error in console: Not allowed to load local resource: file:///C:/Users/emretekince/Desktop/DCSLogBook/client/dist/win-unpacked/resources/app.asar/build/index.html main.js const startUrl = process.env.ELECTRON_START_URL || url.format({ pathname: path.join(__dirname, '/build/index.html'), protocol: 'file:', slashes: true }); mainWindow.loadURL(startUrl); 回答1: Solved by adding "files" in package.json "files": [ "*.js", "build",

Electron Builder: Not allowed to load local resource: app.asar/build/index.html

Deadly 提交于 2020-07-05 06:59:04
问题 I have an issue when using electron builder I got blank page and error in console: Not allowed to load local resource: file:///C:/Users/emretekince/Desktop/DCSLogBook/client/dist/win-unpacked/resources/app.asar/build/index.html main.js const startUrl = process.env.ELECTRON_START_URL || url.format({ pathname: path.join(__dirname, '/build/index.html'), protocol: 'file:', slashes: true }); mainWindow.loadURL(startUrl); 回答1: Solved by adding "files" in package.json "files": [ "*.js", "build",

Electron: get full path of uploaded file

主宰稳场 提交于 2020-07-04 10:37:29
问题 I'm buildind now GUI using Electron. (like PhoneGap for desktop apps) Is there a way to enable full path for file checked in <input type="file"> ? Insted of C:\fakepath\dataset.zip now. (the directory name isn't "fakepath", but that is the value of document.getElementById("myFile").value ) Or, is there other way to select a file? 回答1: Electron adds a path property to File objects, so you can get the real path from the input element using: document.getElementById("myFile").files[0].path 回答2: