Skip to content

✨ feat: 支持下载时转换繁体中文#765

Merged
imsyy merged 3 commits into
devfrom
dev-download
Jan 25, 2026
Merged

✨ feat: 支持下载时转换繁体中文#765
imsyy merged 3 commits into
devfrom
dev-download

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

  • 新增繁体歌词下载转换功能: 在下载歌词时,用户现在可以选择将其内容自动转换为繁体中文,支持 LRC、YRC 和 TTML 格式。
  • 用户界面更新: 在设置界面添加了一个新的“下载歌词转繁体”开关,并会显示当前选择的繁体变体(如“台湾正体”或“香港繁体”)。
  • 核心下载逻辑集成: 下载管理器已集成 OpenCC 转换工具,确保在保存歌词文件之前,根据用户设置对歌词内容进行繁体转换。
  • 设置存储更新: setting.ts 文件中新增了 downloadLyricToTraditional 选项,用于持久化用户的繁体转换偏好。
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 增加了在下载歌词时将其转换为繁体中文的功能,做得很好。代码改动分布在 UI、下载逻辑和状态管理三处,逻辑清晰。

我提出了一些关于代码结构和可维护性的建议:

  1. LocalSetting.vue 中,将 variantMap 移出 computed 属性,以提高性能和可读性。
  2. DownloadManager.ts 中,将重复的繁体转换逻辑提取到一个辅助函数中,以避免代码冗余。

这些修改将使代码更加健壮和易于维护。

Comment on lines +418 to +426
const traditionalVariantLabel = computed(() => {
const variantMap: Record<string, string> = {
s2t: "繁体中文 (标准)",
s2tw: "台湾正体",
s2hk: "香港繁体",
s2twp: "台湾正体 (含词汇)",
};
return variantMap[settingStore.traditionalChineseVariant] || "繁体中文";
});
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

为了提高性能和代码可读性,建议将 variantMap 对象定义在 computed 函数外部,作为一个常量。这样可以避免在每次访问计算属性时都重新创建该对象。

const variantMap: Record<string, string> = {
  s2t: "繁体中文 (标准)",
  s2tw: "台湾正体",
  s2hk: "香港繁体",
  s2twp: "台湾正体 (含词汇)",
};

// 繁体变体标签
const traditionalVariantLabel = computed(() => {
  return variantMap[settingStore.traditionalChineseVariant] || "繁体中文";
});

Comment thread src/core/resource/DownloadManager.ts Outdated
Comment on lines +606 to +615
const result = lines.join("\n");

// 繁体转换
if (settingStore.downloadLyricToTraditional) {
const variant = (settingStore.traditionalChineseVariant || "s2t") as ConverterMode;
const converter = await getConverter(variant);
return converter(result);
}

return result;
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

这块繁体转换的逻辑在 processDownload 方法中也存在,导致了代码重复。为了提高代码的可维护性,建议将此逻辑提取到一个私有的辅助方法中。

你可以在 DownloadManager 类中添加如下方法:

private async _convertToTraditionalIfNeeded(text: string): Promise<string> {
  const settingStore = useSettingStore();
  if (settingStore.downloadLyricToTraditional && text) {
    const variant = (settingStore.traditionalChineseVariant || "s2t") as ConverterMode;
    const converter = await getConverter(variant);
    return converter(text);
  }
  return text;
}

然后,你就可以将当前的 if 代码块替换为对这个新方法的调用。同样的,在 processDownload 方法中(大约在 429 行)也应该使用这个新方法来替换重复的逻辑。

Suggested change
const result = lines.join("\n");
// 繁体转换
if (settingStore.downloadLyricToTraditional) {
const variant = (settingStore.traditionalChineseVariant || "s2t") as ConverterMode;
const converter = await getConverter(variant);
return converter(result);
}
return result;
const result = lines.join("\n");
return await this._convertToTraditionalIfNeeded(result);

@imsyy imsyy merged commit d629dd6 into dev Jan 25, 2026
4 checks passed
@kazukokawagawa kazukokawagawa deleted the dev-download branch January 25, 2026 11:26
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.

2 participants