electron

what is the difference between const and const {} in javascript

天涯浪子 提交于 2019-12-28 07:59:43
问题 When I study electron, I found 2 ways of getting BrowserWindow object. const {BrowserWindow} = require('electron') and const electron = require('electron') const BrowserWindow = electron.BrowserWindow What is the difference between const and const {} in JavaScript? I can't understand why the const {} can work. Do I miss anything important about JS? 回答1: The two pieces of code are equivalent but the first one is using the ES6 destructuring assignment to be shorter. Here is a quick example of

what is the difference between const and const {} in javascript

我们两清 提交于 2019-12-28 07:58:06
问题 When I study electron, I found 2 ways of getting BrowserWindow object. const {BrowserWindow} = require('electron') and const electron = require('electron') const BrowserWindow = electron.BrowserWindow What is the difference between const and const {} in JavaScript? I can't understand why the const {} can work. Do I miss anything important about JS? 回答1: The two pieces of code are equivalent but the first one is using the ES6 destructuring assignment to be shorter. Here is a quick example of

electron数据存储 electron-store

微笑、不失礼 提交于 2019-12-26 04:43:10
npm安装: npm install electron-store yarn安装: yarn add electron-store 使用方法: const Store = require ( 'electron-store' ) ; const store = new Store ( ) ; //如果需要加密存储 就用下面的 //const store = new Store({encryptionKey: '加密值'}); store . set ( 'unicorn' , '这是需要存储的内容' ) ; console . log ( store . get ( 'unicorn' ) ) ; //=> '这是需要存储的内容' // Use dot-notation to access nested properties store . set ( 'foo.bar' , true ) ; console . log ( store . get ( 'foo' ) ) ; //=> {bar: true} store . delete ( 'unicorn' ) ; console . log ( store . get ( 'unicorn' ) ) ; //=> undefined 我的store.set()存储地址: C:\Users\mi\AppData\Roaming

electron入门笔记

↘锁芯ラ 提交于 2019-12-26 01:06:37
1.安装electron npm install electron -g //全局 2.建立主线程 main.js // Modules to control application life and create native browser window const { app, BrowserWindow, globalShortcut } = require('electron') // 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 createWindow() { // Create the browser window. mainWindow = new BrowserWindow({ width: 800, height: 600, webPreferences: { nodeIntegration: true } }) //注册F12打开调试工具,但是F12可能冲突不起作用,自定义alt+c globalShortcut.register('Alt+c', () =

Is where a way to listen to wireless network changes in node js?

老子叫甜甜 提交于 2019-12-25 18:34:47
问题 I am building an application in which I need to detect the any changes in connected wireless network ie when a user transfers from one network to another and log the change. I am using electron js and wireless-tools for nodejs. So is there a way to do this or I have to use setInterval() to check every few seconds. Any suggestions/solutions are appreciated.Thanks. 回答1: online (in index.html or in other html file) to detect if an internet connection exist like this : In index.html you can do

working with electron-edge-js for existing dll with app.config

夙愿已清 提交于 2019-12-25 18:34:02
问题 Using electron-edge-js calling a c# dll method, But its not reading config data from node.exe.config file. Is there any other do we need to keep app.config for electron? 回答1: I got it working by renaming the node.exe.config to myapp.exe.config 来源: https://stackoverflow.com/questions/47851544/working-with-electron-edge-js-for-existing-dll-with-app-config

NodeJS & Electron: Async Multiple Required Files

给你一囗甜甜゛ 提交于 2019-12-25 09:30:13
问题 I wish to create an array of modules to require , to loop through the modules to require, require them asynchronously, and then callback. I have tried the below: // async require module for other required modules function asyncRequire (requireList, callback) { if (!Array.isArray(requireList)) {return}; var index = -1; var loop = {} loop.next = function () { if (index < requireList.length) { var asyncOperation = function (j) { setTimeout(function() { index++; var item = requireList[index];

Broadcasting message from ipcMain in electron

蹲街弑〆低调 提交于 2019-12-25 08:39:40
问题 I need to broadcast a message from main process of electron to all renderer processes. There is no send option for ipcMain, only an option to reply to the sender via event.sender.send() . 回答1: You are looking for the webContents API. From the same page of documentation in your post: It is also possible to send messages from the main process to the renderer process, see webContents.send for more information. Here is the doc for webContents 回答2: You could make an array of windows, then iterate

Save captured video to file in Electron

荒凉一梦 提交于 2019-12-25 04:28:08
问题 I want to save a video that is captured from webcam to a local file. So far I have been able to: Create a stream with getUserMedia Encapsulate the stream with RecordRTC Get blob from RecordRTC I cannot figure out how to save the video to a file though. Calling save() on RecordRTC allows me to download the video file, but I want everything to happen in nodejs for further processing. The file is playable, regardless. I tried to write the blob and dataURL to file, but that file is not playable.

I am getting an error while connecting to sqlite3 database

徘徊边缘 提交于 2019-12-25 04:07:21
问题 I am getting an error while connecting to sqlite3 database. This is my code var sqlite3 = require('sqlite3').verbose(); var db = new sqlite3.Database('testdb'); db.serialize(function(){ dbb.run("create table user (id int, db text)"); var stmt = db.prepare("insert into user values(?,?)"); for(var i=0; i<10; i++){ var d = new Date(); var n = d.toLocateTimeString(); stmt.run(i,n); } stmt.finalize(); db.each("select id, dt from user",function(err,row){ console.log("user id:"+row.id,row.dt); }); }