mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-15 17:30:27 +08:00
feat: 本次更新的公告右上角添加红点
This commit is contained in:
@@ -44,6 +44,8 @@ public class AnnouncementViewModel : Screen
|
||||
{
|
||||
public string Title { get; set; }
|
||||
|
||||
public bool IsNew { get; set; }
|
||||
|
||||
public string Content { get; set; }
|
||||
}
|
||||
|
||||
@@ -85,13 +87,22 @@ public class AnnouncementViewModel : Screen
|
||||
|
||||
private static ObservableCollection<AnnouncementSection> ParseAnnouncementInfo(string markdown)
|
||||
{
|
||||
const string NewString = "(NEW!!!)";
|
||||
var sections = markdown.Split(["### "], StringSplitOptions.RemoveEmptyEntries)
|
||||
.Select(section =>
|
||||
{
|
||||
var lines = section.Split('\n');
|
||||
bool isNew = false;
|
||||
if (lines.Length > 0 && lines[0].Contains(NewString, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
isNew = true;
|
||||
lines[0] = lines[0].Replace(NewString, string.Empty, StringComparison.OrdinalIgnoreCase).Trim();
|
||||
}
|
||||
|
||||
return new AnnouncementSection
|
||||
{
|
||||
Title = lines.FirstOrDefault(),
|
||||
IsNew = isNew,
|
||||
Content = "### " + string.Join("\n", lines).Trim([' ', '\n', '-']),
|
||||
};
|
||||
}).ToList();
|
||||
@@ -99,7 +110,7 @@ public class AnnouncementViewModel : Screen
|
||||
sections.Insert(0, new()
|
||||
{
|
||||
Title = "ALL~ the Announcements",
|
||||
Content = markdown,
|
||||
Content = markdown.Replace(NewString, string.Empty, StringComparison.OrdinalIgnoreCase).Trim(),
|
||||
});
|
||||
|
||||
return [.. sections];
|
||||
|
||||
@@ -40,10 +40,25 @@
|
||||
</hc:Interaction.Triggers>
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock
|
||||
Padding="5"
|
||||
Text="{Binding Title}"
|
||||
TextWrapping="Wrap" />
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock
|
||||
Grid.Column="0"
|
||||
Padding="5"
|
||||
Text="{Binding Title}"
|
||||
TextWrapping="Wrap" />
|
||||
<TextBlock
|
||||
Grid.Column="1"
|
||||
Margin="-8,-5,-5,0"
|
||||
Padding="5"
|
||||
Foreground="Red"
|
||||
Text="●"
|
||||
Visibility="{c:Binding IsNew}" />
|
||||
</Grid>
|
||||
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
|
||||
Reference in New Issue
Block a user