Skip to content

✨ feat: 完善下载管理页面#609

Merged
imsyy merged 3 commits into
devfrom
dev-dl
Dec 4, 2025
Merged

✨ feat: 完善下载管理页面#609
imsyy merged 3 commits into
devfrom
dev-dl

Conversation

@imsyy
Copy link
Copy Markdown
Member

@imsyy imsyy commented Dec 4, 2025

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @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!

此拉取请求旨在全面提升应用程序的下载管理体验。通过引入一个全新的下载管理页面和统一的下载弹窗,用户可以更直观地查看和控制下载任务。核心下载逻辑被封装在 DownloadManager 中,实现了更稳定和可扩展的后台下载处理。这些改进共同提供了一个更现代化、功能更完善的下载功能,使用户能够更好地管理他们的音乐下载。

Highlights

  • 下载管理页面重构: 下载管理页面已全面重构,现在可以清晰地展示所有正在进行的下载任务,包括进度条、传输大小和状态(下载中/失败),并支持对失败任务进行重试或移除。
  • 统一的下载弹窗: 引入了一个新的统一下载弹窗组件 DownloadModal,它取代了旧的 DownloadSong 弹窗,并集成了单曲和批量下载的选项,提供更一致的用户体验。
  • 后台下载队列管理: 新增了一个 DownloadManager 工具类,负责管理下载任务队列,确保下载按序进行,并处理下载进度更新、成功或失败的逻辑,提升了下载功能的健壮性。
  • 侧边栏下载任务提示: 侧边栏的“下载管理”入口现在会显示一个徽章,实时显示当前正在下载的歌曲数量,方便用户快速了解下载状态。
  • 下载设置增强: 在设置中新增了“默认下载音质”选项,用户可以预设下载歌曲的音质。同时,侧边栏现在也支持隐藏“下载管理”入口。
  • Electron下载进程优化: Electron主进程的下载逻辑得到优化,现在下载时会隐藏系统进度条 (showProgressBar: false),并且在发送下载进度时会附带歌曲ID,以便前端精确更新对应歌曲的进度。
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

这个 PR 对下载功能进行了重大的重构和改进,值得称赞。通过引入 DownloadManager 单例和新的 DownloadModal 组件,代码变得更加模块化和可维护。新的 downloading 页面能够清晰地展示所有下载任务的状态,并提供了重试和取消等操作,极大地提升了用户体验。

我在代码中发现了一些可以改进的地方:

  1. 新的下载弹窗不再显示不同音质的文件大小,这是一个小的功能退步。
  2. data.ts 中,标记下载失败的状态没有被持久化,可能导致应用重启后状态丢失。
  3. DownloadManager 中,使用播放链接下载时缺少了对音质是否支持的校验。

总的来说,这是一次非常出色的重构,解决了之前批量下载的许多限制。修复上述几个小问题后,下载管理功能将更加完善和健壮。

Comment on lines +113 to +120
const qualityOptions = computed(() => {
const levels = pick(songLevelData, ["l", "m", "h", "sq", "hr", "je", "sk", "db", "jm"]);
return getSongLevelsData(levels).map((item) => ({
label: item.name,
value: item.value,
size: undefined,
}));
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

功能退步:未显示音质文件大小

新的下载弹窗不再显示不同音质选项对应的文件大小,而旧的实现 (DownloadSong.vue) 中是支持这个功能的。这对于用户选择音质来说是一个有用的信息。

建议在单曲下载时,可以像旧的实现一样通过 songQuality API 获取并展示文件大小。对于批量下载,可以考虑不显示大小以避免大量的 API 请求。

Comment thread src/stores/data.ts
Comment on lines +386 to +394
const item = this.downloadingSongs.find((item) => item.song.id === songId);
if (item) {
item.status = "failed";
item.progress = 0;
item.transferred = "0MB";
item.totalSize = "0MB";
}
},
// 重置下载任务状态(用于重试)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

问题:下载失败状态未持久化

markDownloadFailed 方法在将歌曲状态标记为 failed 后,没有将更新后的 downloadingSongs 数组持久化到 musicDB。这可能导致在应用重启后,失败的任务状态会丢失,用户无法看到失败的记录或进行重试。

建议在 markDownloadFailed 方法中也调用 musicDB.setItem 来保存状态。

    markDownloadFailed(songId: number) {
      const item = this.downloadingSongs.find((item) => item.song.id === songId);
      if (item) {
        item.status = "failed";
        item.progress = 0;
        item.transferred = "0MB";
        item.totalSize = "0MB";
        musicDB.setItem("downloadingSongs", cloneDeep(this.downloadingSongs));
      }
    },

Comment on lines +192 to +202
if (usePlayback) {
try {
const result = await songUrl(song.id, levelName as any);
if (result.code === 200 && result?.data?.[0]?.url) {
url = result.data[0].url;
type = (result.data[0].type || result.data[0].encodeType || "mp3").toLowerCase();
}
} catch (e) {
console.error("Error fetching playback url for download:", e);
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

问题:使用播放链接下载时缺少音质支持校验

在使用播放链接进行下载时 (usePlaybacktrue),代码直接尝试使用 songUrl API,但没有校验当前选择的音质是否被该 API 支持。旧的实现 (download.ts) 中存在一个 allowedLevels 数组用于校验。

缺少这个校验可能会导致在选择某些特定音质(如 dolby)时,songUrl API 调用失败,而代码会继续尝试使用标准下载接口,这虽然是预期的回退行为,但增加了一次不必要的失败请求。

建议恢复对音质支持的校验逻辑,以避免不必要的 API 调用。

      const allowedPlaybackLevels = [
        "standard",
        "higher",
        "exhigh",
        "lossless",
        "hires",
        "jyeffect",
        "sky",
        "jymaster",
      ];
      if (usePlayback && allowedPlaybackLevels.includes(levelName)) {
        try {
          const result = await songUrl(song.id, levelName as any);
          if (result.code === 200 && result?.data?.[0]?.url) {
            url = result.data[0].url;
            type = (result.data[0].type || result.data[0].encodeType || "mp3").toLowerCase();
          }
        } catch (e) {
          console.error("Error fetching playback url for download:", e);
        }
      }

@imsyy imsyy merged commit 50d03c1 into dev Dec 4, 2025
3 checks passed
@kazukokawagawa kazukokawagawa deleted the dev-dl branch December 4, 2025 15:56
@kazukokawagawa kazukokawagawa restored the dev-dl branch December 4, 2025 15:56
@kazukokawagawa kazukokawagawa deleted the dev-dl branch December 6, 2025 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant