Skip to content
Tauri 中文网

主干

Trunk 是 Rust 的 WASM Web 应用打包器。在 https://trunkrs.dev 了解有关 Trunk 的更多信息。本指南适用于 Trunk 0.17.5 版。

¥Trunk is a WASM web application bundler for Rust. Learn more about Trunk at https://trunkrs.dev. This guide is accurate as of Trunk 0.17.5.

检查清单

¥Checklist

  • 使用 SSG,Tauri 不正式支持基于服务器的解决方案。

    ¥Use SSG, Tauri doesn’t officially support server based solutions.

  • 使用 serve.ws_protocol = "ws" 以便热重载 websocket 可以正确连接以进行移动开发。

    ¥Use serve.ws_protocol = "ws" so that the hot-reload websocket can connect properly for mobile development.

  • 启用 withGlobalTauri 以确保 Tauri API 在 window.__TAURI__ 变量中可用,并且可以使用 wasm-bindgen 导入。

    ¥Enable withGlobalTauri to ensure that Tauri APIs are available in the window.__TAURI__ variable and can be imported using wasm-bindgen.

示例配置

¥Example Configuration

  1. Update Tauri configuration
    tauri.conf.json
    {
    "build": {
    "beforeDevCommand": "trunk serve",
    "beforeBuildCommand": "trunk build",
    "devUrl": "http://localhost:8080",
    "frontendDist": "../dist"
    },
    "app": {
    "withGlobalTauri": true
    }
    }
  2. Update Trunk configuration
    Trunk.toml
    [watch]
    ignore = ["./src-tauri"]
    [serve]
    ws_protocol = "ws"

Tauri 中文网 - 粤ICP备13048890号