diff --git a/Aria2Fast/Service/Model/MikanModel.cs b/Aria2Fast/Service/Model/MikanModel.cs index 15757aa..5317be7 100644 --- a/Aria2Fast/Service/Model/MikanModel.cs +++ b/Aria2Fast/Service/Model/MikanModel.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.IO; using System.Linq; using System.Runtime.Caching; @@ -150,6 +151,22 @@ public class MikanAnimeRss : BaseNotificationModel public List Items { get; set; } + public string ShowEpisode + { + get + { + var text = ""; + var episode = Episode; + if (!string.IsNullOrEmpty(episode)) + { + text += $"最新集数 {episode}"; + } + + return text; + // text += $" 总{Items.Count}"; + } + } + //TODO 当前集数 public string Episode { @@ -167,7 +184,7 @@ public string Episode public static string ExtractEpisodeNumber(string title) { // 正则表达式找出集数, 例如: [01], - 02, 第03集 - Regex episodeRegex = new Regex(@"\[\d{2}\]|-\s*\d{2}|\d{2}", RegexOptions.Compiled); + Regex episodeRegex = new Regex(@"\[\d{1,3}\]|-\s*\d{1,3}", RegexOptions.Compiled); Match match = episodeRegex.Match(title); if (match.Success) @@ -187,12 +204,57 @@ public string UpdateTime var item = Items.FirstOrDefault(); if (item != null) { - return item.Updated; + + string result = FormatTimeAgo(item.Updated, +8); + + return result; } return string.Empty; } } + + + + public static string FormatTimeAgo(string timeText, int timeZoneOffset) + { + try + { + // 解析时间字符串 + DateTime inputTime = DateTime.ParseExact(timeText, "yyyy/MM/dd HH:mm", CultureInfo.InvariantCulture); + + // 考虑时区转换到UTC + inputTime = inputTime.AddHours(-timeZoneOffset); + + // 获取当前的UTC时间 + DateTime utcNow = DateTime.UtcNow; + + // 计算差值 + TimeSpan difference = utcNow - inputTime; + + if (difference.TotalDays >= 1) + { + return timeText; + } + else if (difference.TotalHours >= 1) + { + return $"{Math.Floor(difference.TotalHours)}小时前"; + } + else if (difference.TotalMinutes >= 1) + { + return $"{Math.Floor(difference.TotalMinutes)}分钟前"; + } + else + { + return "刚刚"; + } + } + catch (FormatException) + { + return ""; + } + } + public bool IsSubscribed { get diff --git a/Aria2Fast/View/AddSubscriptionView.xaml.cs b/Aria2Fast/View/AddSubscriptionView.xaml.cs index f47f5d4..98a7191 100644 --- a/Aria2Fast/View/AddSubscriptionView.xaml.cs +++ b/Aria2Fast/View/AddSubscriptionView.xaml.cs @@ -1,5 +1,6 @@ using Aria2Fast.Dialogs; using Aria2Fast.Service; +using Aria2Fast.Service.Model; using Aria2Fast.Service.Model.SubscriptionModel; using Aria2Fast.Utils; using System; @@ -175,6 +176,8 @@ await Task.Run(() => { }); //TODO this.Close(); + + //MainWindow.Instance.RootNavigation.Navigate(typeof(AddSubscriptionView), (mikanAnimeRss.Url, mikanAnime.Name)); MainWindow.Instance.RootNavigation.GoBack(); } catch (Exception ex) diff --git a/Aria2Fast/View/AnimeListView.xaml b/Aria2Fast/View/AnimeListView.xaml index 4006b3c..204ba64 100644 --- a/Aria2Fast/View/AnimeListView.xaml +++ b/Aria2Fast/View/AnimeListView.xaml @@ -50,12 +50,13 @@ - + ItemsSource="{Binding Master.AnimeDays}" /> + + + diff --git a/Aria2Fast/View/AnimeListView.xaml.cs b/Aria2Fast/View/AnimeListView.xaml.cs index 9336147..ad07c61 100644 --- a/Aria2Fast/View/AnimeListView.xaml.cs +++ b/Aria2Fast/View/AnimeListView.xaml.cs @@ -60,9 +60,12 @@ private async void MikanAnimeDayControl_RssBorderClicked(object sender, RssBorde //await Task.Delay(50); //TestN.IsOpen = true; MainWindow.Instance.RootNavigation.Navigate(typeof(MikanAnimeRssView), animeItem); - + + //在使用NavigationView的Navigate方法时,如果传递的View的高度大于NavigationView的区域时, + + } - + } private async void GetListButton_Click(object sender, RoutedEventArgs e) diff --git a/Aria2Fast/View/MikanAnimeDayControl.xaml b/Aria2Fast/View/MikanAnimeDayControl.xaml index 5a15113..e5c8ab9 100644 --- a/Aria2Fast/View/MikanAnimeDayControl.xaml +++ b/Aria2Fast/View/MikanAnimeDayControl.xaml @@ -23,11 +23,13 @@ diff --git a/Aria2Fast/View/MikanAnimeRssView.xaml b/Aria2Fast/View/MikanAnimeRssView.xaml index 4f99d81..25bddd7 100644 --- a/Aria2Fast/View/MikanAnimeRssView.xaml +++ b/Aria2Fast/View/MikanAnimeRssView.xaml @@ -11,36 +11,21 @@ d:DesignWidth="800" mc:Ignorable="d"> - - - - - - - - - - - - - + + Stretch="UniformToFill"> - + + + + + + + + + + + + + + + + + diff --git a/Aria2Fast/View/MikanAnimeRssView.xaml.cs b/Aria2Fast/View/MikanAnimeRssView.xaml.cs index e197038..5482552 100644 --- a/Aria2Fast/View/MikanAnimeRssView.xaml.cs +++ b/Aria2Fast/View/MikanAnimeRssView.xaml.cs @@ -1,4 +1,5 @@ -using System; +using Aria2Fast.Service.Model; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -24,5 +25,20 @@ public MikanAnimeRssView() { InitializeComponent(); } + + private void Border_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) + { + var b = sender as Border; + + MikanAnime mikanAnime = ((MikanAnime)DataContext); + + MikanAnimeRss mikanAnimeRss = (MikanAnimeRss)b.DataContext; + + + + + //弹出订阅页面? + MainWindow.Instance.RootNavigation.Navigate(typeof(AddSubscriptionView), (mikanAnimeRss.Url, mikanAnime.Name)); + } } }