File tree Expand file tree Collapse file tree 3 files changed +79
-0
lines changed
Expand file tree Collapse file tree 3 files changed +79
-0
lines changed Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" utf-8" ?>
2+ <Page
3+ x : Class =" Edge.ReleaseItem"
4+ xmlns =" http://schemas.microsoft.com/winfx/2006/xaml/presentation"
5+ xmlns : x =" http://schemas.microsoft.com/winfx/2006/xaml"
6+ xmlns : local =" using:Edge"
7+ xmlns : d =" http://schemas.microsoft.com/expression/blend/2008"
8+ xmlns : mc =" http://schemas.openxmlformats.org/markup-compatibility/2006"
9+ xmlns : labs =" using:CommunityToolkit.Labs.WinUI.MarkdownTextBlock"
10+ mc : Ignorable =" d" >
11+ <ScrollView >
12+ <StackPanel Spacing =" 5" Margin =" 10" >
13+ <HyperlinkButton
14+ Content =" 在 Github 上查看更详细的发行说明"
15+ NavigateUri =" https://github.com/wtcpython/WinUIEdge/releases" />
16+ <labs : MarkdownTextBlock x : Name =" markdown" />
17+ </StackPanel >
18+ </ScrollView >
19+ </Page >
Original file line number Diff line number Diff line change 1+ using CommunityToolkit . Labs . WinUI . MarkdownTextBlock ;
2+ using Microsoft . UI . Xaml . Controls ;
3+ using System . Collections . Generic ;
4+ using System . Net . Http ;
5+ using System . Text . Json ;
6+ using System . Threading . Tasks ;
7+
8+
9+ namespace Edge
10+ {
11+ public class GitHubRelease
12+ {
13+ public string name { get ; set ; }
14+ public string body { get ; set ; }
15+ }
16+
17+ public sealed partial class ReleaseItem : Page
18+ {
19+ public ReleaseItem ( )
20+ {
21+ this . InitializeComponent ( ) ;
22+ markdown . Config = new MarkdownConfig ( ) ;
23+ SetText ( ) ;
24+ }
25+
26+ public async void SetText ( )
27+ {
28+ List < GitHubRelease > releases = await GetReleasesAsync ( ) ;
29+ string contents = string . Empty ;
30+ releases . ForEach ( item =>
31+ {
32+ string content = "# " + item . name + "\n " + item . body + "\n " ;
33+ contents += content ;
34+ } ) ;
35+ markdown . Text = contents ;
36+ }
37+
38+ public static async Task < List < GitHubRelease > > GetReleasesAsync ( )
39+ {
40+ HttpClient client = new ( ) ;
41+ client . DefaultRequestHeaders . UserAgent . ParseAdd ( "WinUIEdge/1.0" ) ;
42+ var response = await client . GetAsync ( "https://api.github.com/repos/wtcpython/WinUIEdge/releases" ) ;
43+
44+ if ( response . IsSuccessStatusCode )
45+ {
46+ var json = await response . Content . ReadAsStringAsync ( ) ;
47+ return JsonSerializer . Deserialize < List < GitHubRelease > > ( json ) ;
48+ }
49+ return null ;
50+ }
51+ }
52+ }
Original file line number Diff line number Diff line change 5353 </NavigationViewItem >
5454 </NavigationView .MenuItems>
5555
56+ <NavigationView .FooterMenuItems>
57+ <NavigationViewItem Content =" 新增内容" Tag =" ReleaseItem" >
58+ <NavigationViewItem .Icon>
59+ <FontIcon Glyph ="  " />
60+ </NavigationViewItem .Icon>
61+ </NavigationViewItem >
62+ </NavigationView .FooterMenuItems>
63+
5664 <Frame x : Name =" ContentFrame" />
5765 </NavigationView >
5866
You can’t perform that action at this time.
0 commit comments