From f5a702fab1e62795217b41c420456941f9b59a80 Mon Sep 17 00:00:00 2001 From: Joe Allen <49467845+LiJoeAllen@users.noreply.github.com> Date: Thu, 20 Aug 2026 15:16:23 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=20Tauri=20=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E6=9B=B4=E6=96=B0=E5=99=A8=E6=8F=92=E4=BB=B6=E6=94=AF?= =?UTF-8?q?=E6=8C=81=20(updater=20plugin)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加 tauri-plugin-updater / tauri-plugin-process Rust 依赖 - 注册 updater 和 process 插件到 Tauri 构建器 - 配置 tauri.conf.json 更新器端点与公钥占位 - 添加 @tauri-apps/plugin-updater / plugin-process npm 依赖 - 创建 useUpdater composable(静默检查、手动检查、下载进度、安装重启) - 在 AppLayout 标题栏集成更新交互 UI(下载按钮、进度条、安装状态) - 添加 .pnpm-store 到 .gitignore --- .gitignore | 1 + package.json | 2 + pnpm-lock.yaml | 20 +++++ rust-toolchain.toml | 3 - src-tauri/Cargo.toml | 2 + src-tauri/src/lib.rs | 2 + src-tauri/tauri.conf.json | 15 +++- src/components/AppLayout.vue | 147 +++++++++++++++++++++++++++++++ src/composables/useUpdater.ts | 159 ++++++++++++++++++++++++++++++++++ 9 files changed, 346 insertions(+), 5 deletions(-) delete mode 100644 rust-toolchain.toml create mode 100644 src/composables/useUpdater.ts diff --git a/.gitignore b/.gitignore index 98d4b33..1280c1b 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ pnpm-debug.log* lerna-debug.log* node_modules +.pnpm-store dist dist-ssr *.local diff --git a/package.json b/package.json index fd96ebd..e0f4fa2 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,8 @@ "@element-plus/icons-vue": "^2.3.2", "@tauri-apps/api": "^2", "@tauri-apps/plugin-opener": "^2", + "@tauri-apps/plugin-process": "^2", + "@tauri-apps/plugin-updater": "^2", "element-plus": "^2.14.4", "vue": "^3.5.13" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 540cacc..2d4b079 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -17,6 +17,12 @@ importers: '@tauri-apps/plugin-opener': specifier: ^2 version: 2.5.4 + '@tauri-apps/plugin-process': + specifier: ^2 + version: 2.3.1 + '@tauri-apps/plugin-updater': + specifier: ^2 + version: 2.10.1 element-plus: specifier: ^2.14.4 version: 2.14.4(vue@3.5.41(typescript@6.0.3)) @@ -261,6 +267,12 @@ packages: '@tauri-apps/plugin-opener@2.5.4': resolution: {integrity: sha512-1HnPkb+AmgO29HBazm4uPLKB+r7zzcTBW1d0fyYp1uP+jwtpoiNDGKMMzz58SFp49nOIrxdE3aUJtT57lfO9CQ==} + '@tauri-apps/plugin-process@2.3.1': + resolution: {integrity: sha512-nCa4fGVaDL/B9ai03VyPOjfAHRHSBz5v6F/ObsB73r/dA3MHHhZtldaDMIc0V/pnUw9ehzr2iEG+XkSEyC0JJA==} + + '@tauri-apps/plugin-updater@2.10.1': + resolution: {integrity: sha512-NFYMg+tWOZPJdzE/PpFj2qfqwAWwNS3kXrb1tm1gnBJ9mYzZ4WDRrwy8udzWoAnfGCHLuePNLY1WVCNHnh3eRA==} + '@types/lodash-es@4.17.12': resolution: {integrity: sha512-0NgftHUcV4v34VhXm8QBSftKVXtbkBG3ViCjs6+eJ5a6y6Mi/jiFGPc1sC7QK+9BFhWrURE3EOggmWaSxL9OzQ==} @@ -705,6 +717,14 @@ snapshots: dependencies: '@tauri-apps/api': 2.11.1 + '@tauri-apps/plugin-process@2.3.1': + dependencies: + '@tauri-apps/api': 2.11.1 + + '@tauri-apps/plugin-updater@2.10.1': + dependencies: + '@tauri-apps/api': 2.11.1 + '@types/lodash-es@4.17.12': dependencies: '@types/lodash': 4.17.25 diff --git a/rust-toolchain.toml b/rust-toolchain.toml deleted file mode 100644 index 47103d1..0000000 --- a/rust-toolchain.toml +++ /dev/null @@ -1,3 +0,0 @@ -[toolchain] -channel = "nightly" -targets = ["x86_64-pc-windows-gnu"] \ No newline at end of file diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 2b214a0..49a0555 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -23,6 +23,8 @@ tauri-build = { version = "2", features = [] } [dependencies] tauri = { version = "2", features = [] } tauri-plugin-opener = "2" +tauri-plugin-process = "2" +tauri-plugin-updater = "2" serde = { version = "1", features = ["derive"] } serde_json = "1" rumqttc-v5-next = "0.34" diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index c821929..3705f5c 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -944,6 +944,8 @@ pub fn run() { tauri::Builder::default() .plugin(tauri_plugin_opener::init()) + .plugin(tauri_plugin_process::init()) + .plugin(tauri_plugin_updater::Builder::new().build()) .manage(AppState { clients: RwLock::new(HashMap::new()), log_writer, diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index f50412e..f6dc1d2 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -23,6 +23,16 @@ "csp": null } }, + "plugins": { + "updater": { + "active": true, + "dialog": true, + "endpoints": [ + "https://releases.mqttx.app/update/{{target}}-{{arch}}/{{current_version}}" + ], + "pubkey": "请替换为你的公钥——使用 `tauri signer generate` 生成签名密钥对后,将公钥粘贴至此" + } + }, "bundle": { "active": true, "targets": "all", @@ -35,11 +45,12 @@ ], "windows": { "nsis": { - "language": ["SimpChinese", "English"] + "languages": ["SimpChinese", "English"], + "displayLanguageSelector": true }, "wix": { "language": ["zh-CN", "en-US"] } } } -} +} \ No newline at end of file diff --git a/src/components/AppLayout.vue b/src/components/AppLayout.vue index 7279472..53c5dbe 100644 --- a/src/components/AppLayout.vue +++ b/src/components/AppLayout.vue @@ -1,11 +1,19 @@