optimize<Popup>: remove popup from welcome page

This commit is contained in:
leo 2022-10-19 15:20:58 +08:00
parent b1102ac035
commit 8520786b7e
13 changed files with 443 additions and 368 deletions

View file

@ -7,11 +7,13 @@ namespace SourceGit.Commands {
/// </summary>
public class Clone : Command {
private Action<string> handler = null;
private Action<string> onError = null;
public Clone(string path, string url, string localName, string sshKey, string extraArgs, Action<string> outputHandler) {
public Clone(string path, string url, string localName, string sshKey, string extraArgs, Action<string> outputHandler, Action<string> 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);
}
}
}

View file

@ -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时的读取函数
/// </summary>
/// <param name="line"></param>
public virtual void OnReadline(string line) { }
public virtual void OnReadline(string line) {
}
/// <summary>
/// 默认异常处理函数
/// </summary>
/// <param name="message"></param>
public virtual void OnException(string message) {
Models.Exception.Raise(message);
}
}
}