发现了一个漏洞,该漏洞允许在某些禁用 Node.js 集成的 Electron 应用中重新启用 Node.js 集成。该漏洞已被分配 CVE 标识符 CVE-2018-1000136。
🌐 A vulnerability has been discovered which allows Node.js integration to be re-enabled in some Electron applications that disable it. This vulnerability has been assigned the CVE identifier CVE-2018-1000136.
🌐 Last week the electronjs.org site had a few minutes
of downtime. If you were affected by these brief outages, we're sorry
for the inconvenience. After a bit of investigation today, we've diagnosed
the root cause and have deployed a fix.
为了防止将来出现这种停机情况,我们已经在我们的应用上启用了Heroku 阈值警报。每当我们的 Web 服务器累积的失败请求或响应缓慢超过某个阈值时,我们的团队将会收到通知,以便我们能够快速解决问题。
🌐 To prevent this kind of downtime in the future, we've enabled
Heroku threshold alerts
on our app. Any time our web server accumulates failed requests or slow responses beyond a certain threshold, our team will be notified so we can
address the problem quickly.
下次当你在飞机上或地下咖啡馆开发 Electron 应用时,可能会希望拥有一份离线文档以供参考。幸运的是,Electron 的文档以 Markdown 文件形式提供,并且有超过 20 种语言版本。
🌐 The next time you're developing an Electron app on a plane or in a subterranean
coffee shop, you might want to have a copy of the docs for offline reference.
Fortunately, Electron's docs are available as Markdown files in over 20
languages.
已经发现了一个影响使用自定义协议处理程序的 Electron 应用的远程代码执行漏洞。该漏洞已被分配 CVE 标识符 CVE-2018-1000006。
🌐 A remote code execution vulnerability has been discovered affecting
Electron apps that use custom protocol handlers. This vulnerability has been
assigned the CVE identifier CVE-2018-1000006.
🌐 Such apps can be affected regardless of how the protocol is registered, e.g.
using native code, the Windows registry, or Electron's
app.setAsDefaultProtocolClient API.
macOS 和 Linux 不受此问题影响。
🌐 macOS and Linux are not vulnerable to this issue.
我们已经发布了包含此漏洞修复的新版本 Electron:
1.8.2-beta.5、
1.7.12、
和 1.6.17。
我们强烈建议所有 Electron 开发者立即将他们的应用更新到最新的稳定版本。
🌐 We've published new versions of Electron which include fixes for
this vulnerability:
1.8.2-beta.5,
1.7.12,
and 1.6.17.
We urge all Electron developers to update their apps to the latest stable
version immediately.
🌐 If for some reason you are unable to upgrade your Electron version,
you can append -- as the last argument when calling app.setAsDefaultProtocolClient,
which prevents Chromium from parsing further options.
The double dash -- signifies the end of command options,
after which only positional parameters are accepted.
Electron 正在开发一个新的主要版本,同时我们对版本控制策略也进行了一些调整。从 2.0.0 版本开始,Electron 将严格遵循语义化版本控制(Semantic Versioning)。
🌐 A new major version of Electron is in the works, and with it some changes to our versioning strategy. As of version 2.0.0, Electron will strictly adhere to Semantic Versioning.
🌐 This change means you'll see the major version bump more often, and it will usually be a major update to Chromium. Patch releases will also be more stable, as they will now only contain bug fixes with no new features.
🌐 Because Electron's semver ranges will now be more meaningful, we recommend
installing Electron using npm's default --save-dev flag, which will prefix
your version with ^, keeping you safely up to date with minor and patch
updates:
🌐 For developers interested only in bug fixes, you should use the tilde semver prefix e.g. ~2.0.0, which which will never introduce new features, only fixes to improve stability.
Electron 有了一个新网站,网址是 electronjs.org!我们已将原来的静态 Jekyll 网站替换为 Node.js 网络服务器,这让我们能够更灵活地进行网站的国际化,并为更多令人兴奋的新功能铺平了道路。
🌐 Electron has a new website at electronjs.org! We've replaced
our static Jekyll site with a Node.js webserver, giving us flexibility to
internationalize the site and paving the way for more exciting new features.
我们已开始着手对网站进行国际化,目标是让全球开发者都能轻松进行 Electron 应用开发。我们正在使用一个名为 Crowdin 的本地化平台,该平台可以与 GitHub 集成,并在内容被翻译成不同语言时自动创建和更新拉取请求。
🌐 We've begun the process of internationalizing the website with the
goal of making Electron app development accessible to a global audience of
developers. We're using a localization platform called Crowdin that integrates
with GitHub, opening and updating pull requests automatically as content is translated into different languages.
🌐 Though we've been working quietly on this effort so far,
over 75 Electron community members have already discovered the project
organically and joined in the effort to internationalize the website and
translate Electron's docs into over 20 languages. We are seeing
daily contributions from people all over the world, with translations for
languages like French, Vietnamese, Indonesian, and Chinese leading the way.
🌐 If you're multilingual and interested in helping translate Electron's docs
and website, visit the electron/electron-i18n repo, or jump right into
translating on Crowdin, where you can sign in using your GitHub account.
🌐 There are currently 21 languages enabled for the Electron project on Crowdin.
Adding support for more languages is easy, so if you're interested in
helping translate but you don't see your language listed,
let us know and
we'll enable it.
🌐 As of today, any Electron app can easily have its own page on the Electron
site. For a few examples, check out
Etcher,
1Clipboard, or
GraphQL Playground, pictured
here on the Japanese version of the site:
有一些非常棒的 Electron 应用,但它们并不总是容易找到,而且并不是每个开发者都有时间或资源去建立一个完善的网站来推广和分发他们的应用。
🌐 There are some incredible Electron apps out there, but they're not always easy
to find, and not every developer has the time or resources to build a proper
website to market and distribute their app.
🌐 Using just a
PNG icon file and a small amount of app metadata,
we're able to collect a lot of information about a given app.
Using data collected from GitHub, app pages can now display screenshots,
download links, versions, release notes, and READMEs for every app that
has a public repository. Using a color palette extracted from each app's icon,
we can produce bold and accessible colors
to give each app page some visual distinction.
🌐 The Homebrew package manager for macOS has a subcommand called cask
that makes it easy to install desktop apps using a single command in your
terminal, like brew cask install atom.
我们已经开始收集流行 Electron 应用的 Homebrew cask 名称,并且现在在每个有 cask 的应用页面上显示安装命令(针对 macOS 访问者):
🌐 We've begun collecting Homebrew cask names for popular Electron apps and are now
displaying the installation command (for macOS visitors) on every app page
that has a cask:
🌐 We've moved the site from electron.atom.io to a new domain: electronjs.org.
Electron 项目诞生于 Atom 内部,Atom 是 GitHub 基于 web 技术构建的开源文本编辑器。Electron 最初被称为 atom-shell。Atom 是第一个使用它的应用,但人们很快就意识到,这个神奇的 Chromium + Node 运行时可以用于各种不同的应用。当像微软和 Slack 这样的公司开始使用 atom-shell 时,很明显这个项目需要一个新的名字。
🌐 The Electron project was born inside Atom, GitHub's open-source text editor
built on web technologies. Electron was originally called atom-shell. Atom
was the first app to use it, but it didn't take long for folks to realize that
this magical Chromium + Node runtime could be used for all kinds of different
applications. When companies like Microsoft and Slack started to make use of
atom-shell, it became clear that the project needed a new name.
🌐 And so "Electron" was born. In early 2016, GitHub assembled a new team to focus
specifically on Electron development and maintenance, apart from Atom. In the
time since, Electron has been adopted by thousands of app developers, and is now
depended on by many large companies, many of which have Electron teams of
their own.
支持 GitHub 的 Electron 项目,比如 Atom 和 GitHub Desktop,仍然是我们团队的优先事项,但通过迁移到一个新的域名,我们希望能够帮助澄清 Atom 和 Electron 之间的技术区别。
🌐 Supporting GitHub's Electron projects like Atom and GitHub Desktop is still a
priority for our team, but by moving to a new domain we hope to help clarify
the technical distinction between Atom and Electron.
之前的 Electron 网站是使用流行的基于 Ruby 的静态网站生成器 Jekyll 构建的。Jekyll 是构建静态网站的绝佳工具,但网站已经开始超出它的能力范围。我们希望拥有更多动态功能,例如正确的重定向和动态内容渲染,因此 Node.js 服务器成为显而易见的选择。
🌐 The previous Electron website was built with Jekyll, the popular Ruby-based
static site generator. Jekyll is a great tool for building static websites, but
the website had started to outgrow it. We wanted more dynamic capabilities like proper redirects and dynamic content rendering, so a Node.js server was the obvious choice.
🌐 The Electron ecosystem includes projects with components written in many
different programming languages, from Python to C++ to Bash. But JavaScript is foundational to Electron, and it's the language used most in our community.
通过将网站从 Ruby 迁移到 Node.js,我们旨在降低希望为网站做出贡献的人的入门门槛。
🌐 By migrating the website from Ruby to Node.js, we aim to lower the barrier to
entry for people wishing to contribute to the website.
🌐 The new website is hosted on Heroku. We use deployment pipelines and the
Review Apps
feature, which automatically creates a running copy of the app for every pull
request. This makes it easy for reviewers to view the actual effects of a
pull request on a live copy of the site.
我们想向世界各地所有贡献了时间和精力帮助改进 Electron 的朋友们表示特别感谢。开源社区的热情在 Electron 的成功中起到了不可估量的作用。谢谢大家!
🌐 We'd like to give special thanks to all the folks around the world who have
contributed their own time and energy to help improve Electron. The passion of
the open-source community has helped immeasurably in making Electron a success.
Thank you!
在 Google Chromium 中发现了一个远程代码执行漏洞,影响所有最近版本的 Electron。任何访问远程内容的 Electron 应用都容易受到此漏洞的攻击,无论是否启用了 [沙箱选项]。
🌐 A remote code execution vulnerability has been discovered in Google Chromium
that affects all recent versions of Electron. Any Electron app that accesses
remote content is vulnerable to this exploit, regardless of whether the
sandbox option is enabled.
我们发布了两个新的 Electron 版本 1.7.8 和 1.6.14,其中都包含了对该漏洞的修复。我们强烈建议所有 Electron 开发者立即将他们的应用更新到最新的稳定版本:
🌐 We've published two new versions of electron 1.7.8 and 1.6.14,
both of which include a fix for this vulnerability. We urge all Electron
developers to update their apps to the latest stable version immediately:
npm i electron@latest --save-dev
要了解有关保持你的 Electron 应用安全的最佳做法,请参阅我们的 [安全教程]。
🌐 To learn more about best practices for keeping your Electron apps secure,
see our security tutorial.
electron npm 包现在包含一个 TypeScript 定义文件,提供了对整个 Electron API 的详细注释。这些注释可以提升你的 Electron 开发体验,即使你使用的是普通的 JavaScript。只需 npm install electron 就可以在你的项目中获取最新的 Electron 类型定义。
🌐 The electron npm package now includes a TypeScript definition file that provides detailed annotations of the entire Electron API. These annotations can improve your Electron development
experience even if you're writing vanilla JavaScript. Just
npm install electron to get up-to-date Electron typings in your project.
TypeScript 是由微软创建的一种开源编程语言。它是 JavaScript 的超集,通过添加对静态类型的支持来扩展语言。近年来,TypeScript 社区发展迅速,在最近的 Stack Overflow 开发者调查中,TypeScript 被评为最受喜爱的编程语言之一。TypeScript 被形容为“可扩展的 JavaScript”,GitHub、Slack 和 Microsoft 的团队都在使用它来编写可扩展的 Electron 应用,这些应用被数百万人使用。
🌐 TypeScript is an open-source programming language created by Microsoft. It's
a superset of JavaScript that extends the language by adding support for
static types. The TypeScript community has grown quickly in recent years,
and TypeScript was ranked among the
most loved programming languages
in a recent Stack Overflow developer survey. TypeScript is described
as "JavaScript that scales", and teams at
GitHub,
Slack,
and
Microsoft
are all using it to write scalable Electron apps that are used
by millions of people.
🌐 TypeScript supports many of the newer language features in JavaScript like
classes, object destructuring, and async/await, but its real differentiating
feature is type annotations.
Declaring the input and output datatypes expected by your program can
reduce bugs by
helping you find errors at compile time, and the annotations can also serve
as a formal declaration of how your program works.
🌐 When libraries are written in vanilla Javascript, the types are often vaguely
defined as an afterthought when writing documentation. Functions can often
accept more types than what was documented, or a function can have invisible
constraints that are not documented, which can lead to runtime errors.
TypeScript 通过 定义文件 解决了这个问题。TypeScript 定义文件描述了一个库的所有函数以及其预期的输入和输出类型。当库的作者在发布的库中打包 TypeScript 定义文件时,该库的使用者可以直接在编辑器中探索它的 API 并立即开始使用,通常无需查阅库的文档。
🌐 TypeScript solves this problem with definition files.
A TypeScript definition file describes all the functions of a library and its
expected input and output types. When library authors bundle a TypeScript
definition file with their published library, consumers of that library can
explore its API right inside their editor
and start using it right away, often without needing to consult the library's
documentation.
🌐 Many popular projects like
Angular,
Vue.js,
node-github
(and now Electron!) compile their own definition file and bundle it with their
published npm package. For projects that don't bundle their own definition file,
there is
DefinitelyTyped,
a third-party ecosystem of community-maintained definition files.
从版本 1.6.10 开始,每个 Electron 版本都包含自己的 TypeScript 定义文件。当你从 npm 安装 electron 包时,electron.d.ts 文件会随安装的包自动打包。
🌐 Starting at version 1.6.10, every release of Electron includes its own
TypeScript definition file. When you install the electron package from npm,
the electron.d.ts file is bundled automatically with the
installed package.
安装 Electron 最安全的方法是使用确切的版本号:
🌐 The safest way to install Electron is using an exact version number:
如果你已经在使用第三方定义,例如 @types/electron 和 @types/node,你应该将它们从你的 Electron 项目中移除,以防止任何冲突。
🌐 If you were already using third-party definitions like @types/electron
and @types/node, you should remove them from your Electron project to prevent
any collisions.
🌐 The definition file is derived from our
structured API documentation,
so it will always be consistent with Electron's API documentation.
Just install electron and you'll always get TypeScript definitions that are
up to date with the version of Electron you're using.
🌐 Once your editor is configured for TypeScript, you'll start to see more
context-aware behavior like autocomplete suggestions, inline method reference,
argument checking, and more.
🌐 If you're new to TypeScript and want to learn more, this
introductory video from Microsoft
provides a nice overview of why the language was created, how it works,
how to use it, and where it's headed.
🌐 Because TypeScript is a superset of JavaScript, your existing JavaScript code is
already valid TypeScript. This means you can gradually transition an existing
JavaScript project to TypeScript, sprinkling in new language features as needed.
🌐 If you encounter any issues using Electron's new TypeScript definition files,
please file an issue on the
electron-typescript-definitions repository.
🌐 When people use GitHub in their job or OSS activities, they tend to receive many notifications on a daily basis. As a way to subscribe to the notifications, GitHub provides email and web notifications. I used these for a couple of years, but I faced the following problems:
🌐 I was spending a lot of time and energy trying to prevent those problems, so I decided to make an issue reader for GitHub to solve these problems efficiently, and started developing Jasper.
🌐 Jasper is used by developers, designers, and managers in several companies that are using GitHub.
Of course, some OSS developers also are using it.
And it is also used by some people at GitHub!
🌐 This "stream" is the core feature of Jasper. For example, if you want to see "issues that are assigned to @zeke in the electron/electron repository", you create the following stream:
repo:electron/electron assignee:zeke is:issue
创建流并等待几秒钟后,你可以看到符合条件的问题。
🌐 After creating the stream and waiting for a few seconds, you can see the issues that meet the conditions.
🌐 As you may have noticed by looking at these, streams can use GitHub's search queries.
For details on how to use streams and search queries, see the following URLs.
🌐 Jasper also has features for unread issue management, unread comment management, marking stars, notification updating, filtering issues, keyboard shortcuts, etc.
🌐 These features enable rapid and simple desktop application development. It is awesome! If you have any product idea, you should consider using Electron by all means.
🌐 I had a hard time figuring out the "stream" concept. At first I considered using GitHub's Notifications API. However I noticed that it does not support certain use cases. After that I considered using the Issues API and Pull Requests API, in addition to the Notification API. But it never became what I wanted. Then while thinking about various methods, I realized that polling GitHub's Search API would offer the most flexibility. It took about a month of experimentation to get to this point, then I implemented a prototype of Jasper with the stream concept in two days.
注意:轮询最多每 10 秒进行一次。这对于 GitHub API 的限制来说已经足够了。
🌐 Note: The polling is limited to once every 10 seconds at most. This is acceptable enough for the restriction of GitHub API.
🌐 This week we caught up with @feross and @dcposch to talk about WebTorrent, the web-powered torrent client that connects users together to form a distributed, decentralized browser-to-browser network.
WebTorrent 使用开放的 Web 标准,将网站用户连接在一起,形成一个分布式、去中心化的浏览器到浏览器网络,以实现高效的文件传输。
🌐 Using open web standards, WebTorrent connects website users together to form a distributed, decentralized browser-to-browser network for efficient file transfer.
🌐 Imagine a video site like YouTube, but where visitors help to host the site's content. The more people that use a WebTorrent-powered website, the faster and more resilient it becomes.
🌐 Browser-to-browser communication cuts out the middle-man and lets people communicate on their own terms. No more client/server – just a network of peers, all equal. WebTorrent is the first step in the journey to re-decentralize the Web.
🌐 In the early days, BitTorrent used TCP as its transport protocol. Later, uTP came along promising better performance and additional advantages over TCP. Every mainstream torrent client eventually adopted uTP, and today you can use BitTorrent over either protocol. The WebRTC protocol is the next logical step. It brings the promise of interoperability with web browsers – one giant P2P network made up of all desktop BitTorrent clients and millions of web browsers.
🌐 Some torrent apps like Vuze already support web peers, but we didn't want to wait around for the rest to add support. So basically, WebTorrent Desktop was our way to speed up the adoption of the WebTorrent protocol. By making an awesome torrent app that people really want to use, we increase the number of peers in the network that can share torrents with web peers (i.e. users on websites).
🌐 One of the most exciting uses for WebTorrent is peer-assisted delivery. Non-profit projects like Wikipedia and the Internet Archive could reduce bandwidth and hosting costs by letting visitors chip in. Popular content can be served browser-to-browser, quickly and cheaply. Rarely-accessed content can be served reliably over HTTP from the origin server.
🌐 The Internet Archive actually already updated their torrent files so they work great with WebTorrent. So if you want to embed Internet Archive content on your site, you can do it in a way that reduces hosting costs for the Archive, allowing them to devote more money to actually archiving the web!
还有一些令人兴奋的商业用例,从 CDN 到通过 P2P 交付应用。
🌐 There are also exciting business use cases, from CDNs to app delivery over P2P.
🌐 What are some of your favorite projects that use WebTorrent?
用 WebTorrent 构建的最酷的东西,毫无疑问,可能是 Gaia 3D 星图。它是一个流畅的 3D 交互式银河系模拟。数据通过 torrent 在你的浏览器中加载。飞越我们的恒星系统时,你会被震撼,同时意识到与宇宙的浩瀚相比,我们人类是多么渺小。
🌐 The coolest thing built with WebTorrent, hands down, is probably Gaia 3D Star Map. It's a slick 3D interactive simulation of the Milky Way. The data loads from a torrent, right in your browser. It's awe-inspiring to fly through our star system and realize just how little we humans are compared to the vastness of our universe.
🌐 You can read about how this was made in Torrenting The Galaxy, a blog post where the author, Charlie Hoey, explains how he built the star map with WebGL and WebTorrent.
🌐 We're also huge fans of Brave. Brave is a browser that automatically blocks ads and trackers to make the web faster and safer. Brave recently added torrent support, so you can view traditional torrents without using a separate app. That feature is powered by WebTorrent.
所以,就像大多数浏览器可以渲染 PDF 文件一样,Brave 也可以渲染磁力链接和种子文件。它们只是浏览器本地支持的另一种内容类型。
🌐 So, just like how most browsers can render PDF files, Brave can render magnet links and torrent files. They're just another type of content that the browser natively supports.
🌐 One of the co-founders of Brave is actually Brendan Eich, the creator of JavaScript, the language we wrote WebTorrent in, so we think it's pretty cool that Brave chose to integrate WebTorrent.
🌐 Why did you choose to build WebTorrent Desktop on Electron?
有一种说法认为 Electron 应用很“臃肿”,因为它们在每个应用中都包含了完整的 Chrome 内容模块。在某些情况下,这在一定程度上是正确的(Electron 应用的安装包通常约为 40MB,而特定操作系统的应用安装包通常约为 20MB)。
🌐 There is a meme that Electron apps are "bloated" because they include the entire Chrome content module in every app. In some cases, this is partially true (an Electron app installer is usually ~40MB, where an OS-specific app installer is usually ~20MB).
然而,在 WebTorrent Desktop 的情况下,我们几乎使用了每一个 Electron 功能,并且在正常操作进程中使用了许多 Chrome 功能。如果我们想为每个平台从零实现这些功能,开发我们的应用将需要多几个月甚至数年的时间,或者我们只能发布单个平台版本。
🌐 However, in the case of WebTorrent Desktop, we use nearly every Electron feature, and many dozens of Chrome features in the course of normal operation. If we wanted to implement these features from scratch for each platform, it would have taken months or years longer to build our app, or we would have only been able to release for a single platform.
只是为了让大家了解,我们使用了 Electron 的 dock 集成(显示下载进度)、菜单栏集成(在后台运行)、协议处理器注册(打开磁力链接)、防止休眠(在视频播放时防止休眠)以及 自动更新。至于 Chrome 的功能,我们也用了很多:<video> 标签(播放多种视频格式)、<track> 标签(支持字幕)、拖放支持,以及 WebRTC(在原生应用中使用起来并不简单)。
🌐 Just to get an idea, we use Electron's dock integration (to show download progress), menu bar integration (to run in the background), protocol handler registration (to open magnet links), power save blocker (to prevent sleep during video playback), and automatic updater. As for Chrome features, we use plenty: the <video> tag (to play many different video formats), the <track> tag (for closed captions support), drag-and-drop support, and WebRTC (which is non-trivial to use in a native app).
🌐 Not to mention: our torrent engine is written in JavaScript and assumes the existence of lots of Node APIs, but especially require('net') and require('dgram') for TCP and UDP socket support.
WebTorrent 库作为一个开源副项目已经开发了两年。我们在四周内完成了 WebTorrent Desktop。 Electron 是我们能够如此快速构建和发布应用的主要原因。
🌐 The WebTorrent library has been in development as an open source side project for two years. We made WebTorrent Desktop in four weeks. Electron is the primary reason that we were able to build and ship our app so quickly.
🌐 Just as Node.js made server programming accessible to a generation of jQuery-using front-end programmers, Electron makes native app development accessible to anyone familiar with Web or Node.js development. Electron is extremely empowering.
🌐 Yes, the webtorrent npm package works in Node.js, in the browser, and in Electron. The exact same code can run in all environments – this is the beauty of JavaScript. It's today's universal runtime. Java Applets promised "Write Once, Run Anywhere" apps, but that vision never really materialized for a number of reasons. Electron, more than any other platform, actually gets pretty darn close to that ideal.
🌐 What are some challenges you've faced while building WebTorrent?
在应用的早期版本中,我们在提升用户界面性能方面遇到了困难。我们将种子引擎放在与主应用窗口绘制相同的渲染进程中,结果不出意外,每当种子引擎进行大量 CPU 活动(例如验证从节点接收到的种子块)时,应用就会变得很慢。
🌐 In early versions of the app, we struggled to make the UI performant. We put the torrent engine in the same renderer process that draws the main app window which, predictably, led to slowness anytime there was intense CPU activity from the torrent engine (like verifying the torrent pieces received from peers).
🌐 We fixed this by moving the torrent engine to a second, invisible renderer process that we communicate with over IPC. This way, if that process briefly uses a lot of CPU, the UI thread will be unaffected. Buttery-smooth scrolling and animations are so satisfying.
🌐 Note: we had to put the torrent engine in a renderer process, instead of a "main" process, because we need access to WebRTC (which is only available in the renderer.)
🌐 One thing we'd love to see is better documentation about how to build and ship production-ready apps, especially around tricky subjects like code signing and auto-updating. We had to learn about best practices by digging into source code and asking around on Twitter!
🌐 We think the current version of WebTorrent Desktop is excellent, but there's always room for improvement. We're currently working on improving polish, performance, subtitle support, and video codec support.
🌐 The Electron 1.6.3 beta release contains initial support for the macOS Touch Bar.
新的 Touch Bar API 允许你添加按钮、标签、弹出窗口、颜色选择器、滑块和间隔符。这些元素可以动态更新,并且在与之交互时也会触发事件。
🌐 The new Touch Bar API allows you to add buttons, labels, popovers, color
pickers, sliders, and spacers. These elements can be dynamically updated and
also emit events when they are interacted with.
这是该 API 的第一个版本,因此它将在接下来的几个 Electron 版本中不断发展。请查看发行说明以获取更多更新,并针对任何问题或缺失的功能提交问题。
🌐 This is the first release of this API so it will be evolving over the next
few Electron releases. Please check out the release notes for further updates
and open issues for any problems
or missing functionality.
你可以通过 npm install electron@beta 安装此版本,并在 TouchBar 和 BrowserWindow Electron 文档中了解更多信息。
🌐 You can install this version via npm install electron@beta and learn
more about it in the TouchBar
and BrowserWindow
Electron docs.
🌐 Below is an example of creating a simple slot machine game in the touch bar.
It demonstrates how to create a touch bar, style the items, associate it with a
window, handle button click events, and update the labels dynamically.