tauri

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Tauri

Tauri

Tauri allows building desktop (and now mobile in v2.0) apps using web technologies. It differs from Electron by using the OS Native Webview (WebView2 on Windows, WebKit on macOS/Linux).
Tauri允许使用Web技术构建桌面应用(在v2.0版本中现已支持移动应用)。与Electron不同,它使用操作系统原生Webview(Windows平台为WebView2,macOS/Linux平台为WebKit)。

When to Use

适用场景

  • Small Binaries: Installers are ~3MB (vs 100MB+ for Electron).
  • Security: Strict isolation and permission system.
  • Rust Backend: If you need high-performance background logic.
  • 小巧的安装包:安装包大小约为3MB(相比Electron的100MB+)。
  • 安全性:严格的隔离机制与权限系统。
  • Rust后端:如果你需要高性能的后台逻辑处理。

Core Concepts

核心概念

Frontend Agnostic

与前端框架无关

Use Svelte, React, Vue, or vanilla JS.
可使用Svelte、React、Vue或原生JavaScript进行开发。

Commands (IPC)

命令(IPC)

Interact with Rust backend:
invoke('my_command')
.
与Rust后端交互:
invoke('my_command')

Config (
tauri.conf.json
)

配置文件(
tauri.conf.json

Defines permissions, windows, and bundling settings.
定义权限、窗口以及打包设置。

Best Practices (2025)

2025年最佳实践

Do:
  • Use v2.0 Mobile: Target iOS/Android from the same codebase.
  • Use Commands: Don't run heavy logic in JS. Offload to Rust.
Don't:
  • Don't assume Chrome: You are running on Safari (macOS) or Edge (Windows). Test cross-platform.
建议
  • 使用v2.0的移动功能:通过同一代码库开发iOS/Android应用。
  • 使用命令机制:不要在JS中运行重逻辑,将其转移到Rust中处理。
不建议
  • 不要假设使用Chrome内核:你的应用在macOS上运行在Safari内核,Windows上运行在Edge内核。务必进行跨平台测试。

References

参考资料