Rust桌面应用开发工具-----Tauri(Yew UI 模版)安装与测试

Rust桌面应用开发工具-----Tauri(Yew UI 模版)安装与测试

最近在学习rust,想要了解一下关于rust在桌面应用开发方面的工具。。。

默认前提

已经安装好了Rust ,我的测试环境是在macos系统进行的。其他系统注意阅读官方的操作文档。

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

MacOs系统环境准备
关于C的开发依赖

xcode-select --install

更新一下rust

rustup update

安装

#下载
cargo install create-tauri-app 
#运行,会给你一些支持的模版,类似Yew一类的
cargo create-tauri-app

运行之后会有如下的一些提示

#项目名称
? Project name (tauri-app)#开发语言,因为在学rust,所以我选了rust,用ts或js的选第一个
? Choose which language to use for your frontend ›
❯ TypeScript / JavaScript  (pnpm, yarn, npm)
  Rust 
#一些UI模版,了解不多,选了第二个Yew,了解的人可以写个博客,我去取取经。
? Choose your UI template ›
❯ Vanilla
  Yew 
  Leptos 
  Sycamore 
#结束了
Template created! To get started run:
  cd 项目名称
  cargo tauri dev

测试

根据提示运行测试一下

cargo tauri dev

有个报错,wasm-bindgen没下载成功,解决一下

        Warn Waiting for your frontend dev server to start on http://localhost:1420/...
2023-05-03T12:45:25.132292Z  INFO installing wasm-bindgen
2023-05-03T12:45:25.178542Z ERROR ❌ error
error from HTML pipeline

Caused by:
    0: error from asset pipeline
    1: error while getting archive entry
    2: numeric field did not have utf-8 text: E�L�u� when getting cksum for WL���"

解决

cargo install --locked wasm-bindgen-cli

再运行就好了, 运行结果如下
在这里插入图片描述

release版

想要发布release版,直接使用一下命令

cargo tauri build

如果有以下错误:

Error You must change the bundle identifier in `tauri.conf.json > tauri > bundle > identifier`. The default value `com.tauri.dev` is not allowed as it must be unique across applications.

修改tauri.conf.json中的语句:
“identifier”:“com.tauri.dev"
"identifier": "com.tauri.dev.webneat.focus"

"bundle": {
      "active": true,
      "icon": [
        "icons/32x32.png",
        "icons/128x128.png",
        "icons/128x128@2x.png",
        "icons/icon.icns",
        "icons/icon.ico"
      ],
      "identifier": "com.tauri.dev.webneat.focus",
      "targets": "all"
    },

结果如下:
target/release/bundle/dmg文件中会有一个.dmg文件
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值