Skip to content

应用更新

灵动桌面框架内置 Updater 插件,支持应用自动检查更新和在线升级。

工作流程

应用启动 → 检查更新服务器 → 发现新版本 → 下载安装包 → 重启应用

配置更新源

json
// src-tauri/tauri.conf.json
{
  "plugins": {
    "updater": {
      "endpoints": [
        "https://your-server.com/update/{{target}}/{{arch}}/{{current_version}}"
      ],
      "pubkey": "你的公钥"
    }
  }
}

前端使用

typescript
import { check } from '@tauri-apps/plugin-updater'
import { relaunch } from '@tauri-apps/plugin-process'

const update = await check()
if (update) {
  await update.downloadAndInstall()
  await relaunch()
}

更新服务器

更新服务器需要返回以下格式的 JSON:

json
{
  "version": "1.1.0",
  "notes": "修复了若干问题",
  "pub_date": "2026-03-30T00:00:00Z",
  "platforms": {
    "windows-x86_64": {
      "url": "https://your-server.com/releases/app_1.1.0_x64-setup.nsis.zip",
      "signature": "签名内容"
    }
  }
}

基于 Tauri 2.x 构建的企业级桌面应用开发框架