feat(updater): 优化更新体验与 UI
- ui: UpdateBadge 使用 Tailwind 内置过渡,支持点击打开设置,保留图标动画 - updater: 新增 UpdateContext 首启延迟检查,忽略版本键名命名空间化(含旧键迁移),并发保护 - settings: 去除版本硬编码回退;检测到更新时复用 updateHandle 下载并安装,并新增常显“更新日志”入口 - a11y: 更新徽标支持键盘触达(Enter/Space) - refactor: 移除未使用的 runUpdateFlow 导出 - chore: 类型检查通过,整体行为与权限边界未改变
This commit is contained in:
@@ -122,25 +122,5 @@ export async function relaunchApp(): Promise<void> {
|
||||
await relaunch();
|
||||
}
|
||||
|
||||
export async function runUpdateFlow(
|
||||
opts: CheckOptions = {},
|
||||
): Promise<{ status: "up-to-date" | "done" }> {
|
||||
const result = await checkForUpdate(opts);
|
||||
if (result.status === "up-to-date") return result;
|
||||
|
||||
let downloaded = 0;
|
||||
let total = 0;
|
||||
await result.update.downloadAndInstall((e) => {
|
||||
if (e.event === "Started") {
|
||||
total = e.total ?? 0;
|
||||
downloaded = 0;
|
||||
} else if (e.event === "Progress") {
|
||||
downloaded += e.downloaded ?? 0;
|
||||
// 调用方可监听此处并更新 UI(目前设置页仅显示加载态)
|
||||
console.debug("update progress", { downloaded, total });
|
||||
}
|
||||
});
|
||||
|
||||
await relaunchApp();
|
||||
return { status: "done" };
|
||||
}
|
||||
// 旧的聚合更新流程已由调用方直接使用 updateHandle 取代
|
||||
// 如需单函数封装,可在需要时基于 checkForUpdate + updateHandle 复合调用
|
||||
|
||||
Reference in New Issue
Block a user