Skip to content

Commit

Permalink
Merge pull request #237 from ywmoyue/dev
Browse files Browse the repository at this point in the history
4.6.10
  • Loading branch information
ywmoyue authored Jul 29, 2023
2 parents 0449e98 + 5790566 commit 407de91
Show file tree
Hide file tree
Showing 37 changed files with 151 additions and 95 deletions.
4 changes: 2 additions & 2 deletions src/BiliLite.UWP/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private void SynchronizationContext_UnhandledException(object sender, AysncUnhan
e.Handled = true;
try
{
logger.Log("程序运行出现错误", LogType.ERROR, e.Exception);
logger.Log("程序运行出现错误", LogType.Error, e.Exception);
Notify.ShowMessageToast("程序出现一个错误,已记录");
}
catch (Exception)
Expand All @@ -70,7 +70,7 @@ private void App_UnhandledException(object sender, Windows.UI.Xaml.UnhandledExce
e.Handled = true;
try
{
logger.Log("程序运行出现错误", LogType.ERROR, e.Exception);
logger.Log("程序运行出现错误", LogType.Error, e.Exception);
Notify.ShowMessageToast("程序出现一个错误,已记录");
}
catch (Exception)
Expand Down
2 changes: 1 addition & 1 deletion src/BiliLite.UWP/Controls/Player.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1135,7 +1135,7 @@ public void Pause()
}
catch (Exception ex)
{
_logger.Log("暂停出现错误", LogType.ERROR, ex);
_logger.Log("暂停出现错误", LogType.Error, ex);
}

}
Expand Down
4 changes: 2 additions & 2 deletions src/BiliLite.UWP/Dialogs/LoginDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,15 @@ private async void webView_NavigationStarting(WebView sender, WebViewNavigationS
}
catch (Exception ex)
{
logger.Log("注入JS对象失败", LogType.ERROR, ex);
logger.Log("注入JS对象失败", LogType.Error, ex);
}
}

private async void WebView_NavigationCompleted(WebView sender, WebViewNavigationCompletedEventArgs args)
{
if (args.Uri.AbsoluteUri == "https://passport.bilibili.com/ajax/miniLogin/redirect" || args.Uri.AbsoluteUri == "https://www.bilibili.com/")
{
var results = await "https://passport.bilibili.com/login/app/third?appkey=27eb53fc9058f8c3&api=http%3A%2F%2Flink.acg.tv%2Fforum.php&sign=67ec798004373253d60114caaad89a8c".GetString();
var results = await $"https://passport.bilibili.com/login/app/third?appkey=&api=http%3A%2F%2Flink.acg.tv%2Fforum.php&sign=67ec798004373253d60114caaad89a8c".GetString();
var obj = JObject.Parse(results);
if (obj["code"].ToInt32() == 0)
{
Expand Down
7 changes: 6 additions & 1 deletion src/BiliLite.UWP/Extensions/ApiModelExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using BiliLite.Models.Requests;
using BiliLite.Models.Responses;
using BiliLite.Services;

namespace BiliLite.Extensions
{
public static class ApiModelExtensions
{
private static readonly ILogger _logger = GlobalLogger.FromCurrentType();

/// <summary>
/// 发送请求,扩展方法
/// </summary>
/// <param name="api"></param>
/// <returns></returns>
public static async Task<HttpResults> Request(this ApiModel api)
public static async Task<HttpResults> Request(this ApiModel api, [CallerMemberName] string methodName = null)
{
_logger.Trace($"请求记录 {methodName} {api.baseUrl}");
if (api.method == RestSharp.Method.Get)
{
if (api.need_redirect)
Expand Down
2 changes: 1 addition & 1 deletion src/BiliLite.UWP/Extensions/BiliExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public static async Task CheckVersion()
try
{
var num = $"{SystemInformation.ApplicationVersion.Major}{SystemInformation.ApplicationVersion.Minor.ToString("00")}{SystemInformation.ApplicationVersion.Build.ToString("00")}";
_logger.Info($"BiliLite.UWP version: {num}");
_logger.Log($"BiliLite.UWP version: {num}", LogType.Necessary);
var result = await new GitApi().CheckUpdate().Request();
var ver = JsonConvert.DeserializeObject<NewVersionResponse>(result.results);
var ignoreVersion = SettingService.GetValue(SettingConstants.Other.IGNORE_VERSION, "");
Expand Down
12 changes: 6 additions & 6 deletions src/BiliLite.UWP/Extensions/StringHttpExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public static async Task<HttpResults> GetRedirectHttpResultsWithWebCookie(this s
}
catch (Exception ex)
{
logger.Log("GET请求失败" + url, LogType.ERROR, ex);
logger.Log("GET请求失败" + url, LogType.Error, ex);
return new HttpResults()
{
code = ex.HResult,
Expand Down Expand Up @@ -110,7 +110,7 @@ public static async Task<HttpResults> GetHttpResultsWithWebCookie(this string ur
}
catch (Exception ex)
{
logger.Log("GET请求失败" + url, LogType.ERROR, ex);
logger.Log("GET请求失败" + url, LogType.Error, ex);
return new HttpResults()
{
code = ex.HResult,
Expand All @@ -136,7 +136,7 @@ public static async Task<Stream> GetStream(this string url, IDictionary<string,
}
catch (Exception ex)
{
logger.Log("GET请求Stream失败" + url, LogType.ERROR, ex);
logger.Log("GET请求Stream失败" + url, LogType.Error, ex);
return null;
}
}
Expand All @@ -160,7 +160,7 @@ public static async Task<IBuffer> GetBuffer(this string url, IDictionary<string,
}
catch (Exception ex)
{
logger.Log("GET请求Buffer失败" + url, LogType.ERROR, ex);
logger.Log("GET请求Buffer失败" + url, LogType.Error, ex);
return null;
}
}
Expand All @@ -182,7 +182,7 @@ public static async Task<string> GetString(this string url, IDictionary<string,
}
catch (Exception ex)
{
logger.Log("GET请求String失败" + url, LogType.ERROR, ex);
logger.Log("GET请求String失败" + url, LogType.Error, ex);
return null;
}
}
Expand Down Expand Up @@ -227,7 +227,7 @@ public static async Task<HttpResults> PostHttpResultsWithCookie(this string url,
}
catch (Exception ex)
{
logger.Log("GET请求失败" + url, LogType.ERROR, ex);
logger.Log("GET请求失败" + url, LogType.Error, ex);
return new HttpResults()
{
code = ex.HResult,
Expand Down
11 changes: 7 additions & 4 deletions src/BiliLite.UWP/Models/Common/Enumerates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
{
public enum LogType
{
INFO,
DEBUG,
ERROR,
FATAL
Trace,
Debug,
Info,
Warn,
Error,
Fatal,
Necessary,
}

public enum LoginStatus
Expand Down
5 changes: 5 additions & 0 deletions src/BiliLite.UWP/Models/Common/SettingConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,11 @@ public class Other
/// </summary>
public const string PROTECT_LOG_INFO = "protectLogInfo";

/// <summary>
/// 日志级别
/// </summary>
public const string LOG_LEVEL = "LogLevel";

/// <summary>
/// 忽略版本
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions src/BiliLite.UWP/Models/Requests/Api/AccountApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ public ApiModel SMSLogin(string cid, string phone, string code, string session_i
{
method = RestSharp.Method.Post,
baseUrl = "https://passport.bilibili.com/x/passport-login/login/sms",
body = $"actionKey=appkey&cid={cid}&tel={phone}&login_session_id={session_id}&captcha_key={captcha_key}&code={code}&" + ApiHelper.MustParameter(ApiHelper.LoginKey)
body = $"actionKey=appkey&cid={cid}&tel={phone}&login_session_id={session_id}&captcha_key={captcha_key}&code={code}&" + ApiHelper.MustParameter(ApiHelper.AndroidKey)
};
api.body += ApiHelper.GetSign(api.body, ApiHelper.LoginKey);
api.body += ApiHelper.GetSign(api.body, ApiHelper.AndroidKey);
return api;
}
/// <summary>
Expand Down
1 change: 1 addition & 0 deletions src/BiliLite.UWP/Models/Requests/Api/User/UserDetailAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ public ApiModel Followers(string mid, int page = 1, int pagesize = 30)
method = RestSharp.Method.Get,
baseUrl = $"{ApiHelper.API_BASE_URL}/x/relation/followers",
parameter = $"vmid={mid}&ps={pagesize}&pn={page}&order=desc",
need_cookie = true,
};
return api;
}
Expand Down
4 changes: 2 additions & 2 deletions src/BiliLite.UWP/Models/Requests/BiliRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ private async Task LogRequest()
var body = "";
if (m_body != null)
body = await m_body?.ReadAsStringAsync();
logger.Log($"网络请求: [{m_method}]{m_url} {body}", LogType.INFO);
logger.Log($"网络请求: [{m_method}]{m_url} {body}", LogType.Info);
}

public async Task<HttpResults> Send()
Expand Down Expand Up @@ -185,7 +185,7 @@ public async Task<HttpResults> Send()
}
catch (Exception ex)
{
logger.Log($"{m_method.Method}请求失败" + m_url, LogType.ERROR, ex);
logger.Log($"{m_method.Method}请求失败" + m_url, LogType.Error, ex);
httpResults = await ConstructExResults(ex);
}

Expand Down
20 changes: 10 additions & 10 deletions src/BiliLite.UWP/Modules/Detail/LiveRoomVM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ public async Task GetTitles()
}
catch (Exception ex)
{
_logger.Log("读取直播头衔失败", LogType.FATAL, ex);
_logger.Log("读取直播头衔失败", LogType.Fatal, ex);
}
}
/// <summary>
Expand Down Expand Up @@ -866,7 +866,7 @@ public async Task GetRoomGiftList()
catch (Exception ex)
{
Notify.ShowMessageToast("读取礼物信息失败");
_logger.Log("读取礼物信息失败", LogType.ERROR, ex);
_logger.Log("读取礼物信息失败", LogType.Error, ex);
}
}

Expand Down Expand Up @@ -933,7 +933,7 @@ public async Task GetGuardList()
catch (Exception ex)
{
Notify.ShowMessageToast("读取舰队失败");
_logger.Log("读取舰队失败", LogType.ERROR, ex);
_logger.Log("读取舰队失败", LogType.Error, ex);
}
finally
{
Expand Down Expand Up @@ -1003,7 +1003,7 @@ public async Task GetFreeSilverTime()
catch (Exception ex)
{
Notify.ShowMessageToast("读取直播免费瓜子时间失败");
_logger.Log("读取直播免费瓜子时间失败", LogType.ERROR, ex);
_logger.Log("读取直播免费瓜子时间失败", LogType.Error, ex);
}
}

Expand Down Expand Up @@ -1034,7 +1034,7 @@ public async Task GetFreeSilver()
catch (Exception ex)
{
Notify.ShowMessageToast("读取直播免费瓜子时间失败");
_logger.Log("读取直播免费瓜子时间失败", LogType.ERROR, ex);
_logger.Log("读取直播免费瓜子时间失败", LogType.Error, ex);
}
}

Expand Down Expand Up @@ -1088,7 +1088,7 @@ public async Task SendGift(LiveGiftItem liveGiftItem)
}
catch (Exception ex)
{
_logger.Log("赠送礼物出现错误", LogType.ERROR, ex);
_logger.Log("赠送礼物出现错误", LogType.Error, ex);
Notify.ShowMessageToast("赠送礼物出现错误");
}

Expand Down Expand Up @@ -1122,7 +1122,7 @@ public async Task SendBagGift(LiveGiftItem liveGiftItem)
}
catch (Exception ex)
{
_logger.Log("赠送礼物出现错误", LogType.ERROR, ex);
_logger.Log("赠送礼物出现错误", LogType.Error, ex);
Notify.ShowMessageToast("赠送礼物出现错误");
}

Expand Down Expand Up @@ -1177,7 +1177,7 @@ public async Task<bool> SendDanmu(string text)
}
catch (Exception ex)
{
_logger.Log("发送弹幕出现错误", LogType.ERROR, ex);
_logger.Log("发送弹幕出现错误", LogType.Error, ex);
Notify.ShowMessageToast("发送弹幕出现错误");
return false;
}
Expand Down Expand Up @@ -1323,7 +1323,7 @@ public async Task LoadData()
catch (Exception ex)
{
Notify.ShowMessageToast("读取直播排行榜失败:" + RankType);
logger.Log("读取直播排行榜失败" + RankType, LogType.ERROR, ex);
logger.Log("读取直播排行榜失败" + RankType, LogType.Error, ex);
}
finally
{
Expand Down Expand Up @@ -1431,7 +1431,7 @@ public async Task LoadLotteryInfo(int roomId)
}
catch (Exception ex)
{
logger.Log("加载主播抽奖信息失败", LogType.ERROR, ex);
logger.Log("加载主播抽奖信息失败", LogType.Error, ex);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/BiliLite.UWP/Modules/IModules.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public virtual ReturnModel<T> HandelError<T>(Exception ex, [CallerMemberName] st
else
{
var type = new StackTrace().GetFrame(1).GetMethod().ReflectedType;
_logger.Log(ex.Message, LogType.ERROR, ex, methodName, type.Name);
_logger.Log(ex.Message, LogType.Error, ex, methodName, type.Name);
return new ReturnModel<T>()
{
success = false,
Expand Down
2 changes: 1 addition & 1 deletion src/BiliLite.UWP/Modules/Live/LiveCenter/LiveCenterVM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public async void GetUserInfo()
}
catch (Exception ex)
{
logger.Log("读取签到信息失败", LogType.ERROR, ex);
logger.Log("读取签到信息失败", LogType.Error, ex);
Notify.ShowMessageToast("读取签到信息失败");
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/BiliLite.UWP/Modules/Live/LiveDanmaku.cs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ private async void Listen()
}
catch (Exception ex)
{
logger.Log("加载直播弹幕失败", LogType.ERROR, ex);
logger.Log("加载直播弹幕失败", LogType.Error, ex);
}

await Task.Delay(delay);
Expand Down
2 changes: 1 addition & 1 deletion src/BiliLite.UWP/Modules/Live/LiveMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public async Task Connect(int roomID, int uid, CancellationToken cancellationTok
{
return;
}
logger.Log("直播接收包出错", LogType.ERROR, ex);
logger.Log("直播接收包出错", LogType.Error, ex);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/BiliLite.UWP/Modules/Live/LiveRecommendVM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public async Task<List<LiveRecommendItemModel>> GetRecommend(int page)
}
catch (Exception ex)
{
logger.Log("加载直播推荐信息失败", LogType.ERROR, ex);
logger.Log("加载直播推荐信息失败", LogType.Error, ex);
Notify.ShowMessageToast("加载直播推荐信息失败");
return new List<LiveRecommendItemModel>();
}
Expand Down
2 changes: 1 addition & 1 deletion src/BiliLite.UWP/Modules/Player/PlayerVM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public async Task<SubtitleModel> GetSubtitle(string url)
catch (Exception ex)
{
Notify.ShowMessageToast("弹幕加载失败:" + ex.Message);
logger.Log("grpc弹幕加载失败", LogType.FATAL, ex);
logger.Log("grpc弹幕加载失败", LogType.Fatal, ex);
}
return danmuList;
}
Expand Down
4 changes: 2 additions & 2 deletions src/BiliLite.UWP/Modules/SettingVM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public async Task SyncDanmuFilter()
}
catch (Exception ex)
{
logger.Log("读取弹幕屏蔽词失败", LogType.ERROR, ex);
logger.Log("读取弹幕屏蔽词失败", LogType.Error, ex);
}
}

Expand All @@ -173,7 +173,7 @@ public async Task<bool> AddDanmuFilterItem(string word, int type)
}
catch (Exception ex)
{
logger.Log("添加弹幕屏蔽词失败", LogType.ERROR, ex);
logger.Log("添加弹幕屏蔽词失败", LogType.Error, ex);
return false;
}
}
Expand Down
Loading

0 comments on commit 407de91

Please sign in to comment.