Compare commits

...

3 Commits

Author SHA1 Message Date
Zhe Fang
6820e59597 Update issue templates 2025-11-11 11:55:54 -05:00
Zhe Fang
c7b0d409ad chores: rollback PasswordVaultHelper 2025-11-11 11:22:58 -05:00
Zhe Fang
6c942657fc chores:
- Support reading local album art file passed by LX Music server
- Support listening LX Music portable version
- Fix translation not be read in search window
2025-11-11 10:44:10 -05:00
8 changed files with 118 additions and 19 deletions

22
.github/ISSUE_TEMPLATE/bug-反馈.md vendored Normal file
View File

@@ -0,0 +1,22 @@
---
name: Bug 反馈
about: 帮助我们改进 BetterLyrics
title: ''
labels: ''
assignees: ''
---
**描述问题**
**屏幕截图**
**BetterLyrics 版本**
v1.0.XX.0
**日志**
将日志以单文件形式上传到此处。你可以在此处找到日志文件 `%LocalAppData%\Packages\37412.BetterLyrics_rd1g0rsrrtxw8\LocalCache\logs`
**附加信息**

21
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@@ -0,0 +1,21 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''
---
**Describe the bug**
**Screenshots**
**BetterLyrics Version**
v1.0.XX.0
**Logs**
Upload logs as a file here. You can find logs at `%LocalAppData%\Packages\37412.BetterLyrics_rd1g0rsrrtxw8\LocalCache\logs`
**Additional context**

View File

@@ -0,0 +1,13 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''
---
**Describe the solution you'd like**
**Additional context**

13
.github/ISSUE_TEMPLATE/功能建议.md vendored Normal file
View File

@@ -0,0 +1,13 @@
---
name: 功能建议
about: 提供宝贵的功能建议
title: ''
labels: ''
assignees: ''
---
**描述你所构想的解决方案**
**附加信息**

View File

@@ -315,15 +315,27 @@ namespace BetterLyrics.WinUI3.Helper
// data URL直接解析
return DataUrlToByteArray(url);
}
else if (Uri.TryCreate(url, UriKind.Absolute, out var uri) &&
(uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps))
else if (Uri.TryCreate(url, UriKind.Absolute, out var uri))
{
// 普通网络图片,下载
return await DownloadImageAsByteArrayAsync(url);
if (uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps)
{
// 普通网络图片,下载
return await DownloadImageAsByteArrayAsync(url);
}
else if (uri.Scheme == Uri.UriSchemeFile)
{
// 本地文件,读取
var file = await StorageFile.GetFileFromPathAsync(uri.LocalPath);
var buffer = await FileIO.ReadBufferAsync(file);
return buffer.ToArray();
}
else
{
return null;
}
}
else
{
// 其他类型暂不支持
return null;
}
}

View File

@@ -20,10 +20,17 @@ namespace BetterLyrics.WinUI3.Helper
var vault = new PasswordVault();
// 删除旧值(避免重复存储)
var oldCredential = vault.FindAllByResource(resource).Where(x => x.UserName == key).FirstOrDefault();
if (oldCredential != null)
try
{
vault.Remove(oldCredential);
var oldCredential = vault.Retrieve(resource, key);
if (oldCredential != null)
{
vault.Remove(oldCredential);
}
}
catch
{
// 没有旧值就忽略
}
vault.Add(new PasswordCredential(resource, key, value));
@@ -38,13 +45,13 @@ namespace BetterLyrics.WinUI3.Helper
public static string? Get(string resource, string key)
{
var vault = new PasswordVault();
var credential = vault.FindAllByResource(resource).Where(x => x.UserName == key).FirstOrDefault();
if (credential != null)
try
{
var credential = vault.Retrieve(resource, key);
credential.RetrievePassword();
return credential.Password;
}
else
catch
{
return null;
}
@@ -56,11 +63,15 @@ namespace BetterLyrics.WinUI3.Helper
public static void Delete(string resource, string key)
{
var vault = new PasswordVault();
var credential = vault.FindAllByResource(resource).Where(x => x.UserName == key).FirstOrDefault();
if (credential != null)
try
{
var credential = vault.Retrieve(resource, key);
vault.Remove(credential);
}
catch
{
// 不存在就忽略
}
}
}
}
}

View File

@@ -197,7 +197,7 @@ namespace BetterLyrics.WinUI3.Services.MediaSessionsService
return _settingsService.AppSettings.MediaSourceProvidersInfo.FirstOrDefault(s => s.Provider == id)?.IsEnabled ?? true;
}
private bool IsMediaSourceTimelineSyncEnabled(string id)
private bool IsMediaSourceTimelineSyncEnabled(string? id)
{
return _settingsService.AppSettings.MediaSourceProvidersInfo.FirstOrDefault(s => s.Provider == id)?.IsTimelineSyncEnabled ?? true;
}
@@ -519,7 +519,7 @@ namespace BetterLyrics.WinUI3.Services.MediaSessionsService
{
_dispatcherQueue.TryEnqueue(DispatcherQueuePriority.Low, async () =>
{
if (_cachedSongInfo?.PlayerId == Constants.PlayerID.LXMusic)
if (PlayerIdMatcher.IsLXMusic(_cachedSongInfo?.PlayerId))
{
var data = JsonSerializer.Deserialize(e.Message, Serialization.SourceGenerationContext.Default.JsonElement);
if (data.ValueKind == JsonValueKind.Number)
@@ -533,7 +533,7 @@ namespace BetterLyrics.WinUI3.Services.MediaSessionsService
_lxMusicDurationSeconds = data.GetDouble();
}
if (IsMediaSourceTimelineSyncEnabled(Constants.PlayerID.LXMusic))
if (IsMediaSourceTimelineSyncEnabled(_cachedSongInfo?.PlayerId))
{
TimelineChanged?.Invoke(this, new TimelineChangedEventArgs(TimeSpan.FromSeconds(_lxMusicPositionSeconds), TimeSpan.FromSeconds(_lxMusicDurationSeconds)));
}
@@ -547,7 +547,14 @@ namespace BetterLyrics.WinUI3.Services.MediaSessionsService
{
_logger.LogInformation("LX Music Album Art URL: {url}", picUrl);
_lxMusicAlbumArtBytes = await ImageHelper.GetImageBytesFromUrlAsync(picUrl);
_SMTCAlbumArtBuffer = _lxMusicAlbumArtBytes.AsBuffer();
if (_lxMusicAlbumArtBytes != null)
{
_SMTCAlbumArtBuffer = _lxMusicAlbumArtBytes.AsBuffer();
}
else
{
_SMTCAlbumArtBuffer = null;
}
UpdateAlbumArt();
}
}

View File

@@ -183,7 +183,7 @@ namespace BetterLyrics.WinUI3.ViewModels
{
var lyricsParser = new LyricsParser();
lyricsParser.Parse(
AppSettings.MappedSongSearchQueries.ToList(),
[MappedSongSearchQuery ?? new()],
MappedSongSearchQuery?.OriginalTitle ?? "",
MappedSongSearchQuery?.OriginalArtist ?? "",
MappedSongSearchQuery?.OriginalAlbum ?? "",