From c3dd03cc13dd42275ebede7d3a6a8542e278cf40 Mon Sep 17 00:00:00 2001 From: algerkong Date: Sat, 20 Dec 2025 14:18:27 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E6=AD=8C=E8=AF=8D?= =?UTF-8?q?=E9=A2=9C=E8=89=B2=E6=A3=80=E6=B5=8B=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderer/components/lyric/MusicFull.vue | 62 +++++-------------- .../components/lyric/MusicFullMobile.vue | 29 ++++----- src/renderer/types/lyric.ts | 2 +- 3 files changed, 29 insertions(+), 64 deletions(-) diff --git a/src/renderer/components/lyric/MusicFull.vue b/src/renderer/components/lyric/MusicFull.vue index 2e2f08e..6a72618 100644 --- a/src/renderer/components/lyric/MusicFull.vue +++ b/src/renderer/components/lyric/MusicFull.vue @@ -417,42 +417,29 @@ const setTextColors = (background: string) => { } }; -// 监听背景变化 +const targetBackground = computed(() => { + if (config.value.useCustomBackground && customBackgroundStyle.value) { + if (typeof customBackgroundStyle.value === 'string') { + return customBackgroundStyle.value; + } + } + if (config.value.theme !== 'default') { + return themeMusic[config.value.theme] || props.background; + } + return props.background; +}); + +// 监听目标背景变化并更新文字颜色 watch( - () => props.background, + targetBackground, (newBg) => { - if (config.value.useCustomBackground) { - // 使用自定义背景时,根据自定义背景计算文字颜色 - if (customBackgroundStyle.value) { - setTextColors(customBackgroundStyle.value); - } - } else if (config.value.theme === 'default') { + if (newBg) { setTextColors(newBg); - } else { - setTextColors(themeMusic[config.value.theme] || props.background); } }, { immediate: true } ); -// 监听自定义背景配置变化 -watch( - () => [config.value.useCustomBackground, customBackgroundStyle.value] as const, - ([useCustom, customBg]) => { - if (useCustom && customBg && typeof customBg === 'string') { - setTextColors(customBg); - } else { - // 回退到主题模式 - if (config.value.theme === 'default') { - setTextColors(props.background); - } else { - setTextColors(themeMusic[config.value.theme] || props.background); - } - } - }, - { deep: true } -); - const { getLrcStyle: originalLrcStyle } = useLyricProgress(); const getLrcStyle = (index: number) => { @@ -589,15 +576,6 @@ watch( { immediate: true } ); -// 监听配置变化并保存到本地存储 -watch( - () => config.value, - (newConfig) => { - localStorage.setItem('music-full-config', JSON.stringify(newConfig)); - }, - { deep: true } -); - // 监听滚动事件 const handleScroll = () => { if (!lrcSider.value || !config.value.hideCover) return; @@ -677,16 +655,6 @@ watch( } ); -// 监听主题变化 -watch( - () => config.value.theme, - (newTheme) => { - const newBackground = themeMusic[newTheme] || props.background; - setTextColors(newBackground); - }, - { immediate: true } -); - // 添加文字间距监听 watch( () => config.value.letterSpacing, diff --git a/src/renderer/components/lyric/MusicFullMobile.vue b/src/renderer/components/lyric/MusicFullMobile.vue index 9068c46..c2d8aca 100644 --- a/src/renderer/components/lyric/MusicFullMobile.vue +++ b/src/renderer/components/lyric/MusicFullMobile.vue @@ -979,14 +979,19 @@ const setTextColors = (background: string) => { } }; -// 监听背景变化 +const targetBackground = computed(() => { + if (config.value.theme !== 'default') { + return themeMusic[config.value.theme] || props.background; + } + return props.background; +}); + +// 监听目标背景变化并更新文字颜色 watch( - () => props.background, + targetBackground, (newBg) => { - if (config.value.theme === 'default') { + if (newBg) { setTextColors(newBg); - } else { - setTextColors(themeMusic[config.value.theme] || props.background); } }, { immediate: true } @@ -1040,16 +1045,6 @@ const closeMusicFull = () => { playerStore.setMusicFull(false); }; -// 监听主题变化 -watch( - () => config.value.theme, - (newTheme) => { - const newBackground = themeMusic[newTheme] || props.background; - setTextColors(newBackground); - }, - { immediate: true } -); - // 添加对 playMusic.id 的监听,歌曲切换时滚动到顶部 watch( () => playMusic.value.id, @@ -1116,7 +1111,9 @@ onMounted(() => { watch(isVisible, (newVal) => { if (newVal) { // 播放器显示时,重新设置背景颜色 - setTextColors(props.background); + if (targetBackground.value) { + setTextColors(targetBackground.value); + } } else { showFullLyrics.value = false; if (autoScrollTimer.value) { diff --git a/src/renderer/types/lyric.ts b/src/renderer/types/lyric.ts index e793a21..737ed2b 100644 --- a/src/renderer/types/lyric.ts +++ b/src/renderer/types/lyric.ts @@ -44,7 +44,7 @@ export const DEFAULT_LYRIC_CONFIG: LyricConfig = { hideMiniPlayBar: false, pureModeEnabled: false, hideLyrics: false, - contentWidth: 100, // 默认100%宽度 + contentWidth: 75, // 默认100%宽度 // 移动端默认配置 mobileLayout: 'ios', mobileCoverStyle: 'full',