electron

主进程创建并关闭多个渲染进程

旧街凉风 提交于 2021-02-01 20:23:29
主脚本指定了运行主进程的 Electron 应用程序的入口 , 通常是man.js文件 , Electron 应用程序只能有一个主进程。 1. 为了管理应用程序的生命周期事件以及创建和控制浏览器窗口,需要从 electron 包导入了 app 和 BrowserWindow 模块 , const { app, BrowserWindow } = require('electron') 2. 定义一个创建 新的浏览窗口 的函数并将 nodeIntegration 设置为 true,将 index.html 文件加载到窗口中, function createWindow () { const win = new BrowserWindow({ width: 800, height: 600, webPreferences: { //注意: 设置 nodeIntegration 选项为 true 表示渲染过程中可以访问Node.js API nodeIntegration: true } }) win.loadFile('index.html') } 3. 调用 createWindow 方法,在 electron app 第一次 被初始化 时创建一个新的窗口 app.whenReady().then(createWindow) 4. 添加一个新的侦听器

electron 启动加载动画

巧了我就是萌 提交于 2021-01-30 09:54:57
因为我用了vue-electron 所以启动的时候是因为vue加载慢 用了官方文档,点击桌面应用后,等待2秒钟才打开程序,太慢了。 下面这个是官方文档的 const {BrowserWindow} = require('electron') let win = new BrowserWindow({show: false}) win.once('ready-to-show', () => { win.show() }) 所以进行检测,发现这个文件慢了 明白了以后,就直接用js load事件即可,注意这里还没有载入vue哦。 来源: oschina 链接: https://my.oschina.net/u/554046/blog/2245068

HTTP GET does not work fine on angular-electron project BUT same url works fine on browser

[亡魂溺海] 提交于 2021-01-29 21:40:08
问题 i am trying to use https://api.pcloud.com/getfilelink API for my graduation project. But i think i have problem with api's CORS or something like that. When i send get from chrome browser or basic node js project api returns fine json but if i try it from my angular-electron project(https://github.com/maximegris/angular-electron) it is returning 'invalid link referer'. What i have tried: Appending ('Access-Control-Allow-Origin', '*'); ('X-Requested-With', 'XMLHttpRequest') to headers. But i

Can't connect to NeDB on render process Electron

我的未来我决定 提交于 2021-01-29 19:52:07
问题 I have problem with connect NeDB to my react-electron app. Now I install NeDB on my project and connect him to electron.js file. const Datastore = require('nedb'); let db = {}; db.students = new Datastore({ filename:'./students.json', autoload: true }) db.students.insert({name : "Putin V.V.", year: 1952}); Now I need connect this db to my app.js file. How I can manipulate with this file on render part? GitHub code 回答1: You can achive your idea by using ipc at Electron. I posted an answer

Command prompt in Electron?

江枫思渺然 提交于 2021-01-29 18:51:47
问题 I'm making an IDE for my language Butterscotch , and I'd like to add a command prompt to my IDE. ( Butterscotch is interpreted , so I don't need to add a compiler.) I'm making my IDE in Electron , so does anybody know how to add command prompt in Electron ? 来源: https://stackoverflow.com/questions/61034778/command-prompt-in-electron

Can't use Discord OAuth2 in Electron application

荒凉一梦 提交于 2021-01-29 17:58:14
问题 I'm trying to create an Electron app (using Electron.net and MVC) with user sign-ins using Discord's OAuth2. However when loading up the OAuth2 page, Discord thinks that I'm using a broken installation of Discord. I assume that this is because the Discord desktop application also uses Electron. When not using Electron, the link opens fine. So far I've attempted changing the User-Agent (both in the Electron startup code and directly on the link with Javascript) used by Electron as I believed

How does Discord connect to third party APIs?

▼魔方 西西 提交于 2021-01-29 17:33:10
问题 I am trying to reproduce something similar in my app. I only see things like OAuth where you can "login" with an external API and a new user will be created/authenticated with their third party credentials. Or alternatively some authorization flow where access tokens must be refreshed every hour or so. Discord, however, connects to these APIs and does not create or login a new user, they only access the user's data from that external API and presents it on the Discord GUI. Furthermore, as a

How to hook a target URL with my own resources in electron?

南楼画角 提交于 2021-01-29 17:12:04
问题 I'm playing around with Electron and want to do the following: Use BrowserWindow.loadURL() to open url_1 In the UI part of url_1 that BrowserWindow renders, there's a link which points to another resource, let's say url_2.html When I click this link, normally my BrowserWindow would load url_2.html . However, I want my BrowserWindow not to actually go to load url_2.html from the internet, since I actually have another file, say, url_3.html in my app's resources. What I want to achieve is this:

Default home directory for snap installer using electron-builder

坚强是说给别人听的谎言 提交于 2021-01-29 15:26:55
问题 I'm currently building a electron app an building the installer like .deb and .snap with electron-builder. Inside the app I need the access the user home directory for some reason and I'm using process.env.HOME || process.env.USERPROFILE to get the home directory (also app.getPath('home') returns the same). This works properly for other cases but when the app installed with .snap , instead of the actual home( /home/username ) directory this returns ~/snap/<app_name>/3/ as home directory. ( 3

Electron: Race condition between main and renderer process

孤人 提交于 2021-01-29 11:17:00
问题 In my Electron application, I am seeing weird behavior. In Windows, sometimes the renderer process executes before the initialization of Electron finishes, which is causing the issue in a startup. For eg: I set up a sequelize database and register IPC channels in the constructor of Main.ts file, so as per my knowledge, app.on('ready') event should be fired once the constructor finishes execution but sometimes in Windows OS only, ready events fires even before the database setup, and my