Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/components/Player/MainAMLyric.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
:playing="statusStore.playStatus"
:enableSpring="settingStore.useAMSpring"
:enableScale="settingStore.useAMSpring"
:alignPosition="settingStore.lyricsScrollPosition === 'center' ? 0.5 : 0.2"
:alignPosition="settingStore.lyricsScrollPosition === 'center' ? 0.5 : 0.15"
:alignAnchor="settingStore.lyricsScrollPosition === 'center' ? 'center' : 'top'"
Comment on lines +20 to +21
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

为了提高代码的可读性和可维护性,可以考虑将重复的条件 settingStore.lyricsScrollPosition === 'center' 提取到一个计算属性中。

例如,在 <script setup> 部分添加:

const isCenterAligned = computed(() => settingStore.lyricsScrollPosition === 'center');

然后在模板中可以这样使用:

:alignPosition="isCenterAligned ? 0.5 : 0.15"
:alignAnchor="isCenterAligned ? 'center' : 'top'"

这样做可以避免在模板中重复逻辑,使代码更清晰,也便于未来可能的扩展。

:enableBlur="settingStore.lyricsBlur"
:hidePassedLines="settingStore.hidePassedLines"
:wordFadeWidth="settingStore.wordFadeWidth"
Expand Down