From 8520786b7e893c86045480dc43d635845ee8bcfe Mon Sep 17 00:00:00 2001 From: leo Date: Wed, 19 Oct 2022 15:20:58 +0800 Subject: [PATCH] optimize: remove popup from welcome page --- src/Commands/Clone.cs | 8 +- src/Commands/Command.cs | 15 +- src/Views/Clone.xaml | 256 +++++++++++++++++++++++++++ src/Views/{Popups => }/Clone.xaml.cs | 43 +++-- src/Views/Controls/PopupWidget.cs | 3 +- src/Views/Launcher.xaml.cs | 13 +- src/Views/Popups/Clone.xaml | 157 ---------------- src/Views/Widgets/Dashboard.xaml | 41 ++++- src/Views/Widgets/Dashboard.xaml.cs | 91 +++++++++- src/Views/Widgets/PopupPanel.xaml | 47 ----- src/Views/Widgets/PopupPanel.xaml.cs | 111 ------------ src/Views/Widgets/Welcome.xaml | 3 - src/Views/Widgets/Welcome.xaml.cs | 23 +-- 13 files changed, 443 insertions(+), 368 deletions(-) create mode 100644 src/Views/Clone.xaml rename src/Views/{Popups => }/Clone.xaml.cs (76%) delete mode 100644 src/Views/Popups/Clone.xaml delete mode 100644 src/Views/Widgets/PopupPanel.xaml delete mode 100644 src/Views/Widgets/PopupPanel.xaml.cs diff --git a/src/Commands/Clone.cs b/src/Commands/Clone.cs index 28587dab..1f845cc8 100644 --- a/src/Commands/Clone.cs +++ b/src/Commands/Clone.cs @@ -7,11 +7,13 @@ namespace SourceGit.Commands { /// public class Clone : Command { private Action handler = null; + private Action onError = null; - public Clone(string path, string url, string localName, string sshKey, string extraArgs, Action outputHandler) { + public Clone(string path, string url, string localName, string sshKey, string extraArgs, Action outputHandler, Action errHandler) { Cwd = path; TraitErrorAsOutput = true; handler = outputHandler; + onError = errHandler; if (!string.IsNullOrEmpty(sshKey)) { Envs.Add("GIT_SSH_COMMAND", $"ssh -i '{sshKey}'"); @@ -30,5 +32,9 @@ namespace SourceGit.Commands { public override void OnReadline(string line) { handler?.Invoke(line); } + + public override void OnException(string message) { + onError?.Invoke(message); + } } } diff --git a/src/Commands/Command.cs b/src/Commands/Command.cs index 90eff69a..4cf248fa 100644 --- a/src/Commands/Command.cs +++ b/src/Commands/Command.cs @@ -112,7 +112,7 @@ namespace SourceGit.Commands { try { proc.Start(); } catch (Exception e) { - if (!DontRaiseError) Models.Exception.Raise(e.Message); + if (!DontRaiseError) OnException(e.Message); return false; } @@ -124,7 +124,7 @@ namespace SourceGit.Commands { proc.Close(); if (!isCancelled && exitCode != 0 && errs.Count > 0) { - if (!DontRaiseError) Models.Exception.Raise(string.Join("\n", errs)); + if (!DontRaiseError) OnException(string.Join("\n", errs)); return false; } else { return true; @@ -173,6 +173,15 @@ namespace SourceGit.Commands { /// 调用Exec时的读取函数 /// /// - public virtual void OnReadline(string line) { } + public virtual void OnReadline(string line) { + } + + /// + /// 默认异常处理函数 + /// + /// + public virtual void OnException(string message) { + Models.Exception.Raise(message); + } } } diff --git a/src/Views/Clone.xaml b/src/Views/Clone.xaml new file mode 100644 index 00000000..db73fe64 --- /dev/null +++ b/src/Views/Clone.xaml @@ -0,0 +1,256 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +