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

🎈 perf: 完善歌词字体自定义 - #634

Merged
imsyy merged 3 commits into
devfrom
dev-perf
Dec 15, 2025
Merged

imsyy merged 3 commits into
devfrom
dev-perf

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

  • 新增英韩语歌词字体自定义: 允许用户为英语和韩语歌词单独设置字体,提升多语言歌词的显示效果。
  • 更新设置界面: 在通用设置中增加了英语和韩语歌词字体的选择器和恢复默认按钮,并使用折叠过渡效果。
  • 动态应用字体: 通过CSS变量和:lang()选择器,实现歌词根据语言动态应用自定义字体,增强了灵活性。
  • 扩展设置存储: 在应用设置中新增了英语和韩语歌词字体的存储字段,以持久化用户偏好。
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 旨在完善歌词字体的自定义功能,增加了对英语和韩语歌词的单独字体设置。这是一个很好的功能增强。

但在审查代码时,我发现一个关键问题和一个可以改进的地方:

  1. (关键)韩语字体功能无法正常工作:您为韩语歌词添加了设置项和 CSS 样式,但用于检测歌词语言的 getLyricLanguage 函数(位于 src/utils/format.ts)并未更新,它无法识别韩语。这将导致 lang="ko" 属性永远不会被设置到歌词元素上,因此韩语字体的设置不会生效。为了修复这个问题,您需要修改 getLyricLanguage 函数,增加对韩语字符的检测逻辑(例如,使用正则表达式 /[\uac00-\ud7af]/.test(lyric))。

  2. (建议)设置项存在代码重复:在 GeneralSetting.vue 文件中,英语、日语和韩语的字体设置卡片存在大量重复代码。建议您通过 v-for 循环来动态生成这些卡片,以提高代码的可维护性。我已在具体的文件评论中给出了建议。

请务必修复第一个关键问题,以确保新功能的完整性。

Comment on lines +245 to +328
<n-card class="set-item">
<div class="label">
<n-text class="name">英语歌词字体</n-text>
<n-text class="tip" :depth="3"> 是否在歌词为英语时单独设置字体 </n-text>
</div>
<n-flex>
<Transition name="fade" mode="out-in">
<n-button
v-if="settingStore.englishLyricFont !== 'follow'"
type="primary"
strong
secondary
@click="settingStore.englishLyricFont = 'follow'"
>
恢复默认
</n-button>
</Transition>
<n-select
v-model:value="settingStore.englishLyricFont"
:options="[
{ label: '跟随全局', value: 'follow' },
...allFontsData.filter((v) => v.value !== 'default'),
]"
class="set"
filterable
/>
</n-flex>
</n-card>
<n-card class="set-item">
<div class="label">
<n-text class="name">日语歌词字体</n-text>
<n-text class="tip" :depth="3"> 是否在歌词为日语时单独设置字体 </n-text>
</div>
<n-flex>
<Transition name="fade" mode="out-in">
<n-button
v-if="settingStore.japaneseLyricFont !== 'follow'"
type="primary"
strong
secondary
@click="settingStore.japaneseLyricFont = 'follow'"
>
恢复默认
</n-button>
</Transition>
<n-select
v-model:value="settingStore.japaneseLyricFont"
:options="[
{ label: '跟随全局', value: 'follow' },
...allFontsData.filter((v) => v.value !== 'default'),
]"
class="set"
filterable
/>
</n-flex>
</n-card>
<n-card class="set-item">
<div class="label">
<n-text class="name">韩语歌词字体</n-text>
<n-text class="tip" :depth="3"> 是否在歌词为韩语时单独设置字体 </n-text>
</div>
<n-flex>
<Transition name="fade" mode="out-in">
<n-button
v-if="settingStore.koreanLyricFont !== 'follow'"
type="primary"
strong
secondary
@click="settingStore.koreanLyricFont = 'follow'"
>
恢复默认
</n-button>
</Transition>
<n-select
v-model:value="settingStore.koreanLyricFont"
:options="[
{ label: '跟随全局', value: 'follow' },
...allFontsData.filter((v) => v.value !== 'default'),
]"
class="set"
filterable
/>
</n-flex>
</n-card>

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

这三张用于设置英语、日语、韩语歌词字体的卡片(n-card)包含了大量重复的模板代码。这会降低代码的可维护性,未来如果需要添加更多语言支持会很麻烦。

建议您进行重构,使用 v-for 指令来动态生成这些卡片。具体做法是:

  1. 在 <script setup> 中创建一个包含各语言配置的对象数组,例如:
    const languageFontSettings = [
      { name: '英语', model: 'englishLyricFont' },
      { name: '日语', model: 'japaneseLyricFont' },
      { name: '韩语', model: 'koreanLyricFont' },
    ];
  2. 在模板中,使用 v-for 遍历这个数组,只写一个 n-card 的模板,并使用数组中的数据动态绑定 v-if, @click, v-model:value 等。

这样可以显著减少代码量,使组件更易于维护和扩展。

@imsyy
imsyy merged commit 20b7ec1 into dev Dec 15, 2025
3 checks passed
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