mirror of
https://github.com/SpaceTimee/Sheas-Cealer.git
synced 2025-07-13 21:02:08 +08:00
1.1.3 -> 1.1.4 第58次更新
This commit is contained in:
parent
2660c63311
commit
54f9326f29
@ -410,41 +410,45 @@ public partial class MainWin : Window
|
|||||||
}
|
}
|
||||||
private async void UpdateUpstreamHostButton_Click(object sender, RoutedEventArgs e)
|
private async void UpdateUpstreamHostButton_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (!File.Exists(MainConst.UpstreamHostPath))
|
try
|
||||||
File.Create(MainConst.UpstreamHostPath).Dispose();
|
{
|
||||||
|
if (!File.Exists(MainConst.UpstreamHostPath))
|
||||||
|
File.Create(MainConst.UpstreamHostPath).Dispose();
|
||||||
|
|
||||||
string upstreamUpstreamHostUrl = (MainPres.UpstreamUrl.StartsWith("http://") || MainPres.UpstreamUrl.StartsWith("https://") ? string.Empty : "https://") + MainPres.UpstreamUrl;
|
string upstreamUpstreamHostUrl = (MainPres.UpstreamUrl.StartsWith("http://") || MainPres.UpstreamUrl.StartsWith("https://") ? string.Empty : "https://") + MainPres.UpstreamUrl;
|
||||||
string upstreamUpstreamHostString = await Http.GetAsync<string>(upstreamUpstreamHostUrl, MainClient);
|
string upstreamUpstreamHostString = await Http.GetAsync<string>(upstreamUpstreamHostUrl, MainClient);
|
||||||
string localUpstreamHostString = File.ReadAllText(MainConst.UpstreamHostPath);
|
string localUpstreamHostString = File.ReadAllText(MainConst.UpstreamHostPath);
|
||||||
|
|
||||||
try { upstreamUpstreamHostString = Encoding.UTF8.GetString(Convert.FromBase64String(upstreamUpstreamHostString)); }
|
try { upstreamUpstreamHostString = Encoding.UTF8.GetString(Convert.FromBase64String(upstreamUpstreamHostString)); }
|
||||||
catch { }
|
catch { }
|
||||||
|
|
||||||
if (sender == null && (localUpstreamHostString != upstreamUpstreamHostString && localUpstreamHostString.ReplaceLineEndings() != upstreamUpstreamHostString.ReplaceLineEndings()))
|
if (sender == null && (localUpstreamHostString != upstreamUpstreamHostString && localUpstreamHostString.ReplaceLineEndings() != upstreamUpstreamHostString.ReplaceLineEndings()))
|
||||||
MainPres.IsUpstreamHostUtd = false;
|
MainPres.IsUpstreamHostUtd = false;
|
||||||
else if (sender != null)
|
else if (sender != null)
|
||||||
if (localUpstreamHostString == upstreamUpstreamHostString || localUpstreamHostString.ReplaceLineEndings() == upstreamUpstreamHostString.ReplaceLineEndings())
|
if (localUpstreamHostString == upstreamUpstreamHostString || localUpstreamHostString.ReplaceLineEndings() == upstreamUpstreamHostString.ReplaceLineEndings())
|
||||||
{
|
|
||||||
MainPres.IsUpstreamHostUtd = true;
|
|
||||||
|
|
||||||
MessageBox.Show(MainConst._UpstreamHostUtdMsg);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MessageBoxResult overrideOptionResult = MessageBox.Show(MainConst._OverrideUpstreamHostPrompt, string.Empty, MessageBoxButton.YesNoCancel);
|
|
||||||
|
|
||||||
if (overrideOptionResult == MessageBoxResult.Yes)
|
|
||||||
{
|
{
|
||||||
File.WriteAllText(MainConst.UpstreamHostPath, upstreamUpstreamHostString);
|
|
||||||
|
|
||||||
MainPres.IsUpstreamHostUtd = true;
|
MainPres.IsUpstreamHostUtd = true;
|
||||||
|
|
||||||
MessageBox.Show(MainConst._UpdateUpstreamHostSuccessMsg);
|
MessageBox.Show(MainConst._UpstreamHostUtdMsg);
|
||||||
}
|
}
|
||||||
else if (overrideOptionResult == MessageBoxResult.No)
|
else
|
||||||
try { Process.Start(new ProcessStartInfo(upstreamUpstreamHostUrl) { UseShellExecute = true }); }
|
{
|
||||||
catch (UnauthorizedAccessException) { Process.Start(new ProcessStartInfo(upstreamUpstreamHostUrl) { UseShellExecute = true, Verb = "RunAs" }); }
|
MessageBoxResult overrideOptionResult = MessageBox.Show(MainConst._OverrideUpstreamHostPrompt, string.Empty, MessageBoxButton.YesNoCancel);
|
||||||
}
|
|
||||||
|
if (overrideOptionResult == MessageBoxResult.Yes)
|
||||||
|
{
|
||||||
|
File.WriteAllText(MainConst.UpstreamHostPath, upstreamUpstreamHostString);
|
||||||
|
|
||||||
|
MainPres.IsUpstreamHostUtd = true;
|
||||||
|
|
||||||
|
MessageBox.Show(MainConst._UpdateUpstreamHostSuccessMsg);
|
||||||
|
}
|
||||||
|
else if (overrideOptionResult == MessageBoxResult.No)
|
||||||
|
try { Process.Start(new ProcessStartInfo(upstreamUpstreamHostUrl) { UseShellExecute = true }); }
|
||||||
|
catch (UnauthorizedAccessException) { Process.Start(new ProcessStartInfo(upstreamUpstreamHostUrl) { UseShellExecute = true, Verb = "RunAs" }); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch { if (sender != null) throw; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SettingsButton_Click(object sender, RoutedEventArgs e) => new SettingsWin().ShowDialog();
|
private void SettingsButton_Click(object sender, RoutedEventArgs e) => new SettingsWin().ShowDialog();
|
||||||
|
Loading…
Reference in New Issue
Block a user