字玩FontPlayer开发笔记9 Tauri2打包应用

字玩FontPlayer开发笔记9 Tauri2打包应用

字玩FontPlayer是笔者开源的一款字体设计工具,使用Vue3 + ElementUI开发,源代码:github | gitee

笔记

字玩目前是用Electron进行桌面端应用打包,但是性能体验不太好,一直想替换成Tauri。Tauri的功能和Electron类似,都可以把前端代码打包生成桌面端(比如Windows和Mac)应用。Tauri只使用系统提供的WebView,不像Electron一样内置Chromium和Node.js,性能体验更佳。

最近开始着手替换成Tauri,前几天把基本功能迁移之后,今天开始打包测试,记录一下。

Tauri配置

在tauri-src/icons中将默认图标替换成自己的图标,然后在配置文件中修改一下图标配置。我的配置:

json 复制代码
{
  "$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
  "productName": "字玩",
  "version": "0.1.0",
  "identifier": "com.fontplayer.app",
  "build": {
    "frontendDist": "../dist",
    "devUrl": "http://localhost:5173",
    "beforeDevCommand": "npm run dev",
    "beforeBuildCommand": "npm run build"
  },
  "app": {
    "windows": [
      {
        "title": "字玩",
        "width": 1280,
        "height": 800,
        "resizable": true,
        "fullscreen": false
      }
    ],
    "security": {
      "csp": null
    }
  },
  "bundle": {
    "active": true,
    "targets": "all",
    "icon": [
      "icons/icon.png",
      "icons/icon.icns",
      "icons/icon.ico"
    ]
  }
}
打包命令
bash 复制代码
npx tauri build

运行后系统会自动执行前端部分的打包,然后在利用生成的dist打包Tauri应用

打包MacOS Intel芯片应用

npx tauri build只打包默认的应用,有时我们还需要打包特定的应用。比如对Mac端笔者需要分别打包Intel芯片和Apple芯片的应用等,这时候我们需要添加特定Target。

添加Target:

bash 复制代码
rustup target add x86_64-apple-darwin

执行打包命令:

bash 复制代码
npx tauri build --target x86_64-apple-darwin
打包MacOS Apple芯片应用

npx tauri build只打包默认的应用,有时我们还需要打包特定的应用。比如对Mac端笔者需要分别打包Intel芯片和Apple芯片的应用等,这时候我们需要添加特定Target。

添加Target:

bash 复制代码
rustup target add aarch64-apple-darwin

执行打包命令:

bash 复制代码
npx tauri build --target aarch64-apple-darwin
打包Windows端64位应用

如果在Mac电脑中打包Windows应用的话,首先需要安装工具链:

bash 复制代码
brew install mingw-w64

添加Target:

bash 复制代码
rustup target add x86_64-pc-windows-gnu

执行打包命令:

bash 复制代码
npx tauri build --target x86_64-pc-windows-gnu
相关推荐
Fireworks21 分钟前
深入vue3源码解读 -- 1、响应式的基础概念
前端
程序员黑豆21 分钟前
JDK 下载安装与配置详细教程
java·前端·ai编程
hunterandroid25 分钟前
文件存储:内部存储与外部存储
前端
NorBugs1 小时前
飞机大战 Low 版 (Made in AI)
前端
angerdream1 小时前
Android手把手编写儿童手机远程监控App之agentweb如何实现全屏
前端
星栈2 小时前
10 分钟跑起第一个 Dioxus 应用:`dx` CLI、`rsx!` 和热更新好不好用
前端·rust·前端框架
奋斗吧程序媛2 小时前
补充一个小知识点:有关@click.native
前端·vue.js
触底反弹2 小时前
🚀 手把手用 HTML5 Canvas 从零打造飞机大战游戏,代码全开源!
前端·javascript·canvas
DJ斯特拉2 小时前
axios快速使用
开发语言·前端·javascript
还有多久拿退休金2 小时前
Ant Design Tree 搜索定位避坑指南:虚拟滚动下如何实现高亮与精准定位
前端·react.js