返回提交历史
Modified
XFENewsApplication.Core/Utilities/Helpers/ClimbHelper.cs
+1
-1
Added
XFENewsApplication/Assets/icon.png
+0
-0
Modified
XFENewsApplication/MainWindow.xaml.cs
+1
-1
Modified
XFENewsApplication/Models/TextArticlePart.cs
+1
-1
Modified
XFENewsApplication/ViewModels/NewsViewPageViewModel.cs
+24
-12
Modified
XFENewsApplication/Views/AppShellPage.xaml
+1
-1
Modified
XFENewsApplication/Views/NewsViewPage.xaml
+18
-9
Modified
XFENewsApplication/Views/NewsViewPage.xaml.cs
+13
-2
Modified
XFENewsApplication/XFENewsApplication.csproj
+1
-0
XFEstudio/XFENewsApplication
更新应用程序图标并优化新闻获取逻辑
- 在 ClimbHelper.cs 中添加 MSNAPI 检查,更新请求 URL。 - 更改 MainWindow.xaml.cs 中的应用程序图标为 icon.png。 - 在 TextArticlePart.cs 中将默认字体大小改为 16。 - 移除 NewsViewPageViewModel.cs 中对 System.Text.Json 的引用,添加对 System.Diagnostics 的引用,并更新 INavigationViewService 的获取方式。 - 添加重试机制以获取新闻内容,并在异常时提供详细错误信息。 - 新增 OpenInBrowser 命令以支持在浏览器中打开新闻源链接。 - 更新 AppShellPage.xaml 和 NewsViewPage.xaml 中的图标和样式,支持在浏览器中打开新闻。 - 在 NewsViewPage.xaml.cs 中设置 NavigationViewService 的内容边距和标题。 - 在 XFENewsApplication.csproj 中添加应用程序图标配置。 - 添加新的 PNG 图像数据到 icon.png。
7af82af
代码差异
9 个文件
+60
-27
@@ -22,7 +22,7 @@ public static class ClimbHelper
22
22
QueryableJsonNode authJsonNode = await client.GetStringAsync("https://www.msn.cn/resolver/api/resolve/v3/config/?expType=AppConfig&expInstance=default&apptype=homePage&v=20250401.183&targetScope={%22audienceMode%22:%22adult%22,%22browser%22:{%22browserType%22:%22edgeChromium%22,%22version%22:%22135%22,%22ismobile%22:%22false%22},%22deviceFormFactor%22:%22desktop%22,%22domain%22:%22www.msn.cn%22,%22locale%22:{%22content%22:{%22language%22:%22zh%22,%22market%22:%22cn%22},%22display%22:{%22language%22:%22zh%22,%22market%22:%22cn%22}},%22os%22:%22windows%22,%22platform%22:%22web%22,%22pageType%22:%22hp%22,%22pageExperiments%22:[]}");
23
23
MSNAPI = authJsonNode["configs"]["StripeWC/default"]["properties"]["apikey"];
24
24
}
25
var result = await client.GetStringAsync($"https://assets.msn.com/service/news/feed/pages/weblayout?User=&activityId=&adoffsets=c1:-1,c2:-1&apikey={MSNAPI}&audienceMode=adult&cm=zh-cn&colstatus=c1:0,c2:0&column=c2&colwidth=300&contentType=article,video,slideshow,webcontent&it=edgeid&l3v=2&layout=c2&memory=8&newsSkip=0&newsTop=48&ocid=hponeservicefeed&pgc=11&private=1&scn=APP_ANON&timeOut=1000&vpSize=721x674&wposchema=byregion");
25
var result = await client.GetStringAsync($"https://assets.msn.com/service/news/feed/pages/weblayout?User=&activityId=&adoffsets=c1:-1,c2:-1&apikey={MSNAPI}&audienceMode=adult&cm=zh-cn&colstatus=c1:0,c2:0&column=c2&colwidth=300&contentType=article&it=edgeid&l3v=2&layout=c2&memory=8&newsSkip=0&newsTop=48&ocid=hponeservicefeed&pgc=11&private=1&scn=APP_ANON&timeOut=1000&vpSize=721x674&wposchema=byregion");
26
26
using var document = JsonDocument.Parse(result);
27
27
int i = 0;
28
28
foreach (var subNode in document.RootElement.GetProperty("sections").EnumerateArray().ElementAt(0).GetProperty("cards").EnumerateArray())
二进制文件已变更,无法进行逐行预览。
@@ -13,7 +13,7 @@ public sealed partial class MainWindow : Window
13
13
{
14
14
this.InitializeComponent();
15
15
ExtendsContentIntoTitleBar = true;
16
AppWindow.SetIcon(Path.Combine(AppContext.BaseDirectory, "Assets/Icons/EditorIcon.ico"));
16
AppWindow.SetIcon(Path.Combine(AppContext.BaseDirectory, "Assets/icon.png"));
17
17
AppWindow.TitleBar.PreferredHeightOption = Microsoft.UI.Windowing.TitleBarHeightOption.Tall;
18
18
UISettings.ColorValuesChanged += (_, _) => DispatcherQueue.TryEnqueue(() => AppThemeHelper.ChangeTheme(AppThemeHelper.Theme));
19
19
}
@@ -5,6 +5,6 @@ namespace XFENewsApplication.Models;
5
5
6
6
public class TextArticlePart : ArticlePart
7
7
{
8
public double FontSize { get; set; } = 14;
8
public double FontSize { get; set; } = 16;
9
9
public FontWeight FontWeight { get; set; } = FontWeights.Normal;
10
10
}
@@ -1,14 +1,11 @@
1
1
using CommunityToolkit.Mvvm.ComponentModel;
2
2
using CommunityToolkit.Mvvm.Input;
3
3
using System.Collections.ObjectModel;
4
using System.Text.Json;
4
using System.Diagnostics;
5
5
using XFEExtension.NetCore.WinUIHelper.Interface.Services;
6
6
using XFEExtension.NetCore.WinUIHelper.Utilities;
7
using XFEExtension.NetCore.XFETransform.JsonConverter;
8
7
using XFENewsApplication.Core.Models;
9
8
using XFENewsApplication.Core.Utilities.Helpers;
10
using XFENewsApplication.Implements.Services;
11
using XFENewsApplication.Interface.Services;
12
9
using XFENewsApplication.Models;
13
10
using XFENewsApplication.Profiles.CrossVersionProfiles;
14
11
using XFENewsApplication.Utilities.Helper;
@@ -23,7 +20,7 @@ public partial class NewsViewPageViewModel : ViewModelBase
23
20
double sideBarWidth = SystemProfile.SideBarWidth;
24
21
private List<NewsSource> newsList = [];
25
22
public INavigationParameterService<string> NavigationParameterService { get; set; } = ServiceManager.GetService<INavigationParameterService<string>>();
26
public INavigationViewService? NavigationViewService { get; set; } = ServiceManager.GetService<INavigationViewService>();
23
public INavigationViewService? NavigationViewService { get; set; } = ServiceManager.GetGlobalService<INavigationViewService>();
27
24
public IListViewService NewsListViewService { get; set; } = ServiceManager.GetService<IListViewService>();
28
25
public IListViewService ContentListViewService { get; set; } = ServiceManager.GetService<IListViewService>();
29
26
public IDialogService DialogService { get; set; } = ServiceManager.GetService<IDialogService>();
@@ -38,20 +35,28 @@ public partial class NewsViewPageViewModel : ViewModelBase
38
35
39
36
private async void ListViewService_SelectionChanged(object sender, SelectionChangedEventArgs e)
40
37
{
38
ContentList.Clear();
41
39
using var client = new HttpClient();
42
40
client.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36 Edg/129.0.0.0");
43
try
41
int reTryTimes = 0;
42
Exception? exception = null;
43
while (reTryTimes < 5)
44
44
{
45
45
if (NewsListViewService.ListView.SelectedItem is NewsSource newsSource)
46
46
{
47
var result = await client.GetStringAsync($"https://assets.msn.cn/content/view/v2/Detail/zh-cn/{newsSource.ID}");
48
LoadContentList(ArticleDisplayHelper.ConvertToArticlePart(result));
47
try
48
{
49
var result = await client.GetStringAsync($"https://assets.msn.cn/content/view/v2/Detail/zh-cn/{newsSource.ID}");
50
LoadContentList(ArticleDisplayHelper.ConvertToArticlePart(result));
51
return;
52
}
53
catch (Exception ex)
54
{
55
exception = ex;
56
}
49
57
}
50
58
}
51
catch (Exception ex)
52
{
53
ServiceManager.GetGlobalService<IMessageService>()?.ShowMessage(ex.Message, "无法获取新闻", InfoBarSeverity.Warning);
54
}
59
ServiceManager.GetGlobalService<IMessageService>()?.ShowMessage(exception?.Message?.ToString() ?? "未知原因", "无法获取新闻", InfoBarSeverity.Warning);
55
60
}
56
61
57
62
private async void NavigationParameterService_ParameterChange(object? sender, string? e)
@@ -89,4 +94,11 @@ public partial class NewsViewPageViewModel : ViewModelBase
89
94
});
90
95
LoadNewsSource(newsList);
91
96
}
97
98
[RelayCommand]
99
void OpenInBrowser()
100
{
101
if (NewsListViewService.ListView.SelectedItem is NewsSource newsSource)
102
Process.Start(new ProcessStartInfo(newsSource.Url) { UseShellExecute = true });
103
}
92
104
}
@@ -11,7 +11,7 @@
11
11
12
12
<Grid x:Name="mainGrid">
13
13
<Grid x:Name="appTitleBar" Canvas.ZIndex="1" Height="{Binding ElementName=navigationView, Path=CompactPaneLength}" IsHitTestVisible="True" VerticalAlignment="Top">
14
<Image Source="/Assets/Icon.ico" HorizontalAlignment="Left" Width="16" Height="16"/>
14
<Image Source="/Assets/icon.png" HorizontalAlignment="Left" Width="16" Height="16"/>
15
15
<TextBlock Text="新闻" VerticalAlignment="Center" TextWrapping="NoWrap" Margin="28,0,0,0"/>
16
16
</Grid>
17
17
<Grid x:Name="rightPanelGrid" Canvas.ZIndex="2" Margin="0,50,0,0">
@@ -30,7 +30,7 @@
30
30
<ColumnDefinition/>
31
31
</Grid.ColumnDefinitions>
32
32
<Border x:Name="sideBar" MinWidth="300" MaxWidth="800" Width="{x:Bind ViewModel.SideBarWidth, Mode=TwoWay}">
33
<ListView x:Name="newsSourceListView" ItemsSource="{x:Bind ViewModel.NewsList}" SelectionMode="Single" SelectedIndex="{x:Bind ViewModel.SelectedIndex, Mode=TwoWay}" ScrollViewer.VerticalScrollBarVisibility="Hidden">
33
<ListView x:Name="newsSourceListView" ItemsSource="{x:Bind ViewModel.NewsList}" SelectionMode="Single" SelectedIndex="{x:Bind ViewModel.SelectedIndex, Mode=TwoWay}" ScrollViewer.VerticalScrollBarVisibility="Auto" Margin="0,5,0,0">
34
34
<ListView.ItemTemplate>
35
35
<DataTemplate x:DataType="coremodel:NewsSource">
36
36
<StackPanel Orientation="Vertical" Padding="5,24" Spacing="12">
@@ -41,7 +41,7 @@
41
41
</ListView.ItemTemplate>
42
42
<ListView.ItemContainerStyle>
43
43
<Style TargetType="ListViewItem" BasedOn="{StaticResource DefaultListViewItemStyle}">
44
<Setter Property="Margin" Value="0,0,0,2"/>
44
<Setter Property="Margin" Value="4,0,5,4"/>
45
45
<Setter Property="CornerRadius" Value="12"/>
46
46
</Style>
47
47
</ListView.ItemContainerStyle>
@@ -49,13 +49,22 @@
49
49
</Border>
50
50
<controls:ContentSizer Grid.Column="1" TargetControl="{x:Bind sideBar}" CornerRadius="4"/>
51
51
<Border Grid.Column="2">
52
<ListView x:Name="contentListView" ItemsSource="{x:Bind ViewModel.ContentList}" SelectionMode="None" ItemTemplateSelector="{StaticResource ArticleDataTemplateSelector}">
53
<ListView.ItemContainerStyle>
54
<Style BasedOn="{StaticResource DefaultListViewItemStyle}" TargetType="ListViewItem">
55
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
56
</Style>
57
</ListView.ItemContainerStyle>
58
</ListView>
52
<Grid>
53
<ListView x:Name="contentListView" Grid.Row="1" ItemsSource="{x:Bind ViewModel.ContentList}" SelectionMode="None" ItemTemplateSelector="{StaticResource ArticleDataTemplateSelector}">
54
<ListView.ItemContainerStyle>
55
<Style BasedOn="{StaticResource DefaultListViewItemStyle}" TargetType="ListViewItem">
56
<Setter Property="MaxWidth" Value="950"/>
57
</Style>
58
</ListView.ItemContainerStyle>
59
</ListView>
60
<CommandBar Background="{ThemeResource AcrylicInAppFillColorDefaultBrush}" VerticalAlignment="Bottom" DefaultLabelPosition="Right">
61
<AppBarButton Label="在浏览器中打开" Command="{x:Bind ViewModel.OpenInBrowserCommand}">
62
<AppBarButton.Icon>
63
<FontIcon Glyph=""/>
64
</AppBarButton.Icon>
65
</AppBarButton>
66
</CommandBar>
67
</Grid>
59
68
</Border>
60
69
</Grid>
61
70
</Page>
@@ -1,5 +1,4 @@
1
using Microsoft.UI.Text;
2
using Microsoft.UI.Xaml.Navigation;
1
using Microsoft.UI.Xaml.Navigation;
3
2
4
3
namespace XFENewsApplication.Views;
5
4
@@ -23,6 +22,18 @@ public sealed partial class NewsViewPage : Page
23
22
protected override void OnNavigatedTo(NavigationEventArgs e)
24
23
{
25
24
base.OnNavigatedTo(e);
25
if (ViewModel.NavigationViewService is not null)
26
{
27
ViewModel.NavigationViewService.ContentMargin = new(0);
28
ViewModel.NavigationViewService.Header = null;
29
}
26
30
ViewModel.NavigationParameterService.OnParameterChange(e.Parameter);
27
31
}
32
33
protected override void OnNavigatedFrom(NavigationEventArgs e)
34
{
35
base.OnNavigatedFrom(e);
36
if (ViewModel.NavigationViewService is not null)
37
ViewModel.NavigationViewService.ContentMargin = new(0, 48, 0, 0);
38
}
28
39
}
@@ -98,5 +98,6 @@
98
98
<PropertyGroup>
99
99
<ImplicitUsings>enable</ImplicitUsings>
100
100
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
101
<ApplicationIcon>Assets\icon.png</ApplicationIcon>
101
102
</PropertyGroup>
102
103
</Project>