Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修改了个人主页搜索视频为空时的报错反馈 #457

Merged
merged 7 commits into from
Jan 1, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/BiliLite.UWP/BiliLite.UWP.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@
<Compile Include="Models\Common\Live\GuardBuyMsgModel.cs" />
<Compile Include="Models\Common\Live\RoomChangeMsgModel.cs" />
<Compile Include="Models\Common\WbiKey.cs" />
<Compile Include="Models\Exceptions\NotFoundException.cs" />
<Compile Include="Models\Exceptions\CustomizedErrorWithDataException.cs" />
<Compile Include="Models\Exceptions\PlayerException.cs" />
<Compile Include="Models\Requests\Api\BaseApi.cs" />
<Compile Include="Player\Controllers\BasePlayerController.cs" />
Expand Down Expand Up @@ -1284,4 +1286,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>
11 changes: 11 additions & 0 deletions src/BiliLite.UWP/Models/Exceptions/NotFoundException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System;

namespace BiliLite.Models.Exceptions
{
public class NotFoundException : Exception
{
public NotFoundException(string msg) : base(msg)
{
}
}
}
6 changes: 6 additions & 0 deletions src/BiliLite.UWP/Services/GrpcService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Bilibili.App.Dynamic.V2;
using Bilibili.App.Interface.V1;
using BiliLite.gRPC.Api;
using BiliLite.Models.Exceptions;

namespace BiliLite.Services
{
Expand All @@ -24,6 +25,11 @@ public async Task<SearchArchiveReply> SearchSpaceArchive(string mid, int page =
{
var reply = SearchArchiveReply.Parser.ParseFrom(result.results);
return reply;
}
// 用户搜索一个不存在的关键字导致的
else if (result.code == -102 && result.message == "请求失败,没有数据返回")
{
throw new NotFoundException(result.message);
}
else
{
Expand Down
25 changes: 14 additions & 11 deletions src/BiliLite.UWP/ViewModels/User/UserSubmitVideoViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,15 @@ public async Task GetSubmitVideo()
LoadingSubmitVideo = true;
if (string.IsNullOrEmpty(Keyword))
{
var api = m_userDetailApi.SubmitVideosCursor(Mid, order: (SubmitVideoOrder)SelectOrder, cursor: m_lastAid);
var api = m_userDetailApi.SubmitVideosCursor(Mid, order: (SubmitVideoOrder)SelectOrder,
cursor: m_lastAid);
CurrentTid = SelectTid.Tid;
var results = await api.Request();
if (!results.status)
{
throw new CustomizedErrorException(results.message);
}

var data = results.GetJObject();
if (data["code"].ToInt32() != 0)
{
Expand All @@ -164,18 +166,19 @@ public async Task GetSubmitVideo()
AttachSubmitVideoItems(submitVideoItems, (int)searchArchive.Total);
}
}
catch (CustomizedErrorException ex)
{
Notify.ShowMessageToast(ex.Message);
_logger.Error("获取用户投稿失败", ex);
}
catch (NotFoundException ex)
{
Notify.ShowMessageToast("(っ °Д °;)っ 没有找到相应的视频~");
}
catch (Exception ex)
{
if (ex is CustomizedErrorException)
{
Notify.ShowMessageToast(ex.Message);
}
else
{
var handel = HandelError<UserSubmitVideoViewModel>(ex);
Notify.ShowMessageToast(handel.message);
}

var handel = HandelError<UserSubmitVideoViewModel>(ex);
Notify.ShowMessageToast(handel.message);
_logger.Error("获取用户投稿失败", ex);
}
finally
Expand Down