electron

Electron: Cannot access dialog before initialization

纵饮孤独 提交于 2021-02-05 11:07:28
问题 I have a renderer file that has the sole purpose of opening a dialog box to select files from. I have tried rewriting this so many times, and each time I get a different error. What am I doing wrong? Exact code: const { ipcRenderer, shell, remote } = require('electron') const dialog = remote.dialog; function openFileBrowser() { dialog.showOpenDialog(remote.getCurrentWindow(), { properties: ["openFile", "multiSelections"] }).then(result => { if (result.canceled === false) { console.log(

Electron: Cannot access dialog before initialization

一曲冷凌霜 提交于 2021-02-05 11:05:10
问题 I have a renderer file that has the sole purpose of opening a dialog box to select files from. I have tried rewriting this so many times, and each time I get a different error. What am I doing wrong? Exact code: const { ipcRenderer, shell, remote } = require('electron') const dialog = remote.dialog; function openFileBrowser() { dialog.showOpenDialog(remote.getCurrentWindow(), { properties: ["openFile", "multiSelections"] }).then(result => { if (result.canceled === false) { console.log(

How to integrate oAuth login with a packaged electron app

佐手、 提交于 2021-02-05 10:48:43
问题 I have been working on a new electron app with react that uses the Spotify API. I am using oAuth to authenticate with Spotify and a return an access token, this why fine in a local dev env as the app if running on the webpack dev server and can provide a callback url. However the when the electron app is packaged up and installed it is no longer using the dev server and the JS bundles are packaged up with the app. At this stage how am I supposed to hit the oauth server and return a valid

“require is not defined” error comes when i try to import js file (with node modules) to my main electron js file

时光怂恿深爱的人放手 提交于 2021-02-05 10:30:49
问题 This is my folder folder structure Hi im new to electron.js I was facing for an issue where that i cannot capture jquery events in my main.js file. As a solution i created a separate file ( events.js )[now i can capture jquery events] and i connect it to index.html . So in my event.js i added a cron-job(node-cron) to check whether it's working or not, but when i try to run a project i get an error saying require is not defined . Without any import library , it worked. This is my index.html

this.util.TextEncoder is not a constructor only in electron app (works in chrome)

本秂侑毒 提交于 2021-02-05 09:11:36
问题 I am creating a body segmentation app using tensorflow bodypix model. It works fine in the browser. I am using webpack to use its modules(see below) import * as wasm from "@tensorflow/tfjs-backend-wasm"; import * as tf from "@tensorflow/tfjs-core"; import * as bodyPix from "@tensorflow-models/body-pix"; wasm.setWasmPaths("./wasm/"); tf.setBackend("wasm").then(() => { //some simple vanilla js code }); //some more vanilla js code... It works exactly fine in chrome and giving output as expected

how can you overwrite or remove the signature “electron.app.Electron” from the desktop notification

不打扰是莪最后的温柔 提交于 2021-02-04 21:05:37
问题 I'm trying to remove or overwrite my notification signature made by electron. here is what i get: I am trying to whether overwrite the signature electron.app.Electron or remove it completely, by knowing that I have tested it on test mode ( npm run start ), and also when packed as .exe also I have noticed that I remove the icon the signature goes a way, but it is very unpleasant without one. my current notification code is bellow: function showNotification() { const notification = new

how can you overwrite or remove the signature “electron.app.Electron” from the desktop notification

我怕爱的太早我们不能终老 提交于 2021-02-04 21:05:30
问题 I'm trying to remove or overwrite my notification signature made by electron. here is what i get: I am trying to whether overwrite the signature electron.app.Electron or remove it completely, by knowing that I have tested it on test mode ( npm run start ), and also when packed as .exe also I have noticed that I remove the icon the signature goes a way, but it is very unpleasant without one. my current notification code is bellow: function showNotification() { const notification = new

Electron: Communicate between BrowserWindow and rendered URL (nodeIntegration: false)

此生再无相见时 提交于 2021-02-04 13:54:50
问题 I've spent about an hour reading gist after repo after blog post, but can't seem to figure out how to do do this. I have a BrowserWindow instance loading a URL (that I control), with nodeIntegration: false . From the main process, I'd like to communicate with the rendered URL. I'm getting confused between preload scripts, BrowserWindow.send and executeJavascript paradigms. The data I want to send is very large (eg. file uploads between 50kb and 10mb). What's the best way to do this? Any any

Electron 中 webview 如何与主进程渲染进程进行事件监听通信

时光总嘲笑我的痴心妄想 提交于 2021-02-02 06:05:48
webview 调用 加载页 方法通过<webview>.executeJavaScript(code[, userGesture, callback])或者webview.send()发送,而在访客页使用ipcRenderer.on()监听 注意、注意、注意: 访客页需要调用webview所在页面的方法,则需要在webview中加上属性 nodeintegration= "true" 访客页(被webview加载的资源页面)也就是webview中src指定的页面(浏览器页面) if ( window .require( 'electron' ) ) { let ipcRenderer = window .require( 'electron' ).ipcRenderer; ipcRenderer && ipcRenderer.on( 'webmsg' , ( e, msg ) => { console .log(msg, '收到的消息' ); }); ipcRenderer && ipcRenderer.sendToHost( '我已经收到消息了' ); } webview所在页面(客户端页面) let webview = document .getElementById( 'test' ); webview.addEventListener( 'ipc-message' , (

electron 从主进程发向渲染进程发消息

点点圈 提交于 2021-02-02 00:34:13
说明: 自主到从:从Main到Renderer的消息传递,借助 BrowerWindow.webContents.send() 发送消息。 自从到主:从Renderer到Main的消息传递,借助 ipcRender 和 ipcMain 发送/接收消息。 事件机制:无论是 BrowerWindow.webContents.send() ,还是 ipc ,其实都是 node 的事件机制,都是 EventEmitter 的实例。 https://github.com/downgoon/hello-electron/issues/3 来源: oschina 链接: https://my.oschina.net/u/2430651/blog/2248859