Skip to main content

搜索

· 12 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 这样的新技术或框架可能会令人望而生畏。一旦你度过了 quick-start 阶段,学习最佳实践、找到合适的 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:

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:

  • / 聚焦搜索输入

    ¥/ focuses the search input

  • esc 聚焦搜索输入并清除它

    ¥esc focuses the search input and clears it

  • down 移动到下一个结果

    ¥down moves to the next result

  • up 移动到上一个结果或搜索输入框

    ¥up moves to the previous result, or the search input

  • enter 打开结果

    ¥enter opens a result

我们还开源了支持这种键盘交互的 module。它设计用于 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. 🍹