feat: OTA 自更新(Gitea Release 为更新源)
Release / Meta (push) Canceled after 0s
Release / Test (push) Canceled after 0s
Release / Build (ubuntu-latest) (push) Canceled after 0s
Release / Publish package (push) Canceled after 0s

- update.rs:检查最新 Release(latest 端点+列表回退)、版本比较、
  平台产物挑选(含 .sha256 侧车)、下载进度、sha256 校验、
  自替换(改名 .old → 换入新 exe → 拉起新进程)、启动清理遗留
- 设置 → 关于:检查更新按钮、发现新版本提示、下载进度条(Progress)、
  失败重试;自动检查更新开关真正生效(启动后台检查并弹通知)
- 版本 1.0.0 → 1.0.1(首个带 OTA 的发布版本)
- 顺手修 clippy 遗留警告(is_none_or、合并 if)
This commit is contained in:
2026-09-28 23:44:56 +08:00
parent 262bc265d8
commit bf6d165854
8 changed files with 654 additions and 27 deletions
+23
View File
@@ -28,6 +28,7 @@ use crate::model::{
};
use crate::mqtt::{EngineEvent, MqttEngine};
use crate::store::Storage;
use crate::update;
use crate::ui::IconName;
use crate::ui::{
connection_form::ConnectionForm,
@@ -127,6 +128,28 @@ impl MqttXApp {
}
});
// OTA:清理上次自更新遗留文件;开启自动检查则后台查一次新版本
update::cleanup_old();
if settings.auto_check_update {
let rx = engine.run_blocking(update::check_latest);
let weak = cx.entity().downgrade();
cx.spawn_in(window, async move |_this, cx: &mut gpui_kit::AsyncWindowContext| {
if let Ok(Ok(Some(info))) = rx.recv().await {
weak.update_in(cx, |_app, window, cx| {
window.push_notification(
Notification::info(format!(
"发现新版本 v{},可在 设置 → 关于 中更新",
info.version
)),
cx,
);
})
.ok();
}
})
.detach();
}
let search = cx.new(|cx| InputState::new(window, cx).placeholder("搜索连接…"));
// 「跟随系统」:监听系统外观(深浅色)变化,仅在设置为 System 时重应用主题。