/// <summary> /// 页面加载 /// </summary> /// <param name="e"></param> protected async override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); Object[] parameters = e.Parameter as Object[]; if (parameters != null && parameters.Length == 1) { _news = parameters[0] as CNNews; BlogTitle.Text = _news.Title; NewsSource.Text = _news.SourceName; PublishTime.Text = _news.PublishTime; Diggs.Text = "[" + _news.Diggs + "]"; Views.Text = _news.Views; Comments.Text = _news.Comments; string news_content = await NewsService.GetNewsContentAsync(_news.ID); if (news_content != null) { if (App.Theme == ApplicationTheme.Dark) //暗主题 { news_content += "<style>body{background-color:black;color:white;}</style>"; } NewsContent.NavigateToString(news_content); } Loading.IsActive = false; } }
/// <summary> /// 页面加载 /// </summary> /// <param name="e"></param> protected async override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); Object[] parameters = e.Parameter as Object[]; if (parameters != null && parameters.Length == 1) { _news = parameters[0] as CnNews; BlogTitle.Text = _news.Title; NewsSource.Text = _news.SourceName; PublishTime.Text = _news.PublishTime; Diggs.Text = "[" + _news.Diggs + "]"; Views.Text = _news.Views; Comments.Text = _news.Comments; string newsContent = await NewsService.GetNewsContentAsync(_news.Id); if (newsContent != null) { //string pattern = "<img src=\"(.*)\""; //news_content = Regex.Replace(news_content, pattern, m => $"<img src=\"{_image_bridge}{m.Groups[1].Value}\""); HideScrollbar(ref newsContent); NewsContent.NavigateToString(newsContent); } // 获取评论数据 _commentsTotalHtml = CommentTool.BaseChatHtml; HideScrollbar(ref _commentsTotalHtml); NewsComment.NavigateToString(_commentsTotalHtml); List <CnNewsComment> refreshComments = await NewsService.GetNewsCommentsAysnc(_news.Id, 1, 200); if (refreshComments != null) { string comments = ""; foreach (CnNewsComment comment in refreshComments) { comments += CommentTool.Receive(comment.AuthorAvatar, comment.AuthorName, comment.Content, comment.PublishTime, comment.Id); } comments += "<a id='ok'></a>"; _commentsTotalHtml = _commentsTotalHtml.Replace("<a id='ok'></a>", "") + comments + "<a id='ok'></a>"; HideScrollbar(ref _commentsTotalHtml); NewsComment.NavigateToString(_commentsTotalHtml); Loading.IsActive = false; } Loading.IsActive = false; } }
/// <summary> /// 点击标题栏刷新 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void RefreshButton_Click(object sender, RoutedEventArgs e) { Loading.IsActive = true; string news_content = await NewsService.GetNewsContentAsync(_news.ID); if (news_content != null) { if (App.Theme == ApplicationTheme.Dark) //暗主题 { news_content += "<style>body{background-color:black;color:white;}</style>"; } NewsContent.NavigateToString(news_content); Loading.IsActive = false; } }