Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tauri: a framework that allows you to build cross-platform apps #408

Open
hhstore opened this issue Jun 26, 2023 · 8 comments
Open

Tauri: a framework that allows you to build cross-platform apps #408

hhstore opened this issue Jun 26, 2023 · 8 comments

Comments

@hhstore
Copy link
Owner

hhstore commented Jun 26, 2023

📖 Abstract:

  • ✅ Tauri: Rust 跨平台(Windows/MacOS/Linux/iOS/Android) App 开发框架, 基于 WebView.
  • ✅ v2 版本, 已支持 mobile app 开发.

💯 Related:

@hhstore
Copy link
Owner Author

hhstore commented Jun 26, 2023

Tauri: 跨平台 app 开发框架

适用场景:

  • ✅️ desktop app 开发
  • ✅️ mobile app 开发

核心优势:

  • ✅️ 打通 rust + js 2大生态, 兼顾开发效率性能.
  • ✅️ 100% 复用 前端生态能力.
  • ✅️ 100% 底层 OS API 操作能力, 基于 rust 这种 系统编程语言, 无所不能.

势能:

  • ✅️ 随着2大生态(rust+js)持续不断繁荣, tauri 的能力也会持续爆炸.

原理:

  • ✅ rust + OS 系统自带 webview 方案, 无需打包 浏览器内核. (部分低端老旧 OS平台, 需要单独安装 webview)
  • ✅ 区别 electron 这种打包浏览器内核的方案.

对比 electron/react-native:

  • ✅ 技术路线: 类似, 都是基于前端方案(vue.js / react.js 等) 写 UI 层.
  • ✅ 优点: 包体积更小(1~2 MB), 启动更快. 相比 electron 动辄 200MB+.
  • ✅ 缺点: 兼容性不如 electron, 对老 OS 支持弱.(考虑拿低端用户不当人, 这个可以忽略)

对比 flutter:

  • ✅ 技术路线: 不同. flutter 是偏原生的 UI 方案.
  • ✅ 优点: desktop app, 比 flutter 完备, flutter 坑非常多, 不建议使用.
  • ✅ 缺点: mobile app, 中期, 不如 flutter.

@hhstore
Copy link
Owner Author

hhstore commented Jun 26, 2023

v2 初始化:

准备工作:

安装 cli:

v2:

  • ✅️ 命令行执行: 基于 rust + cargo
cargo install tauri-cli --version "^2.0.0-alpha"

cargo tauri -h

# 查看版本:
cargo tauri -V

# 初始化:
cargo tauri init
  • ✅️ 前端项目里, 执行:
# 添加依赖:
yarn add -D @tauri-apps/cli@next
yarn add @tauri-apps/api@next

# 依赖:
yarn add -D internal-ip
pnpm add -D internal-ip


# 初始化项目: 生成 tauri 目录
yarn tauri init

v1:

  • ✅️ 前端项目里, 执行:
pnpm add -D @tauri-apps/cli
yarn add -D @tauri-apps/cli

# 初始化:
yarn tauri init

初始化 mobile app 目录:

# 小坑: 要设置环境变量:
TAURI_APPLE_DEVELOPMENT_TEAM="a24z" cargo tauri ios init
TAURI_APPLE_DEVELOPMENT_TEAM="a24z" cargo tauri android init

# iOS:
pnpm tauri ios init
yarn tauri ios init

# Android:
pnpm tauri android init
yarn tauri android init

本地运行+调试:

  • ✅️ 运行:
# iOS:
yarn tauri ios dev [--open]

# Android
yarn tauri android dev [--open]
  • ✅️ 打包 app:
yarn tauri ios build
yarn tauri android build

@hhstore
Copy link
Owner Author

hhstore commented Jun 26, 2023

1

5 similar comments
@hhstore
Copy link
Owner Author

hhstore commented Jun 26, 2023

1

@hhstore
Copy link
Owner Author

hhstore commented Jun 26, 2023

1

@hhstore
Copy link
Owner Author

hhstore commented Jun 26, 2023

1

@hhstore
Copy link
Owner Author

hhstore commented Jun 26, 2023

1

@hhstore
Copy link
Owner Author

hhstore commented Jun 26, 2023

1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant