mirror of
https://github.com/jayfunc/BetterLyrics.git
synced 2026-01-12 10:54:55 +08:00
chores: update StatsDashboardControl
This commit is contained in:
@@ -194,47 +194,25 @@
|
||||
<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" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock
|
||||
FontSize="13"
|
||||
Style="{ThemeResource BodyTextBlockStyle}"
|
||||
Text="{x:Bind PlayerName}" />
|
||||
<TextBlock
|
||||
Grid.Column="1"
|
||||
VerticalAlignment="Center"
|
||||
FontWeight="SemiBold">
|
||||
<Run Text="{x:Bind PlayCount}" />
|
||||
<Run
|
||||
FontSize="10"
|
||||
FontWeight="Normal"
|
||||
Foreground="{ThemeResource SystemControlForegroundBaseMediumBrush}"
|
||||
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.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock
|
||||
FontSize="13"
|
||||
Style="{ThemeResource BodyTextBlockStyle}"
|
||||
Text="{x:Bind PlayerName}" />
|
||||
<TextBlock
|
||||
Grid.Column="1"
|
||||
VerticalAlignment="Center"
|
||||
FontWeight="SemiBold">
|
||||
<Run Text="{x:Bind PlayCount}" />
|
||||
<Run
|
||||
FontSize="10"
|
||||
FontWeight="Normal"
|
||||
Foreground="{ThemeResource SystemControlForegroundBaseMediumBrush}"
|
||||
Text="plays" />
|
||||
</TextBlock>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
// 后台
|
||||
|
||||
@@ -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", // 权重高
|
||||
var playerIds = new[] {
|
||||
"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
|
||||
|
||||
@@ -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
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user