Skip to content

Commit

Permalink
Merge pull request #314 from XuanchenLin/master
Browse files Browse the repository at this point in the history
为 LoadEnd 事件添加了两个参数 SkipErrorHandler 和 ErrorPageUrl
  • Loading branch information
XuanchenLin authored Dec 29, 2022
2 parents 9f984a6 + cfe9e6b commit c60cf96
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 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
18 changes: 9 additions & 9 deletions src/NetDimension.NanUI/NetDimension.NanUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,15 @@
<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="SkiaSharp" Version="2.88.0" />
<PackageReference Include="Vanara.PInvoke.DwmApi" Version="3.4.3" />
<PackageReference Include="Vanara.PInvoke.SHCore" Version="3.4.3" />
<PackageReference Include="Vanara.PInvoke.User32" Version="3.4.3" />
<PackageReference Include="Vanara.PInvoke.UxTheme" Version="3.4.3" />
<PackageReference Include="Vortice.Direct2D1" Version="2.1.19" />
<PackageReference Include="Vortice.Direct3D11" Version="2.1.19" />
<PackageReference Include="Vortice.DXGI" Version="2.1.19" />
<PackageReference Include="Vortice.Mathematics" Version="1.4.16" />
<PackageReference Include="SkiaSharp" Version="2.88.3" />
<PackageReference Include="Vanara.PInvoke.DwmApi" Version="3.4.10" />
<PackageReference Include="Vanara.PInvoke.SHCore" Version="3.4.10" />
<PackageReference Include="Vanara.PInvoke.User32" Version="3.4.10" />
<PackageReference Include="Vanara.PInvoke.UxTheme" Version="3.4.10" />
<PackageReference Include="Vortice.Direct2D1" Version="2.1.41" />
<PackageReference Include="Vortice.Direct3D11" Version="2.1.41" />
<PackageReference Include="Vortice.DXGI" Version="2.1.41" />
<PackageReference Include="Vortice.Mathematics" Version="1.4.19" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit c60cf96

Please sign in to comment.