Skip to content
Tauri 中文网

Tauri 2.0 稳定版发布

我们非常自豪地终于宣布 Tauri 新主要版本的稳定发布。 欢迎来到 Tauri 2.0!

🌐 We are very proud to finally announce the stable release for the new major version of Tauri. Welcome to Tauri 2.0!

🌐 What is Tauri?

在 Tauri 应用中,前端是用你喜欢的网页前端技术栈编写的。它在操作系统的 WebView 中运行,并与主要用 Rust 编写的应用核心进行通信。

🌐 In a Tauri application the frontend is written in your favorite web frontend stack. This runs inside the operating system WebView and communicates with the application core written mostly in Rust.

a graph showing the IPC bridge between the Application Core and the System's WebView

🌐 When Should I Use Tauri?

如果你勾选下面的任意一个选项,你应该使用 Tauri:

🌐 If you check any of the boxes below, you should use Tauri:

  • 你想要一个适用于所有平台的单一 UI 代码库吗?
  • 你想在他们的平台上(例如 Windows、MacOS、Linux、Android、iOS)尽可能多地接触用户吗?
  • 你是前端网页开发者并且想编写原生应用吗?
  • 你是一个 Rust 开发者,想要编写具有美观界面的应用,并且希望可以用 Rust 来实现吗?
  • 你是否已经有一个现有的网页开发团队,并且希望以低前期投资拓展到原生应用市场?
  • 你是否已有一支现有的 Rust 团队,并希望所有内容都用 Rust 编写?

🌐 How Popular is Tauri?

a graph showing the progression of Tauri GitHub stars over the years, starting with 0 at 2019 and continuing to grow past 80.000 in 2024

在 GitHub 上,Tauri 仓库有约 4,878 个拉取请求 和约 3,570 个已关闭的问题,以及大约 1000 个讨论,截至撰写本文时。要获得更详细的洞察,请查看 Tauri 仓库的 OSSinsight 分析

🌐 On GitHub the Tauri repository has ~4,878 Pull Requests and ~3,570 Issues closed and around 1000 discussions, at the time of writing. To get a more detailed insight take a look at the OSSinsight analysis of the Tauri repository.

我们的Discord 服务器目前大约有17,700名成员。我们看到有很多个人用户的支持、关于 Tauri 本身的问题、直接向工作组提出的问题,或者只是 Tauri 应用开发者之间的讨论。

🌐 Our Discord Server currently has ~17,700 members. We are seeing a lot of individual user support, questions on Tauri itself, questions directly to the working group or just discussions between fellow Tauri app developers.

我们对积极支持的社区感到非常高兴,并感谢所有在 Discord 或 GitHub 上回答或帮助他人的社区成员。

🌐 We are very happy about the positive and supportive community and grateful to all the community members answering or helping others in Discord or GitHub.

我们在 awesome-tauri 上维护了一个精心整理的 Tauri 相关项目、应用、插件、指南等列表。如果你想获取灵感、看看别人正在构建什么,并且理想情况下提交一个 PR 来添加你的项目,可以查看这个列表。

🌐 We maintain a curated list of Tauri related projects, applications, plugins, guides and more at awesome-tauri. Check this out if you want to get inspiration, see what others are building and ideally create a PR to add your project.

当然,这只是一个代表性样本集,我们并不确切知道还有谁在基于 Tauri 开发。

🌐 Of course this is only a representative sample set and we don’t know exactly who else is building on Tauri.

🌐 How Did We Get to 2.0?

2022年6月,我们发布了Tauri 1.0,对桌面操作系统市场以及跨平台应用的构建方式产生了巨大影响。

🌐 In June 2022 we released Tauri 1.0 with a great impact on the desktop operating system market and how cross platform applications can be built.

在2022年底,我们发布了2.0的初始alpha版本,以获取初步反馈并测试移动交互的定义方式。

🌐 In the end of 2022 we released our initial alpha version of 2.0 to get initial feedback and to test out how mobile interaction should be defined.

在最初的 alpha 版本之后,我们花了将近两年的时间在公开情况下完善和改变 Tauri 的架构。当我们自己看清了整体情况后,我们在今年二月发布了 beta 版本。与此同时,我们与外部安全审计员合作,审查我们的决策、架构变更以及更多内容。

🌐 After the initial alpha we spent close to two years refining and changing the architecture of Tauri in public. After we saw the broad picture clear enough ourselves we released the beta in Februrary this year. At the same time we collaborated and worked with external security auditors to check our decisions, architecture changes and much more.

今年八月,我们发布了 2.0 版本的候选发布版,以修复主要漏洞并获取更多来自实际使用的反馈。与此同时,外部审计已经完成并公开。

🌐 This August we published the release candidate version of 2.0 to iron out major bugs and to get more feedback from productive use. At the same time the external audit was concluded and made public.

候选发布版本的时间框架要短得多,主要包括高影响的错误修复和文档改进。在候选发布阶段,我们不得不进行的一些破坏性更改被打包到最后,现在已包含在稳定版本中。如果你主要关心从以前的版本升级,请查看迁移部分

🌐 The release candidate time frame was considerably shorter and consisted mainly of high impact bugfixes and documentation improvements. Some breaking changes we had to make during the release candidate phase were bundled up until the end and are now included in the stable release. Take a look at the migration section if your main concern is upgrading from a previous version.

总的来说,我们花了两年多的时间在改进、新功能、修复漏洞、文档编写、重写以及大量讨论上。

🌐 In total we spent over two years working on improvements, new features, bugfixes, documentation, rewrites and a lot of discussions.

这一切都发生在我们发布了 Tauri 1.x 分支的 8 个小版本,并在多个补丁版本中回溯了安全修复和其他重要的错误修复的时候。

🌐 This all happened while we released 8 minor versions of the Tauri 1.x branch and backported security fixes and other important bug fixes in several patch releases.

🌐 Who Made This Release Possible?

此次发布和 Tauri 本身之所以可能,完全归功于 Lucas 的大量贡献,他多年来不断提供代码修改的支持 ❤️。

🌐 This release and Tauri itself is only possible due to massive amount of contributions from Lucas, who has provided a constant stream of code changes over the years ❤️.

Lucas' contribution graph, with 2744 commits, over 896.000 additions and 688.000 deletions.

显然,Lucas 并不是唯一一个在 Tauri 工作和做出贡献的人,但我们认为他值得特别提及,因为这些年来他一直在承担、启动和支持该项目及其社区。

🌐 Obviously, Lucas is not the only individual working and contributing to Tauri, but we feel he deserves a very special mention for carrying, starting, and supporting the project and its community throughout the years.

我们在 2.0 版本中对 Tauri 仓库有过重大贡献的包括 AmrFabian-LarsTonyChipJasonYuWeiicbSimonOliver Lemasle 以及更多贡献者(来源数据)。

🌐 We have had major contributions to the Tauri repository in 2.0 from Amr, Fabian-Lars, Tony, Chip, Jason, YuWei, icb , Simon, Oliver Lemasle and many more contributors (source data).

我们收到了越来越多的临时贡献者(一次或很少的 PR)。我们对此表示感谢,但如果把每个人都列出来,这里会变成一个很长的名单。

🌐 We received an increasing number of drive-by contributors (one or very few PRs). We are grateful for these, but naming everyone would make this a very long list here.

我们在组织中有很多(!)的代码仓库,这些仓库支持着 Tauri 的成功,没有社区和工作组的贡献,Tauri 不可能走到今天这一步。非常感谢所有参与的人!

🌐 We have a lot(!) of repositories in our organization, which are supporting the success of Tauri and without community and working group contributions Tauri would not be where it is now. A big thank you to everyone involved!

另外,特别感谢并致敬他们在社区中的持续参与,特别是 Fabian-LarsSimon。如果你曾参与 Tauri 的 Discord 或 Github 讨论,你可能会认识他们的名字或头像。

🌐 Another special shout out and thanks for their constant involvement in the community goes to Fabian-Lars and Simon. If you have been involved in Tauri’s Discord or Github discussions you likely know their name or avatar.

如果你曾经在 Google 或 YouTube 上搜索过 Tauri,你可能已经看过 Jacob 的直播。如果不是这样,请务必去看看并订阅,因为他的课程不仅仅是教育性的。

🌐 If you ever searched on Google or YouTube for Tauri, you have probably seen one of Jacob’s streams. If that’s not the case please make sure to check it out and subscribe as his sessions are beyond just educational.

我们心中另一个特别的位置属于 Tauri Board,表扬 Daniel Yvetot-Thompson 为了让 Tauri 为人所知和可持续所付出的无数小时、汗水、血汗和奉献。

🌐 Another special place in our heart has the Tauri Board, highlighting Daniel Yvetot-Thompson for the numerous hours, sweat, blood and dedication to make Tauri known and sustainable.

我们不应该忘记的一件重要事情是,我们获得了该开源项目一个稳定合作伙伴的支持。

🌐 One important thing we should not forget, is that we acquired support from a stable partner of this open source project.

CrabNebula Logo

CrabNebula 授予上述提到的多位人员以及其他未提及的人员,在私有时间以及工作时间参与 Tauri 生态系统的特权。你可以在我们的博客上找到合作公告,在过去的一年中,我们对这一合作感到非常高兴。

仅在2024年,他们就在这个项目上花费了超过2,870小时的工作,这大大推动了项目进展,并让我们今天能够宣布稳定的2.0版本发布。

🌐 In 2024 alone they spent over 2,870 work hours on this project, which massively pushed the progress and allows us to announce the stable 2.0 release today.

如果你还不了解 CrabNebula,一定要查看他们的产品和服务,并考虑如果你不仅希望改善工作流程,还想支持 Tauri 生态系统,与 Tauri 建立共生关系。

🌐 If you were not aware of CrabNebula yet, make sure to check out their products and services and consider the symbiotic relationship with Tauri if you are interested in not only improving your workflows, but also supporting the Tauri ecosystem.

🌐 What Makes 2.0 Great?

在这个重大版本中,我们改进并更改了构建、开发和发布 Tauri 应用的方式和位置的几个方面。在接下来的章节中,我们提供了更详细的见解。这并没有涵盖所有内容,但应该能让你对 Tauri 的期望有一个不错的印象。

🌐 With this major release we improved and changed several aspects of how and where you can build, develop and publish your Tauri app. In the following sections we have more detailed insight. This does not cover everything, but should give you a decent impression on what you can expect from Tauri.

🌐 Getting Started Experience

当你开始使用一个新的框架或工具时,你总是会经历的一个事情是最初的入门或开始使用过程。

🌐 One thing you are always going to go through when starting with a new framework or tool is the initial onboarding or getting started process.

我们重视开发者体验(DX),并努力使这一初始过程像构建和分发最终应用一样无缝。

🌐 We value developer experience (DX) and try to make this initial process as seamless as building and distributing your final application.

为此,我们创建了另一个项目,名为create-tauri-app,简称CTA。这个工具允许开发者从零开始,并在几分钟内而不是几个小时内启动一个运行中的Tauri应用。

🌐 For this we created another project, which is called create-tauri-app or in short CTA. This tool allows developers to start from scratch and get to a running Tauri app in a few minutes instead of hours.

sh <(curl https://create.tauri.app/sh)

当然,在开始构建你的应用之前,你需要在开发系统上安装一些前置条件。为此,我们在官方文档中提供了包含操作系统特定部分的详细指南。

🌐 Of course you need to install some prerequisites on your development system before you can start building your application. For this we have extensive guides with operating system specific sections in our official documentation.

整个入职体验得到了改进,现在还为 iOS 和 Android 启动了移动开发模板。

🌐 This whole onboarding experience has been improved and now also bootstraps mobile development templates for iOS and Android.

🌐 Hot-Module Replacement

在初始入职后,你将定期开发和调试你的 Tauri 应用。我们已经考虑过在 Tauri 1.x 中哪些方法可以改进你的开发流程,并将热模块替换(HMR)扩展到了移动设备和模拟器上。

🌐 After the initial onboarding you will regularly develop and debug your Tauri application. We considered what would improve your development process already in 1.x of Tauri and extended the Hot-Module Replacement (HMR) to mobile devices and emulators.

这意味着对应用前端的所有更改都不需要重新构建整个应用,并且你可以实时预览它在你正在开发的设备或操作系统上的外观。

🌐 This means that all changes to the frontend of your application do not require a rebuild of your whole application and you can live preview how it will look like in the device or operating system your are developing for.

🌐 Plugins

在 Tauri 2.0 中,我们构建了一个更先进的插件系统。我们将许多以前的功能转移到了我们的官方插件中(参见 plugins-workspace),以便社区更容易参与到 Tauri 的贡献中。我们也希望吸引更多插件维护者,并加快新功能的实现过程。

🌐 With Tauri 2.0 we built a more advanced plugin system. We transferred a lot of our previous functionality into our official plugins (see plugins-workspace), to allow the community an easier entry into contributing to Tauri. We also hope to attract more maintainers for plugins and to speed up the process of implementing new features.

向插件的转变还有另一个好处。我们将能够为 Tauri 的核心定义完成标准。我们希望稳定核心功能并提供一个稳定的框架,其中可变的部分主要是提供系统特定功能访问的插件。

🌐 This move to plugins has another benefit. We are going to be able to define a definition of done for Tauri’s core. We hope to stabilize the core functionality and offer a stable framework, where the moving parts are mostly plugins offering access to system specific functionality.

你不再需要理解整个 Tauri 才能改进或实现特定功能。插件通常不依赖其他插件,虽然有一些例外。这意味着要实现新的文件系统访问功能,只需对 fs 插件进行贡献,而不必修改 Tauri 本身。

🌐 You no longer need to understand all of Tauri to improve or implement specific features. The plugins usually do not depend on other plugins, with some exceptions. This means to implement a new file system access functionality it is only required to contribute to the fs plugin instead of Tauri itself.

由于此版本也面向移动平台,因此插件系统也支持移动插件。你可以在 iOS 上使用 Swift 或在 Android 上使用 Kotlin 编写或重用原生代码,并通过 Annotations(Android 上为 @Command)直接向 Tauri 前端暴露函数,在 iOS 上实现 SubclassYourPluginClass: Plugin),或者通过基于 Rust 的 Tauri 命令调用 Swift 或 Kotlin 代码。查看 文档 了解如何编写你自己的插件。

🌐 As this release also targets mobile platforms, the plugin system also supports mobile plugins. You can write or re-use native code in Swift on iOS and Kotlin on Android and directly expose functions to the Tauri frontend using Annotations (@Command on Android), implementing a Subclass (YourPluginClass: Plugin) on iOS, or by invoking the Swift or Kotlin code from a Rust based Tauri command. Check out the documentation on how to write your own plugin.

随着我们发布 Tauri 2.0,官方插件将跟随 Tauri 的主要版本,以便一眼就能看出与 Tauri 主要版本的兼容性。不过,并非所有插件的稳定性都像 Tauri 本身那样高。

🌐 As we are releasing Tauri as 2.0, the official plugins will follow the major version of Tauri to make compatibility with Tauri’s major version visible at a glance. Not all plugins are as stable as Tauri itself though.

每个插件的稳定性是按插件定义的,并将(很快)在插件文档中记录。插件 API 在次要版本中可能会发生变动,但我们会尽量将这些变化降到最低,尤其是对于被认为稳定的插件。

🌐 Each plugin’s stableness is defined per plugin and documented (soon) in the plugin documentation. The plugin API can possibly break in minor versions, but we will try to keep these changes to a minimum, especially for plugins considered stable.

🌐 Mobile Support

这个版本一个备受期待的部分是移动操作系统的支持。Tauri 的前一个版本允许在桌面操作系统上使用单一的 UI 代码库,但现在这扩展到了 iOS 和 Android。

🌐 A very much awaited part of this release is the mobile operating system support. The previous version of Tauri allowed to have a single UI code base for desktop operating systems but now this extends to iOS and Android.

我们已经调查并尝试了不同的解决方案来支持移动端,并决定使用操作系统的原生语言(Swift 和 Kotlin)来为 Rust 代码构建接口,并允许开发者在这些语言中编写部分功能。

🌐 We have investigated and experimented with different solutions to support mobile and decided on using the operating system native language (Swift and Kotlin) to build an interface for the Rust code and to allow developers to write part of their functionality in these languages.

这意味着你可以重用现有的 Swift 或 Kotlin 应用中与系统交互的逻辑,并将其暴露给 Rust 或前端。目前,如上所述,这可以通过插件系统实现。

🌐 This means you can re-use existing logic of your Swift or Kotlin app that interacts with the system and expose it to Rust or the frontend. Right now this works as mentioned above via the plugin system.

我们支持使用模拟器或真实设备进行开发,并提供大量工具以尽可能让开发过程无缝。我们目前对开发者体验并不完全满意,但正在积极改进,以使其达到与桌面体验相当的水平。

🌐 We support development with an emulator or a real device and provide a lot of tooling to make the process as seamless as possible. We are not completely happy about the developer experience at the moment but are actively improving to bring it up to par with the desktop experience.

在移动端,并不是所有官方插件都受支持。有些插件本身设计就不适合移动端,有些则尚未实现对移动端的支持。如果你希望在这方面做出贡献,请查看本文的最后一部分

🌐 On mobile not all of the official plugins are supported. Some are by design not a good fit for mobile and some are just not implemented to support mobile yet. If you would like to contribute on this part check the last section of this post.

🌐 The Allowlist is Dead, Long Live the Allowlist

是的,现在已经没有 allowlist 了,因为我们很快就达到了这个系统的限制。我们将其限定用于 Tauri 核心功能,但它甚至没有涵盖 Tauri 的所有 API。我们的新系统不仅覆盖了 Tauri 的所有核心 API,还支持应用和插件开发者以统一的方式实现自己的访问控制和范围管理。

🌐 Yes, there is no allowlist anymore, as we hit the limits of this system pretty quickly. We made it exclusive for Tauri core features and it did not even cover all of Tauri’s APIs. Our new system not only covers all of Tauri’s core API surface, it also supports app and plugin developers to implement their own access control and scoping with a unified approach.

我们实现的新系统正在使用 permissions - “Tauri 命令的开关切换”scopes - “Tauri 命令的参数验证” 以及 capabilities - “将权限和作用域附加到 Windows 和 WebViews”,来创建一个灵活但易于使用的访问控制系统。

🌐 The new system we implemented is using permissions - “On-off toggles for Tauri commands”, scopes - “Parameter validation for Tauri commands” and capabilities - “Attaching permissions and scopes to Windows and WebViews”, to create a flexible but simple to use access control system.

它允许创建命名的权限或作用域文件,并可以将它们与其他命名权限或作用域重复使用和组合。这使得可以构建包含多个简单或复杂权限和作用域的更细粒度的描述性集合。

🌐 It allows the creation of named permission or scoping files and to re-use and combine them with other named permissions or scopes. This makes it possible to build more fine grained descriptive sets containing several simple or complex permissions and scopes.

作为插件开发者,你可以将多个基础权限抽象为一个 default 权限。这可以基于你的默认安全假设和威胁模型。所有官方 Tauri 插件的默认权限默认情况下都是相对安全的。

🌐 As a plugin developer you can abstract away several base permissions into a default permission. This can be based on your default security assumptions and threat model. All official Tauri plugin default permissions are reasonably secure by default.

作为应用开发者,你可以使用、扩展或减少插件权限。当然,你也可以为你自己的应用构建权限和范围。

🌐 As an app developer you can use, extend or reduce plugin permissions. Of course you can also build permissions and scopes for your own application.

通过这一新增功能,Tauri 的核心现在能够理解来自前端 WebView 的命令调用消息是否被允许到达命令函数。它也能够将配置的作用域附加到消息上。

🌐 With this addition, Tauri’s core is now able to understand if a command invoke message from a frontend WebView is allowed to reach the command function. It is also able to attach the configured scope to the message.

命令实现负责解释和执行范围。你可以在我们的文档中阅读更多关于我们的威胁模型和安全方法的信息。

🌐 The command implementation is responsible for interpreting and enforcing the scope. You can read more about our Threat Model and approach to security in our documentation.

🌐 External Security Audit

v2 的主要变更和架构在测试版和发布候选阶段由 Radically Open Security 独立审计。请花时间阅读 报告,了解更多关于 @gronke@pcwizz 的出色工作。

🌐 The major changes and architecture of v2 was independently audited by Radically Open Security during the beta and release candidate period. Please take your time to read the report and learn more about the awesome work of @gronke and @pcwizz.

整个审计由NLNet的出色团队资助,资金来源于NGI,我们非常感激能够处于这一荣幸的位置,为主要版本获得完全资助的外部安全审计。

🌐 The whole audit was funded by the great folks at NLNet via funding from NGI and we are super grateful to be in the privileged position to get fully funded external security audits for major releases.

这次审计的结果促使我们重新编写了开发服务器的部分暴露方式,特别是针对移动开发。如果没有审计人员的帮助和指导,这次重写是不可能实现的 ❤️。

🌐 The results of this audit caused us to rewrite parts of how our dev server is exposed, specifically for mobile development. Without the help and guidance of the auditors this rewrite would not have been possible ❤️.

此外,我们加强了 iFrame API 的暴露,修复了 fshttp 插件的作用域验证和资源标识符访问,改善了我们的进程间通信稳定性,以及许多其他与安全相关的修复和改进。

🌐 Additionally, we hardened our iFrame API exposure, fixed scope validation and resource identifier access for the fs and http plugin, improved our inter-process communication stability, and many other security related fixes and improvements.

🌐 Inter Process Communication (IPC) Rewrite

随着我们对 IPC 层的重写,我们现在支持长期期待的原始负载功能,并且总体上改变了其底层的工作方式。

🌐 With the rewrite of our IPC layer we now support a long wished feature of Raw Payloads and generally changed how it works under the hood.

以前,所有 IPC 有效载荷都是经过 JSON 序列化和反序列化的,这会造成开销。一旦在前端和后端之间传输超过几千字节的数据,这种影响就会显现出来。

🌐 Previously all IPC payloads were json serialized and deserialized which caused an overhead. This was noticeable once more than a few kilobytes were transfered between frontend and backend.

新系统支持原始请求。这些请求加快了从后端到前端以及反向传输大数据的速度,你可以直接使用原始字节,或者使用你自己的(反)序列化过程(例如 bson、protobuf、avro 等)。

🌐 The new system supports Raw Requests. These speed up the transfer of large data from backend to frontend and vice versa, where you can either use raw bytes directly or use your own (de)serialization process (eg. bson, protobuf, avro and others).

对于直接将文件从文件系统读取到 WebView,我们仍然推荐使用 convertFileSrc 功能,因为如果你不需要在 Rust 后端处理数据,它很可能仍然更快。

🌐 For directly reading files from the filesystem into the WebView we still recommend the convertFileSrc functionality, as it is most likely still faster if you do not need to process the data on the Rust backend.

🌐 Distribution Guides

随着 Tauri 2.0 的推出,分发的多样性大大增加。部分原因是移动生态系统,部分原因是我们的社区贡献。

🌐 With Tauri 2.0 the distribution diversity greatly increased. Partially, due to the mobile ecosystem and partially due to our community contributions.

我们有关于如何向 Apple AppstoreGoogle PlayMicrosoft StoreCrabNebula CloudFlathubSnapcraftAUR 以及更多分发格式发布的官方指南,可参见我们的 分发文档

🌐 We have official guides on how to ship to the Apple Appstore, Google Play, Microsoft Store, CrabNebula Cloud, Flathub, Snapcraft, AUR and more distribution formats in our distribution docs.

🌐 Changelog

本节包含从 1.x 版本的所有更改的简明列表。

🌐 This section contains all changes going from 1.x in a concise list.

显示完整列表

🌐 Added

  • 已添加移动支持。
  • 在不稳定功能标志下添加了多网页视图支持。更多信息请参见 WindowBuilder 和 WebviewBuilder。
  • 已添加 rustls-tls 货物功能标志
  • 在创建 webview 窗口时添加了 shadow 选项,Rust 中的 WebviewWindow::set_shadow 方法以及 JS 中的等效 API。
  • 在 Rust 中添加了 tauri::Webviewtauri::WebviewBuildertauri::WebviewWindowtauri::WebviewWindowBuilder 结构体,在 Js 中添加了等效类。旧的 tauri::Windowtauri::WindowBuilder 行为已移至 tauri::WebviewWindowtauri::WebviewWindowBuilder
  • 已添加 tauri::scope::fs 模块
  • 添加了 tauri::App/AppHandle::default_window_icon 方法。
  • 添加了带有IPC原语的tauri::ipc模块。
  • 添加了 tauri::ipc::Channel 类型和对应的 JS Channel 类型以通过 IPC 发送数据。
  • 在创建 webview 窗口时添加了 incognito 选项。
  • 在创建 webview 窗口时添加了 windowEffects 选项,并添加了 WebviewWindow::set_effects 以尝试在运行时更改效果。
  • 已添加 tauri::path::PathResolver
  • 添加了 tauri::Manager::path 方法以访问新的 PathResolver
  • 在创建 webview 窗口时添加了 visibleOnAllWorkspaces 选项。
  • 添加了 tauri::App/AppHandle::primary_monitorApp/AppHandle::available_monitors 方法。
  • 已添加 tauri::plugin::Builder::on_navigationtauri::plugin::Plugin::on_navigation
  • 已添加 tauri::WebviewWindow::navigate 方法
  • 在 macOS 和 iOS 上添加了 tauri::RunEvent::Opened 以支持深层链接。
  • 在打包工具中添加了文件关联支持。
  • 已添加 tauri::App/AppHandle::cleanup_before_exit 用于手动调用清理逻辑。你应当在此函数返回后立即退出 Tauri 应用,而不要使用任何与 Tauri 相关的 API。
  • 在 Linux 上,添加 tauri::WebviewWindow::default_vbox 方法以获取包含菜单栏和 WebView 的 gtk::Box 的引用。
  • 添加了 linux-libxdo cargo 功能标志(默认禁用),以启用链接到 libxdo,该链接用于使 CutCopyPasteSelectAll 本地菜单项在 Linux 上工作。
  • 在 macOS 上,添加 tauri::WebviewWindow::ns_view 方法以获取指向 NSWindow 内容视图的指针。
  • 添加了 tauri::Builder::register_asynchronous_uri_scheme_protocol 以允许异步解析自定义 URI 方案协议请求,从而防止阻塞主线程。
  • 包括拖放事件的放置和悬停位置。
  • 已添加 tauri::WebviewWindow::set_progress_bar 方法
  • 在创建 webview 窗口时添加了 tauri::WebviewWindow::set_always_on_bottom 方法和 alwaysOnTop 选项。
  • 添加了 tauri::WebviewWindowBuilder::on_page_load 方法。
  • 添加了 common-controls-v6 货运功能标志(默认启用)。
  • 添加了 Window::destroy 以强制关闭窗口。
  • 已添加 tauri::EventId 类型
  • 添加了 tauri::WindowBuilder::on_download 来处理下载请求事件。
  • 添加了 tauri::WebviewWindowBuilder::parent,它是一个方便的封装器,用于 Windows、Linux 和 macOS 上的父功能。
  • 仅在 Windows 上添加了 tauri::WebviewWindowBuilder::owner
  • 仅在 Linux 上添加了 tauri::WebviewWindowBuilder::transient_fortauri::WebviewWindowBuilder::transient_for_raw
  • 添加了 tauri::WebviewWindow::start_resize_draggingtauri::ResizeDirection 枚举。
  • 添加了 tauri::WebviewWindowBuilder::proxy_url 方法。
  • 已添加 tauri::WebviewEvent 枚举
  • 添加了 tauri::RunEvent::WebviewEvent 变体。
  • 添加了 tauri::Builder::on_webview_eventtauri::Webview::on_webview_event 方法。
  • 添加了包含 tauri::image::Imagetauri::image::JsImage 类型以及 tauri::image::include_img! 宏的 tauri::image 模块。
  • 添加了 tauri::is_dev 函数以确定应用是否处于开发模式运行。
  • tauri::Assets 特质上添加了 tauri::Assets::setup 方法,它允许你为自定义资源提供程序运行初始化代码。
  • 添加了 tauri::Rect 结构体。
  • 已添加 tauri::WebviewWindow::set_zoom 方法
  • 在创建 webview 窗口时添加了 zoomHotkeys 选项。
  • 添加了 window.isTauri JS 全局函数,用于检查是否在 Tauri 中运行。
  • 添加了 specta 功能标志,为 AppHandleStateWindowWebviewWebviewWindow 类型添加了 specta 支持。
  • 添加了 tauri::App/AppHandle/WebviewWindow::cursor_position 获取器以获取当前光标位置。
  • 添加了 tauri::App/AppHandle/WebviewWindow::monitor_from_point(x,y) 获取器以从给定点获取监视器。
  • 已添加 tauri::RunEvent::Reopen 来处理 macOS 上点击 Dock 图标的操作。
  • 在 JS app 模块中添加了 defaultWindowIcon 以在 JS 中获取默认的窗口图标。
  • 在 macOS 上添加了 tauri::WebviewWindow::set_title_bar_style 以在运行时设置标题栏。
  • 添加 API 以支持单独设置窗口尺寸限制:
    • 添加了 tauri::WindowBuilder::inner_size_constraintstauri::WebviewWindowBuilder::inner_size_constraints
    • 添加了 tauri::WindowSizeConstraints 结构体
    • 添加了 tauri::Window::set_size_constraintstauri::WebviewWindow::set_size_constraints

🌐 Enhancements

  • 在 IPC 实现上使用自定义协议以提升性能。
  • 增强新创建窗口的居中功能,它在可见后将不再跳到中心位置。
  • custom-protocol 货运功能不再是你的应用所必需的,现在将被忽略。要检查是否在生产环境中运行,请使用 #[cfg(not(dev))] 而不是 #[cfg(feature = "custom-protocol")]
  • 改进了 JS path API,使其在可能的情况下在 Windows 上返回简化路径,即移除 UNC (\\?\) 前缀。
  • 改进了反序列化 Tauri 插件配置时显示的错误消息。
  • 将 gtk 应用 ID 设置为在 tauri.conf.json 中定义的 identifier 以确保应用的唯一性。可以通过将 enableGtkAppId 选项设置为 false 来禁用此功能。
  • 在 Windows 上,本地处理无边框窗口的调整大小,这提高了性能并修复了以前 JS 实现的一些烦恼:
    • 当光标移动到边缘时,不再出现光标闪烁。
    • 即使那里存在 data-tauri-drag-region 元素,也可以从顶部调整大小。
    • 在开始调整大小时,点击不会穿透其后的元素,因此不会再发生意外点击。
  • AppHandle::restartprocess::restart 标记为 发散函数

🌐 Bug Fixes

  • 不再在 IPC 上解包和展开 payload,以便带有名为 cmdcallbackerroroptionspayload 的参数的命令不会破坏 IPC。
  • 修复在事件循环运行时调用 set_activation_policy 的问题。
  • 修复无法阻止从另一个 WebView 关闭窗口的问题。
  • 在 Windows 上,修复装饰窗口在最初显示时不透明的问题,直到调整大小后才透明。
  • 在文件系统范围检查中解析符号链接。
  • 修复 JS basename(path, 'ext') API 的实现,删除所有出现的 ext,而它本应该只删除最后一个。
  • 修复 Windows 退出时窗口白屏闪烁
  • 分别应用 minWidthminHieghtmaxWidthmaxHeight 约束,这修复了一个长期存在的错误,该错误导致这些约束从未被应用,除非宽度和高度同时受约束。

🌐 Changed

  • 当事件循环准备好时,现在会调用窗口创建和设置钩子。
  • 已将 default-tls 功能重命名为 native-tls 并。
  • 将插件设置钩子更改为接受第二个类型为 PluginApi 的参数
  • 更改了 tauri::Window 结构的行为,并将其旧行为移到新的 tauri::WebviewWindow 类型。
  • 已将 tauri::api::path 模块移动到 tauri::path
  • 将所有函数从 tauri::api::path 移动到 tauri::path::PathResolver 上作为方法
  • 已将 system-tray 功能标志重命名为 tray-icon
  • tauri::App::handletauri::Manager::app_handle 方法修改为返回对 AppHandle 的引用,而不是返回拥有的值。
  • tauri::Builder::register_uri_scheme_protocol 更改为返回 http::Response 而不是 Result<http::Response>。要返回错误响应,请手动创建状态码 >= 400 的响应。
  • Windows 和 Android 上的自定义协议现在使用 http 方案,而不是 https
  • 已将 tauri::Env.args 更改为 tauri::Env.args_os,现在使用 OsString 而不是 String
  • 已将 TAURI_AUTOMATION 环境变量更改为 TAURI_WEBVIEW_AUTOMATION
  • tauri::Builder::invoke_system 改为接受引用而不是拥有的值。
  • tauri::Builder::invoke_systemtauri::Builder::on_page_load 钩子修改为接受 tauri::Webview 参数,而不是 tauri::Window
  • 已将 tauri::command 模块的项目移到 tauri::ipc 模块,以便其导入名称不会与 tauri::command 宏冲突。
  • tauri::App::run_iteration 改为接受回调函数,并移除了其返回值。
  • AppHandle::exitAppHandle::restart 更改为触发 RunEvent::ExitRequestedRunEvent::Exit
  • 已将 tauri::WebviewWindowBuilder::owner_window 重命名为 tauri::WebviewWindowBuilder::owner_raw,将 tauri::WebviewWindowBuilder::parent_window 重命名为 tauri::WebviewWindowBuilder::parent_raw
  • 已将 window-data-url 功能标志重命名为 webview-data-url
  • tauri::WebviewWindow::close 更改为触发关闭请求事件,而不是强制关闭窗口。使用 tauri::WebviewWindow::destroy 来强制关闭。
  • 已将 icon-icoicon-png 功能标志分别重命名为 image-icoimage-png
  • 已移除 tauri::Icon 枚举,请改用新的 tauri::Image 类型。所有之前接受 tauri::Icon 的 API 已修改为接受 tauri::Image
  • tauri::Context 结构和 tauri::Assets 特质修改为拥有一个 R: Runtime 泛型。
  • 已将 tauri::Context::assets_mut 重命名为 tauri::Context::set_assets
  • tauri::Context 类型更改为不包含 <A: Assets> 泛型,以便可以将资源实现与 Context::set_assets 互换。
  • tauri::Context::assets 更改为返回 &dyn Assets 而不是 &A 泛型。
  • tauri::FileDropEvent 枚举重命名为 tauri::DragDropEvent 并重命名其变体。还重命名了 js 事件
  • tauri::WindowEvent::FileDrop 枚举变体重命名为 tauri::WindowEvent::DragDrop
  • 已将文件删除发出的事件重命名为 tauri://drag-entertauri://drag-overtauri://drag-droptauri://drag-leave
  • 已将 tauri::WebviewWindow::disable_file_drop_handler 重命名为 tauri::WebviewWindow::disable_drag_drop_handler
  • 已将 tauri::WebviewWindow::url getter 更改为返回结果。
  • 已更改 tauri::Env.args_os,以包含二进制路径,以前它被跳过了。
  • 在 JS window 模块中将 getAllgetCurrent 重命名为 getAllWindowsgetCurrentWindow,但你可能想要从 webviewWindow 模块中使用 getAllWebviewWindowsgetCurrentWebviewWindow

🌐 Removed

  • reqwest-* 货运功能已被移除
  • UpdaterEvent
  • 已移除 tauri::api 模块,并将其移到 plugins-workspace 仓库中的独立插件中。
  • 已移除 tauri::scope::IpcScope
  • 已移除 tauri::scope::ipc 模块及其所有类型。
  • 已移除 tauri::scope::FsScope,请使用 tauri::scope::fs::Scope
  • 已移除 tauri::scope::GlobPattern,请使用 tauri::scope::fs::Pattern
  • 已移除 tauri::scope::FsScopeEvent,请使用 tauri::scope::fs::Event
  • 已移除 tauri::scope::HttpScope
  • 已移除 tauri::scope::ShellScope
  • 已移除 tauri::scope::ShellScopeAllowedCommand
  • 已移除 tauri::scope::ShellScopeAllowedArg
  • 已移除 tauri::scope::ExecuteArgs
  • 已移除 tauri::scope::ShellScopeConfig
  • 已移除 tauri::scope::ShellScopeError
  • 已移除 linux-protocol-headers 货物功能标志,现在默认启用。
  • 移除了 tauri::path::Errortauri::path::Result 并将其变体添加到 tauri::Error
  • 已移除 tauri::path::Resulttauri::plugin::Result 别名,你应该使用 tauri::Result 或你自己的 Result 类型。
  • 已将 tauri::Builder::on_page_load 处理程序更改为接受引用。页面加载钩子现在在加载开始和结束事件时触发,若要确定触发它的原因,请参见 tauri::PageLoadPayload::event 字段。
  • 移除了 tauri::GlobalWindowEvent 结构体,并将其字段拆开直接传递给 tauri::Builder::on_window_event
  • 已移除 tauri::EventHandler 类型。
  • tauri::Context::default_window_icon_mut 重命名为 tauri::Context::set_default_window_icon 并更改为接受 Option<T>

🌐 Config restructure

根据 RFC#5 重构了 Tauri 配置:

🌐 Restructured Tauri config per RFC#5:

  • 已将 package.productNamepackage.versiontauri.bundle.identifier 字段移动到顶层。
  • 已移除 package 对象。
  • 已将 tauri 对象重命名为 app
  • 已将 tauri.bundle 对象移动到顶层。
  • build.distDir 字段重命名为 frontendDist
  • 已将 build.devPath 字段重命名为 devUrl,并且将不再接受路径,它只接受 URL。
  • 已将 tauri.pattern 移动到 app.security.pattern
  • 已移除 tauri.bundle.updater 对象,其字段已被移动到 plugins.updater 对象下的更新插件中。
  • 已将 build.withGlobalTauri 移动到 app.withGlobalTauri
  • 已将 tauri.bundle.dmg 对象移动到 bundle.macOS.dmg
  • 已将 tauri.bundle.deb 对象移动到 bundle.linux.deb
  • 已将 tauri.bundle.appimage 对象移动到 bundle.linux.appimage
  • 从每个打包配置对象中删除了所有许可证字段,而是添加了 bundle.licensebundle.licenseFile
  • AppUrl 重命名为 FrontendDist,并重构其变体以使其更明确。
  • 已将 tauri.window.fileDropEnabeld 重命名为 app.window.dragDropEnabled

🌐 Migration

在我们努力使从之前版本的 Tauri 迁移尽可能顺利的同时,我们提供了文档来指导你完成这一过程。

🌐 As we try to make the migration from previous Tauri versions as smooth as possible, we have documentation available to guide you through the process.

如果你正在从 1.x 版本迁移,请查看此 迁移指南

🌐 If you are migrating from a 1.x release please check out this migration guide.

要从 2.0 测试版或候选发布版升级,请查看此 迁移指南

🌐 For upgrading from a 2.0 beta or release candidate version check out this migration guide.

Tauri v2 CLI 包含一个 migrate 命令,它可以自动补齐大部分流程并帮助你完成迁移:

🌐 The Tauri v2 CLI includes a migrate command that automates most of the process and helps you finish the migration:

npm install @tauri-apps/cli@next
npm run tauri migrate

🌐 Call To Action

如果你熟悉 Tauri 并且在你的使用过程中已经使用过它,请花一些时间查看 Github 讨论Github 问题。也许你已经解决了其他刚接触 Tauri 的新手目前正在遇到的问题。

🌐 If you are familiar with Tauri and have used it already during your journey, please take your time to check out the Github Discussions, Github Issues. Maybe you have already solved the issues your fellow newcomers to Tauri are experiencing right now.

如果你认为你看到的一些问题是通用的并且应该在某处记录,我们很可能在我们的官方文档中有一个完美的地方来做这件事。

🌐 If you think that some of these problems you have seen are generic and should be documented somewhere we probably have the perfect place for it in our official documentation.

如果想贡献改进或新增内容,我们欢迎在 tauri-docs 仓库提交 PR。不过请确保你已经阅读了 贡献指南

🌐 To contribute improvements or additions we are open for PRs in the tauri-docs repository. Please make sure you’ve read the guidelines for contribution though.

如果你能够理解并将当前文档翻译成你的母语,我们非常感谢你对我们文档的内容翻译

🌐 If you are in the position to understand and translate the current documentation into your native language we appreciate content translations to our documentation.

围绕 Tauri 的代码仓库也在寻找贡献者,特别是我们希望有更多的维护者和贡献者加入 plugin-workspace

🌐 The repositories surrounding Tauri are also looking for contributors, especially we would love more maintainers and contributors to the plugin-workspace.

插件现在是 Tauri 开发和用户体验的重要组成部分,各种形式的帮助都受到欢迎。从讨论新的插件创意,与他人合作编写新插件,贡献 PR 修复现有插件中的错误,或者在插件自述文件或代码中记录奇怪的解决方法和知识。

🌐 The plugins are now a major part of the development and user experience of Tauri and all kind of help is welcome there. From discussing new plugin ideas, collaborating with others to write new plugins, contributing PRs to fix bugs in existing plugins or documenting weird workarounds and knowledge in the plugin readme or code.

🌐 Roadmap

你们可能期待我们提供明确的未来计划和新的酷点子。我们目前确实有一些想法,但还没有确定2.x之后的路线图。

🌐 You probably expect solid plans for the future and new cool ideas from us. We currently have some in mind but have not committed to a roadmap beyond 2.x yet.

我们主要想专注于通过更好的开发者体验、更完善的文档和更少的重大漏洞来改进这个主版本。我们尤其希望改善移动开发体验,并使从创意到发布应用的整个流程尽可能无缝。

🌐 We mainly want to focus on improving this major version with a better developer experience, better documentation and less impactful bugs. We want to improve especially the mobile development experience and make the whole flow from idea to published application as seamless as possible.

我们认为未来值得至少提及的一些事项:

🌐 Things on our radar for the future we feel we should mention at least:

  • 提供或打包 Chromium Embedded Framework (CEF) 作为 Linux 上 WebKit2GTK 的替代方案
  • Servo 作为 Tauri WebView (POC 在 Wry)

如果你想在这些想法上进行合作,请告诉我们,我们会一起想办法解决。

🌐 If you want to collaborate on these ideas, please let us know and we will figure it out together.


Tauri 中文网 - 粤ICP备13048890号
Nodejs.cn 旗下网站