Skip to content
This repository was archived by the owner on Jul 17, 2026. It is now read-only.

✨ feat: 批量下载处理 - #601

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

imsyy merged 4 commits into
devfrom
dev-dl

Conversation

@kazukokawagawa

Copy link
Copy Markdown
Collaborator

No description provided.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @kazukokawagawa, 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

  • 批量下载功能: 在批量操作列表中新增了批量下载功能,用户现在可以选择多首歌曲进行批量下载。此功能包括音质选择和下载路径配置。
  • 范围选择歌曲: 批量操作列表现在支持通过输入起始和结束序号来选择歌曲范围,极大地提高了选择效率。
  • 统一的下载工具函数: 引入了一个新的 downloadSong 工具函数,将单曲下载和批量下载的逻辑进行了统一和封装,提高了代码的可维护性和复用性。该函数能够根据运行环境(Electron或浏览器)自动选择下载方式,并处理音质、歌词、封面等元数据。
  • 下载进度与错误处理: 批量下载过程现在会显示详细的进度信息,并在下载完成后提供成功/失败统计。对于下载失败的歌曲,用户可以选择重试。
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. ↩

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

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.

Code Review

这个 PR 引入了批量下载功能,这是一个很棒的新特性。代码结构清晰,特别是将下载逻辑提取到 src/utils/download.ts 中,提高了代码的可重用性和可维护性。范围选择和失败重试等功能也考虑得很周到,提升了用户体验。

我提出了一些建议,主要集中在提高代码效率、类型安全和代码风格方面。请查看具体的评论。

Comment thread src/components/Modal/BatchList.vue Outdated
Comment on lines +16 to +32
<n-input-number
v-model:value="startRange"
placeholder="开始"
:min="1"
:max="props.data.length"
style="width: 80px"
size="small"
/>
<n-text>-</n-text>
<n-input-number
v-model:value="endRange"
placeholder="结束"
:min="1"
:max="props.data.length"
style="width: 80px"
size="small"
/>

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

模板中多处使用了内联样式(inline styles)。更好的实践是将其移至 <style> 块中并使用 CSS 类。这能提高代码的可维护性,并实现样式与结构的分离。

例如,对于 n-input-number:

<n-input-number 
  ...
  class="range-input"
  ...
/>

然后在 <style> 块中定义:

.range-input {
  width: 80px;
}

此建议同样适用于第 107、110 和 121 行的元素。

Comment thread src/components/Modal/BatchList.vue Outdated
Comment on lines +301 to +315
const newSelectedKeys: DataTableRowKey[] = [];
const newSelectedRows: DataType[] = [];

tableData.value.forEach((row) => {
if (row.key && row.key >= start && row.key <= end) {
if (row.id) {
newSelectedKeys.push(row.key);
newSelectedRows.push(row);
}
}
});

checkedRowKeys.value = newSelectedKeys;
checkCount.value = newSelectedKeys.length;
checkSongData.value = newSelectedRows.map((row) => row.origin).filter((song) => song) as SongType[];

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

handleRangeSelect 函数当前通过遍历整个 tableData 数组来选取范围内的行。由于每行的 key 属性与其基于 1 的索引相对应,使用 Array.prototype.slice() 会是更高效、更简洁的实现方式,可以避免不必要的遍历。

  const selectedRows = tableData.value.slice(start - 1, end).filter(row => row.id);
  
  checkedRowKeys.value = selectedRows.map(row => row.key as DataTableRowKey);
  checkCount.value = selectedRows.length;
  checkSongData.value = selectedRows.map((row) => row.origin).filter((song) => song) as SongType[];

Comment thread src/utils/download.ts Outdated
interface DownloadOptions {
song: SongType;
quality: SongLevelType;
settingStore: any;

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

DownloadOptions 接口中的 settingStore 属性被定义为 any 类型。为了增强类型安全,建议为其指定一个更具体的类型。你可以使用 ReturnType<typeof useSettingStore> 来获取 store 实例的类型。

Suggested change
settingStore: any;
settingStore: ReturnType<typeof import("@/stores").useSettingStore>;

Comment thread src/utils/meta.ts
Comment on lines +80 to +97
return reduce(
level,
(result, value, key) => {
// 如果没有 quality 数据,则默认显示所有 level
// 如果有 quality 数据,则只显示 quality 中存在的 level
if (value && (!quality || quality[key])) {
result.push({
name: value.name,
level: value.level,
value: key as SongLevelType,
br: quality?.[key]?.br,
size: quality?.[key]?.size,
});
}
return result;
},
[] as any[],
);

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

reduce 函数的初始值被强制转换为 [] as any[],这削弱了类型安全。你可以为 reduce 回调函数中的累加器(accumulator)和初始值提供明确的类型,从而避免使用 any。

  return reduce(
    level,
    (
      result: {
        name: string;
        level: string;
        value: SongLevelType;
        br?: number;
        size?: number;
      }[],
      value,
      key,
    ) => {
      // 如果没有 quality 数据,则默认显示所有 level
      // 如果有 quality 数据,则只显示 quality 中存在的 level
      if (value && (!quality || quality[key])) {
        result.push({
          name: value.name,
          level: value.level,
          value: key as SongLevelType,
          br: quality?.[key]?.br,
          size: quality?.[key]?.size,
        });
      }
      return result;
    },
    [],
  );

@imsyy
imsyy merged commit 18c53b0 into dev Dec 1, 2025
3 checks passed
@imsyy
imsyy deleted the dev-dl branch December 1, 2025 16:08
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants