electron

electron 打开选择文件框

﹥>﹥吖頭↗ 提交于 2020-01-23 05:47:26
electron中有dialog模块,可以用来打来文件框,选择文件夹或者文件。 两种实现方式 1、可以通过ipc通信,main process,实现打开文件对话框的操作,然后把选择的文件夹或者文件再次通过ipc通信发送的render 进程。 // in render.js const {ipcRenderer} = require('electron'); function openDialog(){ ipcRenderer.send('openDialog'); } ipcRenderer.on('selectedItem', (event, files)=>{ console.log(files);//输出选择的文件 }) //in main.js const {ipcRenderer, dialog} = require('electron'); ipcRenderer.on('openDialog',(event)=>{ dialog.showOpenDialog({ }).then(result=>{ console.log(result); //输出结果 result.filePaths.length>0 && ipcRenderer.send(result.filePaths); }) }) 2、直接在render进程中,使用remote模块中的dialog模块,打开

Angular 4 + Electron - How to run application and watch for changes (live reload)

半世苍凉 提交于 2020-01-22 20:13:04
问题 I am creating an Electron application using Angular 4. How can i set it up so that it watches for any changes and live reloads it. package.json { "name": "angular-electron", "version": "0.0.0", "license": "MIT", "main": "main.js", "scripts": { "ng": "ng", "start": "ng serve", "build": "ng build", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e", "electron": "electron .", "electron-build": "ng build --prod && electron ." }, "private": true, "dependencies": { "@angular/animations": "^4.2.4

how can I use fs in react with electron?

旧时模样 提交于 2020-01-22 10:45:10
问题 I want use react+webpack+electron to build a desktop app.How can I inject fs module into react so that I can use it to read native files? I have a component such as: class Some extends Component { render() { return <div>{this.props.content}</div> } } export default Some; in entry.js : import React from 'react'; import { render } from 'react-dom'; import Some from './src/some.jsx'; const data = "some content"; /* How can I read data by fs module? import fs from 'fs' doesn't work here */ render

electron package: reduce the package size

 ̄綄美尐妖づ 提交于 2020-01-22 09:23:05
问题 I made a simple Electron app: main.js const {app, BrowserWindow} = require('electron') const path = require('path') const url = require('url') let win function createWindow () { win = new BrowserWindow({ width: 800, height: 600, icon: path.join(__dirname, 'icon.ico') }) win.maximize(); win.loadURL('https://stackoverflow.com/', {"extraHeaders" : "pragma: no-cache\n"}); win.on('closed', () => { win = null }) } app.on('ready', createWindow) app.on('browser-window-created',function(e,window) {

How to play ogg audio in electron with node addon?

别来无恙 提交于 2020-01-16 19:07:31
问题 I have an atom electron application that plays Ogg audios with HTML5 Audio API. I'm facing performance issues when running this program in very slow and old computers with Windows OS. I'm trying to fork a new process in electron and play the audios with a module or a node addon. But I'm not finding a module or a node addon to do this. Is there any module or node addon to play Ogg files and work with electron? 来源: https://stackoverflow.com/questions/57164605/how-to-play-ogg-audio-in-electron

node module in Electron

我的未来我决定 提交于 2020-01-16 18:18:14
问题 Need help on getting babyparse module working in Electron, after npm install babyparse module and still getting Uncaught Error: Cannot find module 'babyparse' . var Baby = require("babyparse"); window.$ = window.jQuery = require('./jquery.min.js'); var csv; function readyFn(d){ parsed = Baby.parse(csv); Papa.parse(data, { complete: function(results) { console.log("Finished:", results.data); } }); } $(document).ready(readyFn); 回答1: I had to re-bind require to window before using it. In your

Electron: Trying to set `nativeTheme.themeSource`, but `nativeTheme` is undefined

坚强是说给别人听的谎言 提交于 2020-01-16 09:35:50
问题 I'm unable to set the themeSource of my electron app. Platform is Windows 8.1. const electron = require('electron'); const app = electron.app; if (app) app.on('ready', function() { nativeTheme = electron.nativeTheme; nativeTheme.themeSource = 'dark'; }); This produces an error in a modal pop-up alert saying nativeTheme is undefined. I'm definitely doing something wrong, but for the life of me I can't see it. Everything else I'm doing in Electron works like a charm. Here's my entire app.js: //

How to require an image with react electron outside of src folder(Application Support)

戏子无情 提交于 2020-01-16 09:09:07
问题 I want to require images dynamically from the Application Support folder. I use the react-app-rewired package to require outside of the src folder but when I use a window variable in the image src I get the error: Error: Cannot find module. I get the path like this and get an error code with a string that works when I use it directly in the src part of the image tag. window.path = window.electron.remote.app.getPath("appData") image(Does not work): <img className="topSvg" src={require(""

Can I call Ionic 4 / Capacitor Electron code from the Ionic part of the application?

扶醉桌前 提交于 2020-01-15 10:14:37
问题 I am investigating using Ionic 4/ Capacitor to target Windows via the Electron option, for an application where I want to use SQLite. Using the Ionic Native SQLite plugin, which wraps this Cordova plugin, out of the box, as far as I can see, the Windows support is for UWP, and not Desktop, which runs using Electron in Ionic Capacitor wrapper. My plan, was to see if I could use Electron SQLite package, and then call this from my Ionic application by making a wrapper class for the Ionic native