1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-04-09 06:15:49 +02:00

Refactor error page

This commit is contained in:
chylex 2021-12-22 10:05:01 +01:00
parent fd634379d7
commit 13f8f12ac8
Signed by: chylex
GPG Key ID: 4DE42C8F19A80548
3 changed files with 19 additions and 24 deletions
Browser
Resources/Content/error
TweetDuck.csproj

View File

@ -23,7 +23,6 @@ namespace TweetDuck.Browser {
sealed class TweetDeckBrowser : IDisposable {
private static UserConfig Config => Program.Config.User;
private const string ErrorUrl = "http://td/error";
private const string NamespaceTweetDeck = "tweetdeck";
public bool Ready { get; private set; }
@ -167,10 +166,6 @@ private void browser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e) {
CefScriptExecutor.RunBootstrap(frame, "update");
}
if (url == ErrorUrl) {
resourceHandlers.Unregister(ErrorUrl);
}
}
private void browser_LoadError(object sender, LoadErrorEventArgs e) {
@ -178,16 +173,10 @@ private void browser_LoadError(object sender, LoadErrorEventArgs e) {
return;
}
if (!e.FailedUrl.StartsWith("http://td/", StringComparison.Ordinal)) {
string errorPage = Program.Resources.LoadSilent("pages/error.html");
if (errorPage != null) {
string errorName = Enum.GetName(typeof(CefErrorCode), e.ErrorCode);
string errorTitle = StringUtils.ConvertPascalCaseToScreamingSnakeCase(errorName ?? string.Empty);
resourceHandlers.Register(ErrorUrl, ResourceHandlers.ForString(errorPage.Replace("{err}", errorTitle)));
browser.Load(ErrorUrl);
}
if (!e.FailedUrl.StartsWith("td://", StringComparison.Ordinal)) {
string errorName = Enum.GetName(typeof(CefErrorCode), e.ErrorCode);
string errorTitle = StringUtils.ConvertPascalCaseToScreamingSnakeCase(errorName ?? string.Empty);
browser.Load("td://resources/error/error.html#" + Uri.EscapeDataString(errorTitle));
}
}

View File

@ -1,7 +1,9 @@
<!DOCTYPE html>
<html>
<html lang="en">
<head>
<style type="text/css">
<title>TweetDuck Error</title>
<meta charset="UTF-8">
<style>
body {
color: #e1e8ed;
background-color: #1c6399;
@ -16,9 +18,10 @@
display: table;
}
center {
main {
display: table-cell;
vertical-align: middle;
text-align: center;
}
h1 {
@ -39,11 +42,14 @@
</style>
</head>
<body>
<center>
<main>
<h1>Connection Error</h1>
<p>{err}</p>
<button onclick="location.href = 'https://tweetdeck.twitter.com'; [].forEach.call(document.getElementsByTagName('button'), e => e.style.visibility = 'hidden')">Retry</button>
<button onclick="window.close()">Exit</button>
</center>
<p id="error"></p>
<button onclick="location.href = 'https://tweetdeck.twitter.com'; Array.from(document.getElementsByTagName('button')).forEach(e => e.style.visibility = 'hidden');">Retry</button>
<button onclick="window.close();">Exit</button>
</main>
<script type="text/javascript">
document.getElementById("error").innerText = decodeURIComponent(location.hash.slice(1));
</script>
</body>
</html>

View File

@ -322,6 +322,7 @@
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
<None Include="Resources\Content\error\error.html" />
<None Include="Resources\Images\avatar.png" />
<None Include="Resources\Images\icon-muted.ico" />
<None Include="Resources\Images\icon-small.ico" />
@ -355,7 +356,6 @@
<None Include="Resources\PostCefUpdate.ps1" />
<None Include="Resources\Scripts\imports\scripts\plugins.base.js" />
<None Include="Resources\Scripts\notification.js" />
<None Include="Resources\Scripts\pages\error.html" />
<None Include="Resources\Scripts\pages\example.html" />
<None Include="Resources\Scripts\plugins.browser.js" />
<None Include="Resources\Scripts\plugins.notification.js" />