Skip to content

Commit

Permalink
搜索页样式调整 (#909)
Browse files Browse the repository at this point in the history
* 搜索页样式调整 
* 整理搜索页代码
* 添加搜索页缓存
* 搜索页搜索框响应式处理

---------

Co-authored-by: ProJend <[email protected]>
  • Loading branch information
ywmoyue and ProJend authored Nov 11, 2024
1 parent 669c080 commit 3d39917
Show file tree
Hide file tree
Showing 32 changed files with 2,002 additions and 1,414 deletions.
23 changes: 21 additions & 2 deletions src/BiliLite.UWP/BiliLite.UWP.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -262,16 +262,35 @@
<Compile Include="Models\Functions\ToggleFullWindowShortcutFunction.cs" />
<Compile Include="Models\Functions\ToggleMiniWindowShortcutFunction.cs" />
<Compile Include="Models\Functions\ToggleSubtitleShortcutFunction.cs" />
<Compile Include="Models\Common\Search\SearchAnimeItem.cs" />
<Compile Include="Models\Common\Search\SearchArea.cs" />
<Compile Include="Models\Common\Search\SearchArticleItem.cs" />
<Compile Include="Models\Common\Search\SearchLiveRoomItem.cs" />
<Compile Include="Models\Common\Search\SearchTopicItem.cs" />
<Compile Include="Models\Common\Search\SearchUserItem.cs" />
<Compile Include="Models\Common\Search\SearchUserOfficialVerifyItem.cs" />
<Compile Include="Models\Common\Search\SearchVideoItem.cs" />
<Compile Include="Pages\IScrollRecorablePage.cs" />
<Compile Include="Pages\Other\MarkdownViewerPage.xaml.cs">
<DependentUpon>MarkdownViewerPage.xaml</DependentUpon>
</Compile>
<Compile Include="Models\Common\Search\SearchParameter.cs" />
<Compile Include="Controls\DataTemplateSelectors\SearchDataTemplateSelector.cs" />
<Compile Include="Services\BiliLiteDbContext.cs" />
<Compile Include="Services\DownloadService.cs" />
<Compile Include="Services\PluginService.cs" />
<Compile Include="Services\SqlMigrateService.cs" />
<Compile Include="ViewModels\Common\MainPageViewModel.cs" />
<Compile Include="ViewModels\Common\PieControlViewModel.cs" />
<Compile Include="ViewModels\Search\BaseSearchPivotViewModel.cs" />
<Compile Include="ViewModels\Search\ISearchPivotViewModel.cs" />
<Compile Include="ViewModels\Search\SearchAnimeViewModel.cs" />
<Compile Include="ViewModels\Search\SearchArticleViewModel.cs" />
<Compile Include="ViewModels\Search\SearchLiveRoomViewModel.cs" />
<Compile Include="ViewModels\Search\SearchPageViewModel.cs" />
<Compile Include="ViewModels\Search\SearchTopicViewModel.cs" />
<Compile Include="ViewModels\Search\SearchUserViewModel.cs" />
<Compile Include="ViewModels\Search\SearchVideoViewModel.cs" />
<Compile Include="ViewModels\Plugins\WebSocketPluginViewModel.cs" />
<Compile Include="ViewModels\Settings\CDNServerItemViewModel.cs" />
<Compile Include="Pages\ISavablePage.cs" />
Expand Down Expand Up @@ -785,7 +804,7 @@
<Compile Include="Modules\Player\Playurl\BiliPlayUrl.cs" />
<Compile Include="Models\Common\Video\PlayUrlInfos\BiliFlvPlayUrlInfo.cs" />
<Compile Include="Modules\RegionDetailVM.cs" />
<Compile Include="Modules\SearchVM.cs" />
<Compile Include="Models\Common\Search\SearchFilterItem.cs" />
<Compile Include="Modules\Season\SeasonRankVM.cs" />
<Compile Include="Modules\Season\SeasonReviewVM.cs" />
<Compile Include="Modules\User\Account.cs" />
Expand Down Expand Up @@ -940,7 +959,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Models\Requests\ApiModel.cs" />
<Compile Include="Models\Common\ApiKeyInfo.cs" />
<Compile Include="Services\SearchService.cs" />
<Compile Include="Services\Biz\SearchService.cs" />
<Compile Include="ViewModels\Common\BaseViewModel.cs" />
<Compile Include="ViewModels\Download\DownloadDialogViewModel.cs" />
<Compile Include="Models\Common\Video\VideoListItem.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using BiliLite.Models.Common;
using BiliLite.ViewModels.Search;

namespace BiliLite.Controls.DataTemplateSelectors
{
public class SearchDataTemplateSelector : DataTemplateSelector
{
public DataTemplate VideoTemplate { get; set; }
public DataTemplate AnimeTemplate { get; set; }
public DataTemplate TestTemplate { get; set; }
public DataTemplate LiveRoomTemplate { get; set; }
public DataTemplate UserTemplate { get; set; }
public DataTemplate ArticTemplate { get; set; }
public DataTemplate TopicTemplate { get; set; }
protected override DataTemplate SelectTemplateCore(object item, DependencyObject container)
{
var data = item as ISearchPivotViewModel;
switch (data.SearchType)
{
case SearchType.Video:
return VideoTemplate;
case SearchType.Anime:
case SearchType.Movie:
return AnimeTemplate;
case SearchType.User:
return UserTemplate;
case SearchType.Live:
return LiveRoomTemplate;
case SearchType.Article:
return ArticTemplate;
case SearchType.Topic:
return TopicTemplate;
case SearchType.Anchor:
return TestTemplate;
default:
return TestTemplate;
}


}
}
}
2 changes: 1 addition & 1 deletion src/BiliLite.UWP/Extensions/StringHttpExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public static async Task<HttpResults> GetHttpResultsWithWebCookie(this string ur
{
foreach (var kvp in extraCookies.ToList())
{
cookies.Add(kvp.Key, kvp.Value);
cookies[kvp.Key] = kvp.Value;
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/BiliLite.UWP/Extensions/ViewModelExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using BiliLite.ViewModels.Home;
using BiliLite.ViewModels.Live;
using BiliLite.ViewModels.Rank;
using BiliLite.ViewModels.Search;
using BiliLite.ViewModels.Settings;
using BiliLite.ViewModels.User;
using BiliLite.ViewModels.User.SendDynamic;
Expand Down Expand Up @@ -53,6 +54,7 @@ public static IServiceCollection AddViewModels(this IServiceCollection services)
services.AddTransient<ShortcutKeySettingsControlViewModel>();
services.AddTransient<DevSettingsControlViewModel>();
services.AddTransient<MainPageViewModel>();
services.AddTransient<SearchPageViewModel>();
return services;
}
}
Expand Down
36 changes: 36 additions & 0 deletions src/BiliLite.UWP/Models/Common/Enumerates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -525,4 +525,40 @@ public enum FilterContentType
User,
Desc,
}

public enum SearchType
{
/// <summary>
/// 视频
/// </summary>
Video = 0,
/// <summary>
/// 番剧
/// </summary>
Anime = 1,
/// <summary>
/// 直播
/// </summary>
Live = 2,
/// <summary>
/// 主播
/// </summary>
Anchor = 3,
/// <summary>
/// 用户
/// </summary>
User = 4,
/// <summary>
/// 影视
/// </summary>
Movie = 5,
/// <summary>
/// 专栏
/// </summary>
Article = 6,
/// <summary>
/// 话题
/// </summary>
Topic = 7
}
}
42 changes: 42 additions & 0 deletions src/BiliLite.UWP/Models/Common/Search/SearchAnimeItem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
namespace BiliLite.Models.Common.Search
{
public class SearchAnimeItem
{
public string type { get; set; }
public string season_id { get; set; }
public string media_id { get; set; }
private string _title;

public string title
{
get { return _title; }
set
{

_title = System.Web.HttpUtility.HtmlDecode(value.Replace("<em class=\"keyword\">", "").Replace("</em>", ""));
}
}
public string areas { get; set; }
public string cv { get; set; }
public string styles { get; set; }
public string desc { get; set; }
public long pubtime { get; set; }
public string season_type_name { get; set; }

private string _pic;
public string cover
{
get { return _pic; }
set { _pic = value; }
}

public string angle_title { get; set; }
public bool showBadge
{
get
{
return !string.IsNullOrEmpty(angle_title);
}
}
}
}
13 changes: 13 additions & 0 deletions src/BiliLite.UWP/Models/Common/Search/SearchArea.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace BiliLite.Models.Common.Search
{
public class SearchArea
{
public SearchArea(string name, string area)
{
this.name = name;
this.area = area;
}
public string name { get; set; }
public string area { get; set; }
}
}
40 changes: 40 additions & 0 deletions src/BiliLite.UWP/Models/Common/Search/SearchArticleItem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using System.Collections.Generic;

namespace BiliLite.Models.Common.Search
{
public class SearchArticleItem
{

public string mid { get; set; }

private string _title;

public string title
{
get { return _title; }
set
{
_title = System.Web.HttpUtility.HtmlDecode(value.Replace("<em class=\"keyword\">", "").Replace("</em>", ""));
}
}
public string category_name { get; set; }
public string type { get; set; }
public string desc { get; set; }
public long like { get; set; }
public long view { get; set; }
public long reply { get; set; }
public string id { get; set; }
public List<string> image_urls { get; set; }
public string cover
{
get
{
if (image_urls != null && image_urls.Count != 0)
{
return "https:" + image_urls[0];
}
return null;
}
}
}
}
13 changes: 13 additions & 0 deletions src/BiliLite.UWP/Models/Common/Search/SearchFilterItem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace BiliLite.Models.Common.Search
{
public class SearchFilterItem
{
public SearchFilterItem(string name, string value)
{
this.name = name;
this.value = value;
}
public string name { get; set; }
public string value { get; set; }
}
}
45 changes: 45 additions & 0 deletions src/BiliLite.UWP/Models/Common/Search/SearchLiveRoomItem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
namespace BiliLite.Models.Common.Search
{
public class SearchLiveRoomItem
{

public string roomid { get; set; }

private string _title;

public string title
{
get { return _title; }
set
{

_title = System.Web.HttpUtility.HtmlDecode(value.Replace("<em class=\"keyword\">", "").Replace("</em>", ""));
}
}
public string uname { get; set; }
public string tags { get; set; }
public string cate_name { get; set; }
public int online { get; set; }


private string _user_cover;
public string user_cover
{
get { return _user_cover; }
set { _user_cover = "https:" + value; }
}
private string _uface;
public string uface
{
get { return _uface; }
set { _uface = "https:" + value; }
}
private string _cover;
public string cover
{
get { return _cover; }
set { _cover = "https:" + value; }
}

}
}
9 changes: 9 additions & 0 deletions src/BiliLite.UWP/Models/Common/Search/SearchParameter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace BiliLite.Models.Common.Search
{
public class SearchParameter
{
public string Keyword { get; set; }

public SearchType SearchType { get; set; } = SearchType.Video;
}
}
42 changes: 42 additions & 0 deletions src/BiliLite.UWP/Models/Common/Search/SearchTopicItem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
namespace BiliLite.Models.Common.Search
{
public class SearchTopicItem
{
public string arcurl { get; set; }

private string _title;

public string title
{
get { return _title; }
set
{
_title = System.Web.HttpUtility.HtmlDecode(value.Replace("<em class=\"keyword\">", "").Replace("</em>", ""));
}
}

private string _description;

public string description
{
get { return _description; }
set
{
_description = value.Replace("<em class=\"keyword\">", "").Replace("</em>", "");
}
}


public long pubdate { get; set; }


private string _pic;
public string cover
{
get { return _pic; }
set { _pic = "https:" + value; }
}


}
}
Loading

0 comments on commit 3d39917

Please sign in to comment.