electron

Communicate with <webview> in Electron

不羁的心 提交于 2019-12-04 03:13:27
I have a <webview> in my Electron app. I'd like to have safe "foreign" communication, the way I would with an iframe through postMessage . So for example: webview.executeJavaScript("window.parent.postMessage('all done!')"); Is my only choice for communication with this subwebview to turn on nodeIntegration so that I can use sendToHost ? Turning on all of nodeIntegration just for this one feature seems like overkill. You can access Electron APIs in the webview preload script, including IPC, even when nodeIntegration is disabled. Your preload script can inject functions into the global namespace

nodejs下 electron 使用 Web Termination

≯℡__Kan透↙ 提交于 2019-12-04 01:35:28
想在工具里面执行 shell 进行部分命令行交互 基于 微软开源的 xterm.js 和 nodepty https://github.com/microsoft/xterm.js 前端 https://github.com/microsoft/node-pty 后台 index.html 文件 <!doctype html> <html> <link rel="stylesheet" href="node_modules/xterm/css/xterm.css" /> <body> <div id="terminal"></div> </body> <script> // No idea what these are about. Just copied them from the demo code window.require = window.parent.require; var global_xterm = undefined; var global_pty = undefined; function testbtnclick(){ var os = require('os'); var process = require('process'); var pty = require('node-pty'); var Terminal = require('xterm')

How to close electron app via javascript?

风流意气都作罢 提交于 2019-12-04 00:26:33
问题 I am running an express app via electron. Below is the main.js const electron = require("electron"), app = electron.app, BrowserWindow = electron.BrowserWindow; let mainWindow; function createWindow () { mainWindow = new BrowserWindow({ width: 1200, height: 800, frame: false, kiosk: true }); mainWindow.loadURL(`file://${__dirname}/index.html`) mainWindow.webContents.openDevTools(); mainWindow.on("closed", function () { mainWindow = null; }) } app.on("ready", createWindow); app.on("browser

electron仿制qq(2) 主界面制作

房东的猫 提交于 2019-12-04 00:04:09
制作从头开始 最后会将写好的组件放到一起的! 之前写了好几天的纯css 有点累 本章中将使用 sass 如果代码太长 会分两个或多个章节写 代码中会有详细的注释 以便于大家阅读and理解 界面可能会有部分偏差 比较是仿制的 官方界面尺寸 默认宽度: 280px (大约 我之前拉伸过 被记录了 所以没法准确的测量) 默认高度: 652px (也是大约值) 最小高度: 528px 最小宽度: 280px 最大高度: 1041px (可能不太准确 有可能是根据分辨率来显示的) 最大宽度: 605px 顶部头像区域高度: 140px 底部选项区域高度: 40px 搜索框高度: 30px 头像直径/高度: 50px 右键菜单宽度: 180px 下载安装 安装electron-vue 这几天不知道什么情况 老是下载很慢 如果太慢就挂代理吧! #cd F:\electron vue init simulatedgreg/electron-vue qq_main cd qq_main npm install npm run dev 开始制作 创建路由和界面 路由: export default new Router({ routes: [ {path: '/', name: 'main', component: () => import('@/components/LandingPage')},

Where can I find the logs for my Electron app in production?

时光总嘲笑我的痴心妄想 提交于 2019-12-04 00:02:32
I've built an app with Electron and used Electron-Builder to create a Squirrel windows installer and updater. It all works great but I'm having trouble debugging the production version of my app. Are the logs created by a console.log written somewhere on disk when using the production version? If so, where can I find them? Or are those all removed when compiling the executable? There must be some kind of log file for my app right? I've found the SquirrelSetupLog in C:\Users\Tieme\AppData\Local\MyApp\SquirrelSetupLog but that's not enough for debugging my production-only problem. Just came

why use webpack with electron

喜夏-厌秋 提交于 2019-12-03 23:41:19
问题 I am experimenting with electron. I see a lot of examples that use webpack. But why use something like webpack? Because as far as I can tell electron supports require('module') . 回答1: It is not webpack which is used in electron. The require function is part of the node.js, which is the base for electron. More informations about the modules at the node.js docs: https://nodejs.org/dist/latest-v5.x/docs/api/modules.html But as long as webpack is also availiable as a node module (https://www

ELECTRON 学习四

倾然丶 夕夏残阳落幕 提交于 2019-12-03 23:21:59
接上篇,优化 第一步:去掉菜单栏 mainWindow = new BrowserWindow({ title: 'hello Electron', width: 800, height: 500, frame: false, }); 第二步:改为透明窗口 mainWindow = new BrowserWindow({ title: 'hello Electron', width: 800, height: 500, frame: false, transparent: true }); 参考地址: https://electronjs.org/docs/api/frameless-window 基本达到要求 第三步:打包 cnpm install electron-packager -g 第四步:添加打包命令 "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "start": "electron .", "pack": "electron-packager . Electron_Snow --win --out ../Electron_Snow --arch=x64 --app-version=0.0.1 --electron-version=6.1.4" }, 第五步:打包exe 注意

Get selected text from electron webview

我与影子孤独终老i 提交于 2019-12-03 22:42:12
How to get the selected text from a webview in an electron application? I am using Angular with Electron. So I have a component which has a webview: <webview id="foo" attr.src={{activeUrl}} style="height: 600px"></webview> This is what I use for getting the selected text: let rightClickPosition = null; const menu = new Menu(); const menuItem = new MenuItem({ label: 'Get selected text', click: () => { // does not work for selected text in webview console.log(window.getSelection().toString()); } }); menu.append(menuItem); window.addEventListener('contextmenu', (e) => { e.preventDefault();

How should I configure the base href for Angular 2 when using Electron?

流过昼夜 提交于 2019-12-03 22:30:23
I need to either set <base> in the HTML or APP_BASE_HREF during the bootstrap for Angular 2 to not throw exceptions. If I set either of these then Electron , thinking in terms of the file system, throws exceptions in browser_adapter.ts when trying to match a route: EXCEPTION: Error: Uncaught (in promise): Cannot match any routes. Current segment: 'C:'. Available routes: ['/dashboard', '/accounts']. I tried using just the HashLocationStrategy mentioned in this blog post , but Angular still complains about the base href not being set. Since the href attribute can take a relative path and thanks

electron 学习一

依然范特西╮ 提交于 2019-12-03 17:36:25
概念: Electron是由Github开发,用HTML,CSS和JavaScript来构建 跨平台桌面应用程序的一个开源库。 Electron提供了丰富的本地(操作系统)的API,使你能够使用纯JavaScript来创建桌面应用程序。与其它各种的Node.js运行时不同的是Electron专注于桌面应用程序而不是Web服务器。 安装: cnpm install electron -g(不能使用npm) cnpm install -g electron-prebuilt 是否成功: 在命令行输入 electron会弹出一个窗体 来源: https://www.cnblogs.com/tylz/p/11805220.html