electron

VSCode代码编译启动调试

匿名 (未验证) 提交于 2019-12-02 23:59:01
编译运行 fork vscode的源代码,并clone到本地, checkout到master分支 执行 yarn install 安装依赖,具体node环境查看官方文档 执行 yarn watch 编译代码并且执行实时监控修改进行增量编译 执行 ./script/code.sh 启动electron程序 1. yarn watch 分析 利用gulp watch监控目录变化,实时编译最新的代码 gulp watch -- max_old_space_size = 4095 gulp会自动读取执行目录下的 gulpfile.js 文件,并执行,下面分析 gulpfile.js gulpfile.js 定义了compile-client, watch-client, compile, watch,default五种任务,先看watch,也就是我们上面执行的命令 - default 可以看到,执行watch的时候并没有执行编译步骤,应该是在default中定义了执行watch前需要执行的流程。 // monacoTypecheckTask monaco编辑器编译 // compileClientTask 客户端基础代码编译 // compileExtensionsTask 客户端基础扩展插件代码编译 const compileTask = task . define (

What are the pros and cons of Chrome Apps compared to Electron?

风格不统一 提交于 2019-12-02 23:56:18
I want to program a desktop app in javascript (with web technologies) and looked for a comparison between Electron and Chrome Apps. Everything I need seems to be possible with Chrome Apps, but there's a big hype around Electron/NW.js. What are the advantages of Electron? Is it due to the large amount of Node packages? I think the functional differences are clear to me. Pros and cons like: + Chrome Apps can run on Chrome OS - Chrome Apps needs an installed Chrome Browser ... UPDATE 2016-08-20: As Eduardo pointed out, Google announced that they'll discontinue Chrome Apps for all platforms expect

Printing a PDF file with Electron JS

房东的猫 提交于 2019-12-02 23:55:24
I am trying to create an Electron JS app that has the purpose to print letter size PDFs. This is my snippet of code for printing: win = new BrowserWindow({ width: 378, height: 566, show: true, webPreferences: { webSecurity: false, plugins: true } }); // load PDF win.loadURL('file://' + __dirname + '/header1_X_BTR.pdf'); // if pdf is loaded start printing win.webContents.on('did-finish-load', () => { win.webContents.print({silent: true, printBackground:true}); }); My issues are: if I have print({silent:true}) my printer prints an empty page. If I have print({silent:false}) , the printer prints

electron-vue小试身手

匿名 (未验证) 提交于 2019-12-02 23:52:01
最近一个项目(vue)需求是用硬件来触发web端页面显示以及效果的切换,客户的硬件设备只支持用tcp协议通讯,而我们的前端呢是用不了tcp的,众所周知在浏览器端,我们只能用http/https协议(ajax)和websocket协议来通讯,前端页面开发完成之后,我用node起了一个websocket实现了项目需求,但是终归还是要用tcp的啊。这时候就得用之前同事说过的electron来构建整个项目了(之前看了一个demo把vue打包后的静态文件打包成桌面程序)。但是,怎么在electron里面用tcp把数据推给vue页面呢? 同事也是非常热心,百度了好些资料,我自己也百度了好多,在electron里面起一个tcp倒是简单,demo奉上: //tcp服务端 var net = require('net'); var server = net.createServer(function(connection) { connection.on('end', function() { //console.log('客户端关闭连接'); }); connection.on('data',function(data){ //console.log('服务端:收到客户端发送数据为',data) }) }); server.listen(9002, function() { console.log

electron 常用命令

匿名 (未验证) 提交于 2019-12-02 23:51:01
"scripts": { "start": "electron .", "packagerWin64": "electron-packager ./ '项目' --platform=win32 --arch=x64 --out ./project --app-version 1.0.0 --overwrite --icon=./static/assets/img/favicon.ico --asar", "packagerWin32": "electron-packager ./ '项目' --platform=win32 --arch=ia32 --out ./project --app-version 1.0.0 --overwrite --icon=./static/assets/img/favicon.ico --asar", "packagerMAC": "electron-packager ./ '项目' --platform=darwin --arch=x64 --out ./project --app-version 1.0.0 --overwrite --extra-resource=./res/2.dat --extra-resource=./res/1.dat --icon=./static/assets/img/favicon.icns" } app

Electron学习入门

匿名 (未验证) 提交于 2019-12-02 23:43:01
1、electron app electron 2、package.json script start electron . Electron应用结构 主进程 Package.json main web 渲染进程 Electron Chromium 来展示 web Chromium Electron web Electron Node.js API BrowserWindow BrowserWindow BrowserWindow web web GUI API web GUI web GUI GUI Electron API API API require Electron API , Electron remote API BrowserWindow remote Node.js API Electron Node.js Node.js API Electron Electron Node.js npm npm Electron 调试应用 1 Chromium BrowserWindow BrowserView WebView BrowserWindow webContents openDevTool()API const { BrowserWindow } = require('electron') let win = new BrowserWindow() win

How to launch my electron app from a website

青春壹個敷衍的年華 提交于 2019-12-02 23:10:30
We have an electron crypto app that signs transactions (among other things). We want other websites to have the ability to have a button that opens that electron app, pre-filled with some params (the transaction information). flow is: user clicks "make transaction" on some-crypto-site.com electron app opens up with pre-filled params user clicks "sign transaction" in electron app electron app does stuff behind the scenes electron app closes and sends a message to some-crypto-site.com This could be done at runtime, or install time. What I tried (linux, chrome) calling app

Electron应用使用electron-builder配合electron-updater实现自动更新

匿名 (未验证) 提交于 2019-12-02 21:53:52
开发客户端一定要做的就是自动更新模块,否则每次版本升级都是一个头疼的事。 下面是Electron应用使用electron-builder配合electron-updater实现自动更新的解决方案。 1.安装 electron-updater 包模块 1 npm install electron-updater --save 2.配置package.json文件 2.1 为了打包时生成latest.yml文件,需要在 build 参数中添加 publish 配置。 注意: 配置了publish才会生成latest.yml文件,用于自动更新的配置信息;latest.yml文件是打包过程生成的文件,为避免自动更新出错,打包后禁止对latest.yml文件做任何修改。如果文件有误,必须重新打包获取新的latest.yml文件!!! 2.2 增加nsis配置(可省略) nsis配置不会影响自动更新功能,但是可以优化用户体验,比如是否允许用户自定义安装位置、是否添加桌面快捷方式、安装完成是否立即启动、配置安装图标等。nsis 配置也是添加在 build 参数中。 View Code 3.配置主进程main.js文件(或主进程main中的index.js文件),引入 electron-updater 文件,添加自动更新检测和事件监听: 注意: 一定要是主进程main.js文件

Electron npm install 常见错误(Linux)

匿名 (未验证) 提交于 2019-12-02 21:53:52
Linux版本 Ubuntu 12.04 (32bit) 安装Git sudo apt-get install git 生成ssh key #查看有没有sshkey cd ~/.ssh #生成 ssh-keygen #查询 cat ~/.ssh/id_rsa.pub 安装node 使用二进制文件 错误一:./node: cannot execute binary file 原因可能如下: 1、非root用户或者无执行权限 2、编译环境不同(程序由其他操作环境复制过来) PS: https:// blog.51cto.com/1381479/888198 错误二:axconfig: port 1 not active axconfig: port 2 not active 原因:可能 sudo apt-get install node 这么去安装node了。 解决:先 sudo apt-get remove node 卸载掉,从node官网下。 PS: https:// dolinux.blogspot.com/2012/04/axconfig-port-1-not-active-axconfig.html 编译源码 错误一:WARNING: failed to autodetect C++ compiler version (CXX=g++) ERROR: Did not find

Electron npm install 常见错误(Windows)

匿名 (未验证) 提交于 2019-12-02 21:53:52
问题一:node_gyp使用版本不对 if not defined npm_config_node_gyp (node "C:\Users\Administrator\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "C:\Users\Administrator\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild ) 问题:明明装的是5.0.2版本,使用的却是3.9.2版本。 原因:命令上已经写明,在npm_config_node_gyp未配置情况,node_gyp使用的版本。 解决:删掉前者路径的node-gyp。 问题二:无法找到 v140 的生成工具 C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\VC\VCTargets\Microsoft.Cpp.Platform.targets(6 7,5): error MSB8020