From 16aced3f9874794d47e91ed1ce3b5189efacc0e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8C=BF=E4=BA=BA=E6=98=93?= Date: Sat, 5 Jul 2025 13:10:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=96=84=E7=94=A8=E6=88=B7=E4=BD=93?= =?UTF-8?q?=E9=AA=8C=EF=BC=9A=E6=B7=BB=E5=8A=A0=E8=BF=94=E5=9B=9E=E4=B8=BB?= =?UTF-8?q?=E8=8F=9C=E5=8D=95=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在 `RestartService.cs`、`StartService.cs` 和 `StopService.cs` 文件中,添加了 "0. 返回主菜单" 选项,并更新了用户输入提示信息。修改了输入检查逻辑,使用户在输入为空或 "0" 时能够返回主菜单,而不是取消操作。 --- StarAgent/CommandHandler/RestartService.cs | 7 ++++--- StarAgent/CommandHandler/StartService.cs | 7 ++++--- StarAgent/CommandHandler/StopService.cs | 7 ++++--- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/StarAgent/CommandHandler/RestartService.cs b/StarAgent/CommandHandler/RestartService.cs index 4e275fcd..9bfdb094 100644 --- a/StarAgent/CommandHandler/RestartService.cs +++ b/StarAgent/CommandHandler/RestartService.cs @@ -36,13 +36,14 @@ public class RestartService : BaseCommandHandler var status = es != null ? "运行中" : "已停止"; XTrace.WriteLine("{0}. {1} ({2})", i + 1, svc.Name, status); } + XTrace.WriteLine("0. 返回主菜单"); // 获取用户输入 - XTrace.WriteLine("请输入服务序号或名称:"); + XTrace.WriteLine("请输入服务序号或名称(0 返回主菜单):"); var input = Console.ReadLine(); - if (String.IsNullOrEmpty(input)) + if (String.IsNullOrEmpty(input) || input == "0") { - XTrace.WriteLine("操作已取消"); + XTrace.WriteLine("返回主菜单..."); return; } diff --git a/StarAgent/CommandHandler/StartService.cs b/StarAgent/CommandHandler/StartService.cs index 5c0463f7..df889a30 100644 --- a/StarAgent/CommandHandler/StartService.cs +++ b/StarAgent/CommandHandler/StartService.cs @@ -34,13 +34,14 @@ public class StartService : BaseCommandHandler var svc = services.Services[i]; XTrace.WriteLine("{0}. {1}", i + 1, svc.Name); } + XTrace.WriteLine("0. 返回主菜单"); // 获取用户输入 - XTrace.WriteLine("请输入服务序号或名称:"); + XTrace.WriteLine("请输入服务序号或名称(0 返回主菜单):"); var input = Console.ReadLine(); - if (String.IsNullOrEmpty(input)) + if (String.IsNullOrEmpty(input) || input == "0") { - XTrace.WriteLine("操作已取消"); + XTrace.WriteLine("返回主菜单..."); return; } diff --git a/StarAgent/CommandHandler/StopService.cs b/StarAgent/CommandHandler/StopService.cs index 05d22882..b2b932d1 100644 --- a/StarAgent/CommandHandler/StopService.cs +++ b/StarAgent/CommandHandler/StopService.cs @@ -38,13 +38,14 @@ public class StopService : BaseCommandHandler XTrace.WriteLine("{0}. {1} (PID: {2})", i + 1, svc.Name, es.ProcessId); } } + XTrace.WriteLine("0. 返回主菜单"); // 获取用户输入 - XTrace.WriteLine("请输入服务序号或名称:"); + XTrace.WriteLine("请输入服务序号或名称(0 返回主菜单):"); var input = Console.ReadLine(); - if (String.IsNullOrEmpty(input)) + if (String.IsNullOrEmpty(input) || input == "0") { - XTrace.WriteLine("操作已取消"); + XTrace.WriteLine("返回主菜单..."); return; }