-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix: 修复滞后加载状态覆盖桌面歌词的问题 #1074
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
abkkkbb
wants to merge
1
commit into
SPlayer-Dev:dev
Choose a base branch
from
abkkkbb:codex/fix-desktop-lyric-loading
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+28
−4
Open
fix: 修复滞后加载状态覆盖桌面歌词的问题 #1074
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -182,6 +182,15 @@ const lyricData = reactive<LyricData>({ | |
| lyricIndex: -1, | ||
| }); | ||
|
|
||
| const hasLyricLines = (data: Pick<LyricData, "lrcData" | "yrcData">) => | ||
| Boolean(data.lrcData?.length || data.yrcData?.length); | ||
|
|
||
| const shouldIgnoreLoadingUpdate = (data: LyricData) => { | ||
| if (data.lyricLoading !== true) return false; | ||
| if (hasLyricLines(data) || !hasLyricLines(lyricData)) return false; | ||
| return data.songId === undefined || data.songId === lyricData.songId; | ||
| }; | ||
|
Comment on lines
+188
to
+192
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 在切歌场景下,来自前一首歌曲的滞后“加载中”消息可能覆盖当前歌曲的状态。建议在当前已有歌词的情况下,忽略任何不带歌词数据的加载状态更新。这能有效防止 UI 闪烁并确保数据一致性,符合项目在处理异步更新时优先保证数据一致性和防止视觉闪烁的原则。 References
|
||
|
|
||
| // 锚点时间(毫秒)与锚点帧时间,用于插值推进 | ||
| let baseMs = 0; | ||
| let anchorTick = 0; | ||
|
|
@@ -306,7 +315,7 @@ const renderLyricLines = computed<RenderLine[]>(() => { | |
| return placeholder("SPlayer Desktop Lyric"); | ||
| } | ||
| // 加载中 | ||
| if (lyricData.lyricLoading) return placeholder("歌词加载中..."); | ||
| if (lyricData.lyricLoading && !lyrics?.length) return placeholder("歌词加载中..."); | ||
| // 纯音乐 | ||
| if (!lyrics?.length) return placeholder("纯音乐,请欣赏"); | ||
| // 获取当前歌词索引 | ||
|
|
@@ -708,6 +717,12 @@ onMounted(() => { | |
| window.electron.ipcRenderer.on( | ||
| "desktop-lyric:update-data", | ||
| (_event, data: LyricData & { sendTimestamp?: number }) => { | ||
| if (shouldIgnoreLoadingUpdate(data)) { | ||
| if (isInitializing.value) { | ||
| isInitializing.value = false; | ||
| } | ||
| return; | ||
| } | ||
| Object.assign(lyricData, data); | ||
|
Comment on lines
+720
to
726
|
||
| // 首次接收到歌词数据时,立即结束初始化状态 | ||
| if (isInitializing.value) { | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
歌曲 ID (
song.id) 在项目中可能是number或string类型(例如在retryInfo中定义为number | string),但LyricData接口中将其定义为了number。建议将LyricData接口中的songId类型更新为number | string以确保类型定义与实际 IPC 通信数据一致。这符合项目信任内部 IPC 数据结构的原则,通过完善类型定义而非增加运行时校验来保证安全。References