Tag: 电子

从主stream程向所有渲染器处理电子广播事件

我知道如何使用ipcRenderer.send()和ipcMain.on()将事件从渲染器进程发送到主进程。 我也可以使用event.sender.send()将回复发送给渲染器进程,但是我怎么能从主进程向所有渲染进程发送事件,更像广播。

为什么不启动运行电子应用程序?

我有以下几个电子应用程序package.json: "name": "my-app", "version": "1.0.0", "description": "", "main": "main.js", "scripts": { "start": "electron ." }, 当我npm start在应用程序文件夹中npm start ,相应的应用程序将用于运行。 使用npm start时,我npm start为我的所有电子应用程序获取以下输出: 电子。 module.js:471 扔呃; ^ 错误:找不到模块'./' 在Function.Module._resolveFilename(module.js:469:15) 在Function.Module._load(module.js:417:25)。 在Module.require(module.js:497:17) 在要求(内部/ module.js:20:19) 在对象。 (/Users/me/electron/my-app/node_modules/.bin/electron:3:16) 在Module._compile(module.js:570:32) 在Object.Module._extensions..js(module.js:579:10) 在Module.load(module.js:487:32) 在tryModuleLoad(module.js:446:12) 在Function.Module._load(module.js:438:3) npm ERR! 代码ELIFECYCLE npm ERR! errno 1 npm ERR! m1@1.0.0开始: electron . npm ERR! 退出状态1 npm […]

没有显示一个吞噬一个电子应用程序的Console.logs

我开始一口气工作。 我有一个电子应用程序是由一个吞咽过程调用。 问题是我不能够看到main.js进程的console.logs到执行gulp命令的控制台。 我可以看到开发工具中所有渲染进程的console.logs。 我的大文件是: var gulp = require('gulp'), browserify = require('gulp-browserify'), concatCss = require('gulp-concat-css'), run = require('gulp-run'); var src = './process', app = './app'; gulp.task('js', function () { return gulp.src(src + '/js/render.js') .pipe(browserify({ transform: 'reactify', extensions: 'browserify-css', debug: true })) .on('error', function (err) { console.error('Error!', err.message); }) .pipe(gulp.dest(app + '/js')); }); gulp.task('html', function () […]

为什么Node模块进入.staging文件夹?

我有一个电子应用程序,我正在尝试安装节点模块。 当我运行npm install ,它会创buildnode_modules文件夹,但是所有模块都会进入名为.staging的子文件夹。 每个模块还附加-xxxxx ,其中x是一些随机的字母数字。 我创build的其他电子应用程序从来没有这样做过。 所有节点模块都位于node_modules的根目录下,并且没有附加-xxxxx 。 任何想法为什么发生这种情况?

win.document.write('content'); 无法读取未定义的属性'写'

我试图通过JavaScript文件从电子打开一个新的窗口,它的工作原理,并打开新的窗口,但我不能写入HTML /文本到新文件。 我得到这个错误: 无法读取未定义的属性'写' 我简单的代码: var myWindow = window.open("", "myWindow", "width=300, height=200"); myWindow.document.write ('content'); 任何build议或其他方式? 这里是来自控制台的图像:

用“启动函数”和“参数”调用JavaScript文件

我正在开发一个简单的Electon应用程序。 我有两个JavaScript文件(NodeJs)。 第一个文件是调用第二个..我的代码正在工作… 我想修改这一行: require('./mitm.js'); 接受参数。 我想在mitm.js文件中添加一个启动函数,并在main.js文件中使用object.start(),并使用参数来configuration代理并replace"http://proxy:1111" 例如:obj.start(param) 文件1:main.js const electron = require('electron') const {app, BrowserWindow, session} = require('electron') const path = require('path') const url = require('url') //call mitm proxy require('./mitm.js'); let win function createWindow () { win = new BrowserWindow({width: 800, height: 800}) win.webContents.session.setProxy({proxyRules:'localhost:8080'}, function () { win.loadURL(url.format({ pathname: path.join(__dirname, 'index.html'), protocol: 'file:', slashes: […]

需要使用共享数据库的Electron应用程序的解决scheme

我知道node-mysql可以用于Electron的数据库。 但是,如果我构build我的应用程序,用户仍然需要在他们的计算机上正确安装MySQL? 我需要一个数据库解决scheme,我的应用程序的多个用户可以使用,而无需安装任何其他的依赖关系。 只是我的独立应用程序。 有没有解决方法?

如何在电子中创builddynamic路线?

我怎样才能创buildelectrondynamic路线? 我很困惑,因为如果没有误, electron就不会使用URL

使用Electron访问Angular 2应用程序中的文件系统

我知道Angular 2运行在无法访问文件系统的Web浏览器上。 不过,我使用Electron作为我的前端,并通过电子运行应用程序: "build-electron": "ng build –base-href . && cp src/electron/* dist", "electron": "npm run build-electron && electron dist" 所以我用npm run electron运行它,最后运行electron dist 。 由于我通过electron运行,而不是ng我会认为我应该能够访问文件系统。 但是,当我这样做的时候: import * as fs from 'fs' 我收到一个错误: ng:///AppModule/AppComponent_Host.ngfactory.js:5 ERROR TypeError: __WEBPACK_IMPORTED_MODULE_0_fs__.readFileSync is not a function(…) 同样,当我尝试: var fs = require('fs'); 我得到: ng:///AppModule/AppComponent_Host.ngfactory.js:5 ERROR TypeError: fs.readFileSync is not a function […]

在Electron中输出用户名

我真的知道如何在Electron应用程序中输出用户名。 所以这样的事情: const os = require('os') const username = // the code or the username so that it can be displayed document.write("The username is: " + username) 那可能吗?