-
Notifications
You must be signed in to change notification settings - Fork 98
feat: 插件歌词优先偏好配置 & 音源插件图形化配置 #203
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
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 |
|---|---|---|
|
|
@@ -14,6 +14,7 @@ import { | |
| resolveLocalRepoLyric, | ||
| resolveOnlineByPreference, | ||
| resolvePluginLyric, | ||
| resolvePreferredPluginLyric, | ||
| resolveStreamingByPreference, | ||
| resolveTTMLOverlay, | ||
| type LocalLyric, | ||
|
|
@@ -136,6 +137,19 @@ const tryPluginFallback = async (token: number, track: Track): Promise<boolean> | |
| return resolved ? commitResolvedAndHasParsed(token, resolved) : false; | ||
| }; | ||
|
|
||
| /** | ||
| * 插件歌词作为首选来源:开启偏好时在所有网络来源之前尝试 | ||
| * 关闭时不发起请求,插件仍按原有顺序兜底 | ||
| * @param token - 竞态 token | ||
| * @param track - 歌曲信息 | ||
| * @returns 是否已提交有效歌词 | ||
| */ | ||
| const tryPreferredPlugin = async (token: number, track: Track): Promise<boolean> => { | ||
|
Member
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. 按照新方案,该函数需要删除;在现有的 |
||
| const resolved = await resolvePreferredPluginLyric(track); | ||
| if (token !== currentToken) return false; | ||
| return resolved ? commitResolvedAndHasParsed(token, resolved) : false; | ||
| }; | ||
|
|
||
| /** | ||
| * 流媒体歌词加载:按来源偏好解析,失败后使用插件和内嵌歌词兜底 | ||
| * @param token - 竞态 token | ||
|
|
@@ -213,6 +227,9 @@ export const loadForTrack = async (detail: TrackDetail | null): Promise<void> => | |
| // 本地 TTML 歌词库最高优先 | ||
| if (await tryLocalRepo(token, track)) return; | ||
| if (token !== currentToken) return; | ||
| // 插件首选:仅在开启偏好时先于所有网络来源 | ||
| if (await tryPreferredPlugin(token, track)) return; | ||
| if (token !== currentToken) return; | ||
| // 在线歌曲(任一在线平台) | ||
| if (isPlatform(track.source)) { | ||
| await loadPlatformLyric(token, track); | ||
|
|
@@ -262,6 +279,9 @@ const refreshPreference = async (): Promise<void> => { | |
| // 本地 TTML 歌词库最高优先 | ||
| if (await tryLocalRepo(token, track)) return; | ||
| if (token !== currentToken) return; | ||
| // 插件首选 | ||
| if (await tryPreferredPlugin(token, track)) return; | ||
| if (token !== currentToken) return; | ||
| if (track.source === "streaming") { | ||
| await loadStreamingLyric(token, track, media.detail); | ||
| return; | ||
|
|
@@ -302,6 +322,7 @@ export const watchLyricPreference = (): void => { | |
| () => [ | ||
| settings.lyric.lyricSourcePreference, | ||
| settings.lyric.smartPreferOnline, | ||
| settings.lyric.preferPluginLyric, | ||
| settings.lyric.detectBackgroundLyrics, | ||
| settings.system.lyric.enableOnlineTTMLLyric, | ||
| settings.system.localLyric.enableLocalTTMLOverride, | ||
|
|
||
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 |
|---|---|---|
|
|
@@ -295,6 +295,21 @@ export const resolvePluginLyric = async (track: Track): Promise<ResolvedLyric | | |
| return null; | ||
| }; | ||
|
|
||
| /** 插件歌词是否作为首选来源(本地 TTML 仓库仍最高) */ | ||
| export const isPluginLyricPreferred = (): boolean => | ||
| useSettingsStore().lyric.preferPluginLyric === true; | ||
|
|
||
| /** | ||
| * 插件歌词作为首选时的前置尝试 | ||
| * 关闭该偏好时不发起任何插件请求,保持原有兜底语义 | ||
| * @param track - 歌曲信息 | ||
| * @returns 命中的插件歌词,未开启或未命中返回 null | ||
| */ | ||
| export const resolvePreferredPluginLyric = async (track: Track): Promise<ResolvedLyric | null> => { | ||
|
Member
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. 按照新方案,该函数需要删除 |
||
| if (!isPluginLyricPreferred()) return null; | ||
| return resolvePluginLyric(track); | ||
| }; | ||
|
|
||
| /** | ||
| * 为下一首歌曲解析最终歌词结果 | ||
| * 本地歌曲依赖实际加载后的 TrackDetail,不在此处提前解析 | ||
|
|
@@ -311,6 +326,10 @@ export const resolveLyricForPreload = async ( | |
| if (!shouldContinue()) return null; | ||
| if (localRepo) return localRepo; | ||
|
|
||
| const preferredPlugin = await resolvePreferredPluginLyric(track); | ||
| if (!shouldContinue()) return null; | ||
| if (preferredPlugin) return preferredPlugin; | ||
|
|
||
| if (track.source === "streaming") { | ||
| const streaming = await resolveStreamingByPreference(track, shouldContinue); | ||
| if (!shouldContinue()) return null; | ||
|
|
||
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.