chores: update StatsDashboardControl

This commit is contained in:
Zhe Fang
2025-12-30 14:04:08 -05:00
parent f39ad54df8
commit 8ec71fcfb7
5 changed files with 24 additions and 59 deletions

View File

@@ -194,11 +194,6 @@
<ItemsControl.ItemTemplate>
<DataTemplate x:DataType="models:PlayerStatDisplayItem">
<Grid Margin="0,4">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
@@ -219,23 +214,6 @@
Text="plays" />
</TextBlock>
</Grid>
<Grid
Grid.Row="1"
Height="4"
Margin="0,4,0,0"
CornerRadius="2">
<Rectangle
Fill="{ThemeResource SystemControlBackgroundBaseLowBrush}"
RadiusX="2"
RadiusY="2" />
<Rectangle
Width="{x:Bind DisplayWidth}"
HorizontalAlignment="Left"
Fill="{ThemeResource AccentFillColorDefaultBrush}"
RadiusX="2"
RadiusY="2" />
</Grid>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>

View File

@@ -10,7 +10,6 @@ namespace BetterLyrics.WinUI3.Models
public string PlayerId { get; set; }
public int PlayCount { get; set; }
public double DisplayWidth { get; set; }
public string PlayerName => PlayerIdHelper.GetDisplayName(PlayerId);
}
}

View File

@@ -333,7 +333,7 @@ namespace BetterLyrics.WinUI3.Services.MediaSessionsService
_scrobbleStopwatch.Elapsed.TotalMilliseconds >= (lastSong.DurationMs / 2))
{
// 写入本地播放记录
var playHistoryItem = CurrentSongInfo.ToPlayHistoryItem(_scrobbleStopwatch.Elapsed.TotalMilliseconds);
var playHistoryItem = lastSong.ToPlayHistoryItem(_scrobbleStopwatch.Elapsed.TotalMilliseconds);
if (playHistoryItem != null)
{
// 后台

View File

@@ -149,7 +149,6 @@ namespace BetterLyrics.WinUI3.Services.PlayHistoryService
{
var random = new Random();
// === 1. 扩充的数据池 (涵盖多语言、多风格) ===
var presetSongs = new List<(string Title, string Artist, string Album)>
{
// --- 欧美流行 ---
@@ -208,9 +207,8 @@ namespace BetterLyrics.WinUI3.Services.PlayHistoryService
("Summer", "Calvin Harris", "Motion"),
};
// 模拟播放器分布:假设 Spotify 和 MusicBee 用得最多
var playerIds = new[] {
"Spotify", "Spotify", "Spotify", // 权重高
"Spotify", "Spotify", "Spotify",
"MusicBee", "MusicBee",
"QQMusic",
"NeteaseCloudMusic",
@@ -219,20 +217,16 @@ namespace BetterLyrics.WinUI3.Services.PlayHistoryService
int addedCount = 0;
// 我们用 while 循环,直到凑够 count 条有效的记录为止
while (addedCount < count)
{
// 随机挑一首歌
var song = presetSongs[random.Next(presetSongs.Count)];
// 随机挑一个播放器
var playerId = playerIds[random.Next(playerIds.Length)];
// 生成时间:过去 60 天内均匀分布
var daysBack = random.Next(0, 60);
// 生成时间:过去 365 天内均匀分布
var daysBack = random.Next(0, 365);
var hoursBack = random.Next(0, 24);
var minutesBack = random.Next(0, 60);
// 加一点随机秒数,防止时间完全重叠
var secondsBack = random.Next(0, 60);
var startedAt = DateTime.Now

View File

@@ -104,16 +104,10 @@ namespace BetterLyrics.WinUI3.ViewModels
foreach (var item in stats.OrderByDescending(x => x.Count))
{
double maxBarWidth = 150.0;
double calculatedWidth = (item.Count / maxCount) * maxBarWidth;
if (calculatedWidth < 2 && item.Count > 0) calculatedWidth = 2;
PlayerStats.Add(new PlayerStatDisplayItem
{
PlayerId = item.PlayerId,
PlayCount = item.Count,
DisplayWidth = calculatedWidth
});
}
}