From bc7bf345ca7060e5eef14ade4009a89e4feebc51 Mon Sep 17 00:00:00 2001 From: lyswhut Date: Fri, 22 Sep 2023 14:08:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=9B=B4=E6=96=B0=E7=BF=BB?= =?UTF-8?q?=E8=AF=91=E6=AD=8C=E8=AF=8D=E3=80=81=E7=BD=97=E9=A9=AC=E9=9F=B3?= =?UTF-8?q?=E6=AD=8C=E8=AF=8D=E8=AE=BE=E7=BD=AE=E5=90=8E=E9=9C=80=E9=87=8D?= =?UTF-8?q?=E5=90=AF=E5=BA=94=E7=94=A8=E6=89=8D=E7=94=9F=E6=95=88=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- publish/changeLog.md | 1 + src/core/init/player/lyric.ts | 4 +-- src/core/lyric.ts | 26 ++++++++++--------- .../settings/Player/IsShowLyricRoma.tsx | 2 ++ .../Player/IsShowLyricTranslation.tsx | 2 ++ .../settings/SettingPlaybackRate.tsx | 2 +- 6 files changed, 22 insertions(+), 15 deletions(-) diff --git a/publish/changeLog.md b/publish/changeLog.md index 7641e3a..18bf2b3 100644 --- a/publish/changeLog.md +++ b/publish/changeLog.md @@ -8,3 +8,4 @@ - 修复横屏状态下的歌词滚动位置计算问题 - 修复切歌时歌词激活行的重置问题 +- 修复更新翻译歌词、罗马音歌词设置后需重启应用才生效的问题,现在更新设置后会立即生效 diff --git a/src/core/init/player/lyric.ts b/src/core/init/player/lyric.ts index b5f9b7c..32426f1 100644 --- a/src/core/init/player/lyric.ts +++ b/src/core/init/player/lyric.ts @@ -5,8 +5,8 @@ import { onDesktopLyricPositionChange, showDesktopLyric } from '@/core/desktopLy export default async(setting: LX.AppSetting) => { await initLyricPlayer() void setPlaybackRate(setting['player.playbackRate']) - toggleTranslation(setting['player.isShowLyricTranslation']) - toggleRoma(setting['player.isShowLyricRoma']) + void toggleTranslation(setting['player.isShowLyricTranslation']) + void toggleRoma(setting['player.isShowLyricRoma']) if (setting['desktopLyric.enable']) { showDesktopLyric().catch(() => { diff --git a/src/core/lyric.ts b/src/core/lyric.ts index 0c1e82e..82cf076 100644 --- a/src/core/lyric.ts +++ b/src/core/lyric.ts @@ -17,7 +17,7 @@ import { } from '@/core/desktopLyric' import { getPosition } from '@/plugins/player' import playerState from '@/store/player/state' -import settingState from '@/store/setting/state' +// import settingState from '@/store/setting/state' /** * init lyric @@ -31,9 +31,9 @@ export const init = async() => { * @param lyric lyric str * @param translation lyric translation */ -const handleSetLyric = (lyric: string, translation = '', romalrc = '') => { - void setDesktopLyric(lyric, translation, romalrc) +const handleSetLyric = async(lyric: string, translation = '', romalrc = '') => { lrcSetLyric(lyric, translation, romalrc) + await setDesktopLyric(lyric, translation, romalrc) } /** @@ -57,7 +57,7 @@ export const pause = () => { * stop lyric */ export const stop = () => { - handleSetLyric('') + void handleSetLyric('') } /** @@ -80,18 +80,20 @@ export const setPlaybackRate = async(playbackRate: number) => { * toggle show translation * @param isShowTranslation is show translation */ -export const toggleTranslation = (isShowTranslation: boolean) => { +export const toggleTranslation = async(isShowTranslation: boolean) => { lrcToggleTranslation(isShowTranslation) - void toggleDesktopLyricTranslation(isShowTranslation) + await toggleDesktopLyricTranslation(isShowTranslation) + if (playerState.isPlay) play() } /** * toggle show roma lyric * @param isShowLyricRoma is show roma lyric */ -export const toggleRoma = (isShowLyricRoma: boolean) => { +export const toggleRoma = async(isShowLyricRoma: boolean) => { lrcToggleRoma(isShowLyricRoma) - void toggleDesktopLyricRoma(isShowLyricRoma) + await toggleDesktopLyricRoma(isShowLyricRoma) + if (playerState.isPlay) play() } export const play = () => { @@ -101,14 +103,14 @@ export const play = () => { } -export const setLyric = () => { +export const setLyric = async() => { if (!playerState.musicInfo.id) return if (playerState.musicInfo.lrc) { let tlrc = '' let rlrc = '' - if (settingState.setting['player.isShowLyricTranslation'] && playerState.musicInfo.tlrc) tlrc = playerState.musicInfo.tlrc - if (settingState.setting['player.isShowLyricRoma'] && playerState.musicInfo.rlrc) rlrc = playerState.musicInfo.rlrc - handleSetLyric(playerState.musicInfo.lrc, tlrc, rlrc) + if (playerState.musicInfo.tlrc) tlrc = playerState.musicInfo.tlrc + if (playerState.musicInfo.rlrc) rlrc = playerState.musicInfo.rlrc + await handleSetLyric(playerState.musicInfo.lrc, tlrc, rlrc) } if (playerState.isPlay) play() diff --git a/src/screens/Home/Views/Setting/settings/Player/IsShowLyricRoma.tsx b/src/screens/Home/Views/Setting/settings/Player/IsShowLyricRoma.tsx index 3c1fece..a864031 100644 --- a/src/screens/Home/Views/Setting/settings/Player/IsShowLyricRoma.tsx +++ b/src/screens/Home/Views/Setting/settings/Player/IsShowLyricRoma.tsx @@ -7,12 +7,14 @@ import { useSettingValue } from '@/store/setting/hook' import CheckBoxItem from '../../components/CheckBoxItem' +import { toggleRoma } from '@/core/lyric' export default memo(() => { const t = useI18n() const isShowLyricRoma = useSettingValue('player.isShowLyricRoma') const setShowLyricRoma = (isShowLyricRoma: boolean) => { updateSetting({ 'player.isShowLyricRoma': isShowLyricRoma }) + void toggleRoma(isShowLyricRoma) } return ( diff --git a/src/screens/Home/Views/Setting/settings/Player/IsShowLyricTranslation.tsx b/src/screens/Home/Views/Setting/settings/Player/IsShowLyricTranslation.tsx index 3386686..05480e4 100644 --- a/src/screens/Home/Views/Setting/settings/Player/IsShowLyricTranslation.tsx +++ b/src/screens/Home/Views/Setting/settings/Player/IsShowLyricTranslation.tsx @@ -7,12 +7,14 @@ import { useSettingValue } from '@/store/setting/hook' import CheckBoxItem from '../../components/CheckBoxItem' +import { toggleTranslation } from '@/core/lyric' export default memo(() => { const t = useI18n() const isShowLyricTranslation = useSettingValue('player.isShowLyricTranslation') const setShowLyricTranslation = (isShowLyricTranslation: boolean) => { updateSetting({ 'player.isShowLyricTranslation': isShowLyricTranslation }) + void toggleTranslation(isShowLyricTranslation) } return ( diff --git a/src/screens/PlayDetail/components/SettingPopup/settings/SettingPlaybackRate.tsx b/src/screens/PlayDetail/components/SettingPopup/settings/SettingPlaybackRate.tsx index ae07f54..3c3a4fd 100644 --- a/src/screens/PlayDetail/components/SettingPopup/settings/SettingPlaybackRate.tsx +++ b/src/screens/PlayDetail/components/SettingPopup/settings/SettingPlaybackRate.tsx @@ -46,8 +46,8 @@ const Volume = () => { setSliderSize(100) void setPlaybackRate(1).then(() => { void updateMetaData(playerState.musicInfo, playerState.isPlay, true) // 更新通知栏的播放速率 + void setLyricPlaybackRate(1) }) - void setLyricPlaybackRate(1) updateSetting({ 'player.playbackRate': 1 }) }