0


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/[email protected]","icons/icon.icns","icons/icon.ico"],"identifier":"com.tauri.dev.webneat.focus","targets":"all"},

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

标签: rust ui 开发语言

本文转载自: https://blog.csdn.net/weixin_42453691/article/details/130477823
版权归原作者 将离❦ 所有, 如有侵权,请联系我们删除。

“Rust桌面应用开发工具-----Tauri(Yew UI 模版)安装与测试”的评论:

还没有评论