Tauri打包

官网:https://tauri.app/zh-cn/v1/guides/getting-started/prerequisites/#windows

1.环境安装

  1. Microsoft Visual Studio C++ 生成工具​
    您需要安装 Microsoft C++ 生成工具。 最简单的方法是下载 Visual Studio 2022 生成工具。 进行安装选择时,请勾选 “C++ 生成工具” 和 Windows 10 SDK。
    使用 Visual Studio 生成工具 2022 安装程序,并勾选 “C++ 构建工具” 和 “Windows 10 SDK”。
  2. WebView2​
    On Windows 10 (Version 1803 and later with all updates applied) and Windows 11, the Webview2 runtime is distributed as part of the operating system.
    Tauri 需要 WebView2 才能在 Windows 上呈现网页内容,所以您必须先安装 WebView2。 最简单的方法是从微软网站下载和运行常青版引导程序。
    安装脚本会自动为您下载适合您架构的版本。 不过,如果您遇到问题 (特别是 Windows on ARM),您可以自己手动选择正确版本。
  3. Rust​
    最后,请前往 https://www.rust-lang.org/zh-CN/tools/install 来安装 rustup (Rust 安装程序)。 请注意,为了使更改生效,您必须重新启动终端,在某些情况下需要重新启动 Windows 本身。
    安装 Tauri
    主要第一次运行需要下载很多包
    其中一个https://github.com/wixtoolset/wix3/releases/download/wix3112rtm/wix311-binaries.zip
    我们可以手动解压放到C:\Users\用户\AppData\Local\tauri\WixTools,如果目录不存在就自己手动建
    在这里插入图片描述

2.打包流程

第一次运行打包会很慢,可以参考 https://blog.csdn.net/rznice/article/details/112424406
前提的是已经准备好了html工程

tauri init 

执行了之后会弹出这些问题。基本上选默认即可
What is your app name?
应用名。这个名字会作为打包后应用的正式名称。
What should the window title be?
默认窗口名称。这个会作为我们打开应用窗口的名称,后续我们不需要这个窗口的话我们可以在 tauri.conf.json 的 hiddenTitle 字段去隐藏它。
Where are your web assets (HTML/CSS/JS) located relative to the /src-tauri/tauri.conf.json file that will be created?
生产环境下的文件路径。也就是前端项目打包之后的项目路径,这个路径相对于 /src-tauri/tauri.conf.json 路径。FocusTide 项目打包产物放在项目的 dist 文件夹中,所以我们填 …dist。
What is the URL of your dev server?
开发环境下的服务路径。FocusTide 项目开发下的服务路径为 http://localhost:3000。
What is your frontend dev command?
前端启动开发命令。FocusTide 项目启动开发命令是 yarn dev。
What is your frontend build command?
前端打包命令。FocusTide 项目的打包命令是 yarn generate。
此时的文件目录结构是
在这里插入图片描述

npm run tauri dev

报错npm ERR! missing script: tauri 在 package.json scripts 中添加 tauri

报错npm ERR! missing script: dev 在 tauri.conf.json 配置文件中 beforeDevCommand 参数 的 值错误,应该是React 项目 package.json 里的 项目启动命令。

在这里插入图片描述

报错参考:https://blog.csdn.net/weixin_43387812/article/details/129097255

npm run tauri build 或者 tauri build 

可能到时候需要修改下tauri.conf.json里面的identifier。

打包成功

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

镜中先生

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值