Skip to content

Commit

Permalink
🎉 为 LoadEnd 事件添加了两个参数 SkipErrorHandler 和 ErrorPageUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
XuanchenLin committed Dec 29, 2022
1 parent f3cf0e7 commit cfe9e6b
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,16 @@ protected override void OnLoadEnd(CefBrowser browser, CefFrame frame, int httpSt

if (frame.IsMain)
{
if (httpStatusCode >= 400 || httpStatusCode ==0)
if (e.SkipErrorHandler == false && ((httpStatusCode >= 400 && httpStatusCode < 500) || httpStatusCode ==0))
{
frame.LoadUrl("res://formium/InternalError/index.html");
if(string.IsNullOrEmpty(e.ErrorPageUrl))
{
frame.LoadUrl("res://formium/InternalError/index.html");
}
else
{
frame.LoadUrl(e.ErrorPageUrl);
}
}
else
{
Expand All @@ -39,8 +46,6 @@ protected override void OnLoadEnd(CefBrowser browser, CefFrame frame, int httpSt

protected override void OnLoadError(CefBrowser browser, CefFrame frame, CefErrorCode errorCode, string errorText, string failedUrl)
{


var e = new LoadErrorEventArgs(frame, errorCode, errorText, failedUrl);
_owner.InvokeIfRequired(() => _owner.OnLoadError(e));
}
Expand Down Expand Up @@ -74,7 +79,8 @@ internal LoadEndEventArgs(CefFrame frame, int httpStatusCode)
Frame = frame;
HttpStatusCode = httpStatusCode;
}

public string? ErrorPageUrl { get; set; }
public bool SkipErrorHandler { get; set; } = false;
public CefFrame Frame { get; }
public int HttpStatusCode { get; }
}
Expand Down

0 comments on commit cfe9e6b

Please sign in to comment.