字玩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
相关推荐
天若有情67316 分钟前
纯HTML+Tailwind单页作品集网站——零框架静态前端完整源码
前端·html
WebGirl23 分钟前
H5唤起app前端实现方案
前端
Larcher1 小时前
从零实现一个可运行的 RAG - LangChain、内存向量库与检索增强生成
前端·javascript
饼饼饼1 小时前
React 组件间传参好痛苦?试试这一套"优雅组合拳":Context 与 Refs 实战
前端
qq_419854052 小时前
空间网格管理器
前端·javascript·html
qingmiaozhuan2 小时前
电脑录屏没有声音还能补救吗?音频采集链路详解及4种技术方案
前端·电脑·音视频·开发工具·电脑录屏·电脑录屏软件
后季暖2 小时前
langgraph笔记
笔记
天若有情6732 小时前
Dev_Portfolio 个人主页html网页源码分享!!!
前端·html·源码·个人主页
李剑一3 小时前
ant-design-vue 1.x 版本换肤功能开发
前端·vue.js·ant design