✨ feat: 更新进度展示优化#870
Conversation
Summary of ChangesHello @imsyy, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 此拉取请求旨在优化应用程序的更新流程和用户体验。通过将更新的下载和安装步骤解耦,并引入全局状态管理来跟踪更新进度,用户现在可以更直观地了解更新状态,并在下载完成后选择手动安装。这不仅提升了用户对更新过程的控制感,也使得更新提示和交互更加友好和清晰。 Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Pull request overview
该 PR 优化了 Electron 客户端的软件更新流程与进度展示:将更新状态沉淀到全局 statusStore,支持在导航栏展示“有更新/下载进度/已就绪”,并将“下载完成后自动安装”改为“用户确认后安装”。
Changes:
- 新增全局更新状态(是否有更新、更新信息、下载中/已下载、下载进度)并由 IPC 统一维护
- 更新弹窗改为基于全局状态展示下载进度与“立即安装”入口,移除弹窗内重复 IPC 监听
- Electron 主进程更新逻辑从“下载完成立即安装”调整为显式 IPC 触发安装
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/utils/initIpc.ts | 在渲染进程集中监听更新相关 IPC,并写入全局更新状态 |
| src/stores/status.ts | 扩展 StatusState,增加更新可用/下载状态/进度等字段 |
| src/components/Modal/UpdateApp.vue | 更新弹窗 UI:展示下载进度与“立即安装”,移除局部 IPC 监听 |
| src/components/Layout/Nav.vue | 新增“有更新”导航栏按钮与动态提示文案 |
| electron/main/update/index.ts | 下载完成不再自动安装,新增 installUpdate() 显式安装入口 |
| electron/main/ipc/ipc-update.ts | 新增 install-update IPC 通道调用 installUpdate() |
| src/components/List/CommentList.vue | 使用 --main-cover-color 变量调整评论气泡背景色 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const startDownload = async () => { | ||
| downloadStatus.value = true; | ||
| // 开始下载更新 | ||
| const startDownload = () => { |
There was a problem hiding this comment.
startDownload() 这里只发送了 IPC,但没有立刻把 statusStore.updateDownloading 置为 true。在首个 download-progress 事件到来前按钮不会进入 loading,用户可能重复点击触发多次下载请求,且 UI 反馈会延迟。建议在发送 IPC 前先根据当前状态(已下载/下载中)做一次 guard,并在开始下载时立即更新 store 的下载中状态(必要时也可清零进度)。
| const startDownload = () => { | |
| const startDownload = () => { | |
| // 已在下载中或已下载完成时直接返回,避免重复触发 | |
| if ((statusStore as any).updateDownloading || (statusStore as any).updateDownloaded) { | |
| return; | |
| } | |
| // 立即更新下载中状态,让按钮立刻进入 loading 状态 | |
| (statusStore as any).updateDownloading = true; |
| window.electron.ipcRenderer.on("update-available", (_, info) => { | ||
| const isManualCheck = statusStore.updateCheck; | ||
| closeUpdateStatus(); | ||
| openUpdateApp(info); | ||
| statusStore.updateAvailable = true; | ||
| statusStore.updateInfo = info; |
There was a problem hiding this comment.
这里把更新信息写入 store,但在 update-not-available / update-error 分支并没有清理 updateAvailable / updateInfo / 下载状态。若之前已检测到更新,之后切换更新通道再检查且返回“无更新”,Nav 的更新按钮和旧的 updateInfo 可能会一直保留。建议把更新相关字段的重置逻辑集中到一个方法里,并在“无更新/错误”时也调用以避免状态残留。
There was a problem hiding this comment.
Code Review
本次更新对应用的更新机制进行了重构,优化了进度展示。主要改动包括:
- 将更新的下载与安装过程分离,让用户可以自主选择安装时机。
- 通过 Pinia store (
statusStore) 集中管理更新状态,这是一种良好的架构实践。 - 在导航栏增加了更新状态的展示,并优化了更新弹窗的触发逻辑(仅在手动检查时弹出),提升了用户体验。
- 将 IPC 事件监听逻辑从 Vue 组件中移至全局初始化文件
initIpc.ts,使组件代码更清晰,并修复了潜在的事件监听器重复注册问题。
整体来看,这是一次很棒的改进。我只发现了一个关于下载进度显示不一致的小问题,并在代码中提出了建议。
| {{ | ||
| statusStore.updateDownloading | ||
| ? `下载中 ${statusStore.updateDownloadProgress}%` | ||
| : "立即更新" | ||
| }} |
|
/gemini review |
There was a problem hiding this comment.
Code Review
本次 PR 对应用的更新流程进行了重构和优化。主要改动包括:
- 将更新通道(稳定版/测试版)的设置持久化到
electron-store,使得主进程可以正确读取该配置。 - 更新检查逻辑不再通过 IPC 传递通道信息,而是直接从 store 中读取。
- 更新下载完成后不再自动安装,而是通过前端 UI 触发,给予用户更多控制权。
- 引入了
statusStore来集中管理更新状态(如是否有可用更新、下载进度、是否下载完成等),并在导航栏和更新弹窗中展示这些状态,提升了用户体验。 - 代码结构上,将更新相关的状态管理和 IPC 事件处理逻辑更加集中,提高了可维护性。
整体来看,这是一次非常棒的改进。我发现了一个小问题,请查看具体的评论。
| import { isElectron } from "@/utils/env"; | ||
| import { openExcludeComment } from "@/utils/modal"; | ||
| import { sendRegisterProtocol } from "@/utils/protocol"; | ||
| import { SettingConfig } from "@/types/settings"; |
There was a problem hiding this comment.
No description provided.