跳转到内容
Tauri

Leptos

Leptos 是一个基于 Rust 的 Web 框架。您可以在他们的 官方网站 上了解更多关于 Leptos 的信息。本指南截至 Leptos 版本 0.6。

检查清单

  • 使用 SSG,Tauri 官方不支持基于服务器的解决方案。
  • 使用 serve.ws_protocol = "ws" 以确保热重载 WebSocket 可以在移动开发中正常连接。
  • 启用 withGlobalTauri 确保在 window.__TAURI__ 变量中可用 Tauri API,并可以使用 wasm-bindgen 导入。

示例配置

  1. 更新 Tauri 配置
    src-tauri/tauri.conf.json
    {
    "build": {
    "beforeDevCommand": "trunk serve",
    "devUrl": "https://127.0.0.1:1420",
    "beforeBuildCommand": "trunk build",
    "frontendDist": "../dist"
    },
    "app": {
    "withGlobalTauri": true
    }
    }
  2. 更新 Trunk 配置
    Trunk.toml
    [build]
    target = "./index.html"
    [watch]
    ignore = ["./src-tauri"]
    [serve]
    port = 1420
    open = false
    ws_protocol = "ws"

© 2025 Tauri 贡献者。CC-BY / MIT