Skip to main content

搜索

· 9 min read

Electron 网站有了一个新的搜索引擎,可以即时显示 API 文档、教程、与 Electron 相关的 npm 包等的搜索结果。

🌐 The Electron website has a new search engine that delivers instant results for API docs, tutorials, Electron-related npm packages, and more.

Electron Search Screenshot


学习像 Electron 这样的新技术或框架可能让人感到畏惧。一旦你度过了[快速入门]阶段,学习最佳实践、找到合适的 API 或发现能帮助你构建理想应用的工具可能会变得困难。我们希望 Electron 网站能成为一个更好的工具,让你更快、更轻松地找到构建应用所需的资源。

🌐 Learning a new technology or framework like Electron can be intimidating. Once you get past the quick-start phase, it can be difficult to learn best practices, find the right APIs, or discover the tools that will help you build the app of your dreams. We want the Electron website to be a better tool for finding the resources you need to build apps faster and more easily.

访问 electronjs.org 的任意页面,你都会在页面顶部看到新的搜索输入框。

🌐 Visit any page on electronjs.org and you'll find the new search input at the top of the page.

搜索引擎

🌐 The Search Engine

当我们最初开始给网站添加搜索功能时,我们使用 GraphQL 作为后端自己开发了搜索引擎。使用 GraphQL 非常有趣,搜索引擎的性能也不错,但我们很快意识到,构建搜索引擎不是一件简单的事情。像多词搜索和拼写错误检测这样的功能需要大量工作才能实现正确。与其重复造轮子,我们决定使用现有的搜索解决方案:Algolia

🌐 When we first set about adding search to the website, we rolled our own search engine using GraphQL as a backend. GraphQL was fun to work with and the search engine was performant, but we quickly realized that building a search engine is not a trivial task. Things like multi-word search and typo detection require a lot of work to get right. Rather than reinventing the wheel, we decided to use an existing search solution: Algolia.

Algolia 是一项托管搜索服务,已迅速成为流行开源项目(如 React、Vue、Bootstrap、Yarn 以及许多其他)的首选搜索引擎。

🌐 Algolia is a hosted search service that has quickly become the search engine of choice among popular open source projects like React, Vue, Bootstrap, Yarn, and many others.

以下是一些使 Algolia 非常适合 Electron 项目的功能:

🌐 Here are some of the features that made Algolia a good fit for the Electron project:

  • InstantSearch.js 在你输入时提供结果,通常大约在1毫秒内。
  • 容错拼写 意味着即使你输入 widnow,仍然可以获得结果。
  • 高级查询语法 使 "exact quoted matches"-exclusion 成为可能。
  • API 客户端 是开源的并且有良好的文档。
  • 分析 告诉我们人们最常搜索的内容,以及他们在搜索但找不到的内容。这将为我们提供有关如何改进 Electron 文档的宝贵见解。
  • Algolia 对开源项目是免费的 链接

API 文档

🌐 API Docs

有时候你知道自己想要完成的目标,但不清楚具体的操作方法。Electron 有超过 750 个 API 方法、事件和属性。没有人能轻松记住它们所有,但计算机在这方面很擅长。通过使用 Electron 的 JSON API 文档,我们将所有数据整理到 Algolia 中,现在你可以轻松找到你所需要的准确 API。

🌐 Sometimes you know what you want to accomplish, but you don't know exactly how to do it. Electron has over 750 API methods, events, and properties. No human can easily remember all of them, but computers are good at this stuff. Using Electron's JSON API docs, we indexed all of this data in Algolia, and now you can easily find the exact API you're looking for.

想调整窗口大小吗?搜索 resize 并直接跳到你需要的方法。

🌐 Trying to resize a window? Search for resize and jump straight to the method you need.

教程

🌐 Tutorials

Electron 拥有不断增长的教程集合,以补充其 API 文档。现在,你可以更轻松地在相关 API 文档旁边找到特定主题的教程。

🌐 Electron has an ever-growing collection of tutorials to complement its API documentation. Now you can more easily find tutorials on a given topic, right alongside related API documentation.

在寻找安全最佳实践吗?请搜索 security

🌐 Looking for security best practices? Search for security.

npm 软件包

🌐 npm Packages

目前 npm 注册表中已有超过 70 万个软件包,要找到你需要的那个并不总是容易的。为了更方便地发现这些模块,我们创建了 electron-npm-packages,这是一个包含注册表中 3400 多个专门为 Electron 使用而构建的模块的集合。

🌐 There are now over 700,000 packages in the npm registry and it's not always easy to find the one you need. To make it easier to discover these modules, we've created electron-npm-packages, a collection of the 3400+ modules in the registry that are built specifically for use with Electron.

Libraries.io 的团队创建了 SourceRank,一个基于代码、社区、文档和使用等多种指标来评分软件项目的系统。我们创建了一个 sourceranks 模块,其中包含 npm 注册表中每个模块的评分,并且我们使用这些评分来对包的结果进行排序。

🌐 The folks at Libraries.io have created SourceRank, a system for scoring software projects based on a combination of metrics like code, community, documentation, and usage. We created a sourceranks module that includes the score of every module in the npm registry, and we use these scores to sort the package results.

想要 Electron 内置 IPC 模块的替代方案吗?搜索 is:package ipc

🌐 Want alternatives to Electron's built-in IPC modules? Search for is:package ipc.

Electron 应用

🌐 Electron Apps

使用 Algolia 索引数据很容易,因此我们从 electron/apps 添加了现有的应用列表。

🌐 It's easy to index data with Algolia, so we added the existing apps list from electron/apps.

尝试搜索 musichomebrew

🌐 Try a search for music or homebrew.

过滤结果

🌐 Filtering Results

如果你以前使用过 GitHub 的代码搜索,你可能已经了解它的以冒号分隔的键值过滤器,例如 extension:jsuser:defunkt。我们认为这种过滤技术非常强大,因此我们在 Electron 的搜索中添加了一个 is: 关键字,可以让你只显示单一类型的结果:

🌐 If you've used GitHub's code search before, you're probably aware of its colon-separated key-value filters like extension:js or user:defunkt. We think this filtering technique is pretty powerful, so we've added an is: keyword to Electron's search that lets you filter results to only show a single type:

键盘导航

🌐 Keyboard Navigation

人们喜爱键盘快捷键!新的搜索功能可以在不离开键盘的情况下使用:

🌐 People love keyboard shortcuts! The new search can be used without taking your fingers off the keyboard:

  • / 聚焦搜索输入
  • esc 聚焦搜索输入框并清除内容
  • 向下 移动到下一个结果
  • 向上 移动到上一个结果,或搜索输入
  • 回车 打开一个结果

我们还开源了模块,它可以实现这种键盘交互。它是为 Algolia InstantSearch 设计的,但已通用化,可兼容不同的搜索实现。

🌐 We also open-sourced the module that enables this keyboard interaction. It's designed for use with Algolia InstantSearch, but is generalized to enable compatibility with different search implementations.

我们期待你的反馈

🌐 We want your feedback

如果你在使用新的搜索工具时遇到任何问题,我们很乐意听取你的意见!

🌐 If you encounter any issues with the new search tool, we want to hear about it!

提交反馈的最佳方式是在 GitHub 的相应仓库中提交问题:

🌐 The best way to submit your feedback is by filing an issue on GitHub in the appropriate repository:

致谢

🌐 Thanks

特别感谢 Emily JordanVanessa Yuen 构建了这些新的搜索功能,感谢 Libraries.io 提供 SourceRank 分数,以及 Algolia 团队帮助我们启动项目。🍹

🌐 Special thanks to Emily Jordan and Vanessa Yuen for building these new search capabilities, to Libraries.io for providing SourceRank scores, and to the team at Algolia for helping us get started. 🍹