跳转到主内容

42 篇博文 含有标签「发行版」

查看所有标签

API Changes Coming in Electron 1.0

· 阅读时间:约 4 分钟

Since the beginning of Electron, starting way back when it used to be called Atom-Shell, we have been experimenting with providing a nice cross-platform JavaScript API for Chromium's content module and native GUI components. The APIs started very organically, and over time we have made several changes to improve the initial designs.


Now with Electron gearing up for a 1.0 release, we'd like to take the opportunity for change by addressing the last niggling API details. The changes described below are included in 0.35.x, with the old APIs reporting deprecation warnings so you can get up to date for the future 1.0 release. An Electron 1.0 won't be out for a few months so you have some time before these changes become breaking.

弃用警告

By default, warnings will show if you are using deprecated APIs. To turn them off you can set process.noDeprecation to true. To track the sources of deprecated API usages, you can set process.throwDeprecation to true to throw exceptions instead of printing warnings, or set process.traceDeprecation to true to print the traces of the deprecations.

使用内置模块的新方式

内置模块现在分成一个模块,而不是分成独立模块, 这样您就可以使用它们 而不会与其他模块 相冲突:

var app = require('electron').app;
var BrowserWindow = require('electron').BrowserWindow;

The old way of require('app') is still supported for backward compatibility, but you can also turn if off:

require('electron').hideInternalModules();
require('app'); // throws error.

An easier way to use the remote module

Because of the way using built-in modules has changed, we have made it easier to use main-process-side modules in renderer process. You can now just access remote's attributes to use them:

// New way.
var app = require('electron').remote.app;
var BrowserWindow = require('electron').remote.BrowserWindow;

Instead of using a long require chain:

// Old way.
var app = require('electron').remote.require('app');
var BrowserWindow = require('electron').remote.require('BrowserWindow');

Splitting the ipc module

The ipc module existed on both the main process and renderer process and the API was different on each side, which is quite confusing for new users. We have renamed the module to ipcMain in the main process, and ipcRenderer in the renderer process to avoid confusion:

// 在主进程中.
var ipcMain = require('electron').ipcMain;
// In renderer process.
var ipcRenderer = require('electron').ipcRenderer;

And for the ipcRenderer module, an extra event object has been added when receiving messages, to match how messages are handled in ipcMain modules:

ipcRenderer.on('message', function (event) {
console.log(event);
});

BrowserWindow 的标准化

The BrowserWindow options had different styles based on the options of other APIs, and were a bit hard to use in JavaScript because of the - in the names. They are now standardized to the traditional JavaScript names:

new BrowserWindow({ minWidth: 800, minHeight: 600 });

Following DOM's conventions for API names

The API names in Electron used to prefer camelCase for all API names, like Url to URL, but the DOM has its own conventions, and they prefer URL to Url, while using Id instead of ID. We have done the following API renames to match the DOM's styles:

  • Url 更名为 URL
  • Csp 更名为 CSP

You will notice lots of deprecations when using Electron v0.35.0 for your app because of these changes. An easy way to fix them is to replace all instances of Url with URL.

Changes to Tray's event names

The style of Tray event names was a bit different from other modules so a rename has been done to make it match the others.

  • clicked 更名为 click
  • double-clicked 更名为 double-click
  • right-clicked 更名为 right-click

Electron 有哪些新功能

· 阅读时间:约 3 分钟

Electron近期收到了一些有趣的更新和趣谈,摘要如下:


Electron 现在已经更新了 Chrome 45,截止为 v0.32.0。 其他更新包含...

更好的帮助文档

新文档

为了让文档看起来、读起来更舒适,我们标准化了文档记录,并对其结构进行了调整。 同时,对如日语和韩语等语言内容,还有社区贡献的文档翻译。

相关的拉取请求: electron/electron#2028electron/electron#2533, electron/electron#2557, electron/electron#2709, electron/electron#2725, electron/electron#2698, electron/electron#2649.

Node.js 4.1.0

自从v0.33.0版本开始,Electron附带Node.js 4.1.0。

相关的拉取请求: electron/electrony#2817

node-pre-gyp

依赖 node-pre-gyp 的模块现在可以在源代码构建时针对Electron编译。

相关的拉取请求: mapbox/node-pre-gyp#175

ARM支持

Electron现在在ARMv7上为Linux提供构建。 它可以在Chromebook和Raspberry Pi 2等流行平台上运行。

相关问题: atom/libchromiumcontent#138, electron/electronic #2094, electron/electronic #366

MacOS X 10.10 “Yosemite” 式的无边框窗口

无边框窗口

一个由@jaanus提供的、已被合并的补丁允许Electron像其他内置的原生OS X程序一样创建包含在OS X “Yosemite” 后系统集成的红绿灯式按钮的无边框窗口。

相关的拉取请求: electron/electrony#2776

谷歌 Summer of Code 项目:打印支持

谷歌Summer of Code项目后,我们合并了 @hokein 的补丁,以改进打印支持。 并添加打印页面到 PDF 文件的能力。

相关问题: electron/electron#2677, electron/electron#1935, electron/electron#1532, electron/electron#805, electron/electron#1669, electron/electron#1835.

Atom

Atom现在已经升级到Electron v0.30.6 运行Chrome 44。 到v0.33.0的升级在atom/atom#8779上进行。

Talks

GitHub用户Amy PalamountainNordic.js上为Electron做了很好的介绍。 她还创建了 electron-accelerator 库。

Amy Palomountain:用 Electron 构建本地应用程序

也在Atom团队中的Ben OgleYAPC Asia上作了一段关于Electron的演讲:

Ben Ogle:使用互联网技术构建桌面应用

Atom团队成员Kevin Sawicki等人在湾区Electron用户组近期的会面上作了关于Electron的演讲。 这些视频已被发布,这里有一些:

Kevin Sawicki:Electron的历史

Ben Gotow:让网页应用感觉是原生的