Skip to content

Commit a38bbf2

Browse files
committed
feature: 修改启动方式
1 parent e5ff3df commit a38bbf2

File tree

3 files changed

+24
-44
lines changed

3 files changed

+24
-44
lines changed

src/StartManager/Application.cs

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,22 @@ namespace StartManager;
44

55
public class Application
66
{
7+
public static void StartFileServer() => Start("hfs.exe", GetAppDirectory());
78

8-
public static void StartFileServer()
9-
{
10-
var name = "hfs.exe";
11-
}
12-
13-
public static void StartClient()
14-
{
15-
var name = "ClientSample.exe";
16-
}
9+
public static void StartClient() => Start("ClientSample.exe", GetAppDirectory());
1710

18-
public static void StartServer()
19-
{
20-
var name = "ServerSample.exe";
21-
}
11+
public static void StartServer() => Start("ServerSample.exe", GetAppDirectory());
2212

23-
public static void StartUpgrade()
24-
{
25-
var name = "UpgradeSample.exe";
26-
}
13+
public static void Reset() => Start("resource.bat", GetParent());
14+
15+
private static string GetAppDirectory() => Path.Combine(GetParent(), "run", "app");
2716

28-
public static void Reset()
17+
private static string GetParent()
2918
{
19+
var currentDirectory = Directory.GetCurrentDirectory();
20+
int indexOfSrc = currentDirectory.IndexOf("src", StringComparison.OrdinalIgnoreCase);
21+
string truncatedPath = currentDirectory.Substring(0, indexOfSrc + "src".Length);
22+
return truncatedPath;
3023
}
3124

3225
private static void Start(string appName, string path)

src/StartManager/Program.cs

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,25 @@ class Program
55
static void Main(string[] args)
66
{
77
bool exit = false;
8-
ShowMenu();
98
while (!exit)
109
{
10+
ShowMenu();
1111
string input = Console.ReadLine();
1212
switch (input)
1313
{
1414
case "1":
15-
Option1();
15+
Application.Reset();
1616
break;
1717
case "2":
18-
Option2();
18+
Application.StartFileServer();
1919
break;
2020
case "3":
21-
Option3();
21+
Application.StartServer();
2222
break;
2323
case "4":
24+
Application.StartClient();
25+
break;
26+
case "E":
2427
exit = true;
2528
break;
2629
default:
@@ -33,28 +36,11 @@ static void Main(string[] args)
3336
static void ShowMenu()
3437
{
3538
Console.WriteLine("请选择一个选项:");
36-
Console.WriteLine("1. 启动服务端");
37-
Console.WriteLine("2. 启动客户端");
38-
Console.WriteLine("3. 还原");
39-
Console.WriteLine("4. 退出");
39+
Console.WriteLine("1. 还原run目录");
40+
Console.WriteLine("2. 启动文件服务端");
41+
Console.WriteLine("3. 启动服务端");
42+
Console.WriteLine("4. 启动客户端");
43+
Console.WriteLine("E. 退出");
4044
Console.Write("输入你的选择: ");
4145
}
42-
43-
static void Option1()
44-
{
45-
Console.WriteLine("你选择了选项1");
46-
// 在这里添加选项1的逻辑
47-
}
48-
49-
static void Option2()
50-
{
51-
Console.WriteLine("你选择了选项2");
52-
// 在这里添加选项2的逻辑
53-
}
54-
55-
static void Option3()
56-
{
57-
Console.WriteLine("你选择了选项3");
58-
// 在这里添加选项3的逻辑
59-
}
6046
}

src/resource.bat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ REM Copy files from Client, Server, Upgrade to app directory
2222
xcopy "%BASE_DIR%Client\bin\Release\net8.0\*" "%BASE_DIR%run\app\" /s /e /y
2323
xcopy "%BASE_DIR%Server\bin\Release\net8.0\*" "%BASE_DIR%run\app\" /s /e /y
2424
xcopy "%BASE_DIR%Upgrade\bin\Release\net8.0\*" "%BASE_DIR%run\app\" /s /e /y
25+
xcopy "%BASE_DIR%FileService\*" "%BASE_DIR%run\app\" /s /e /y
2526

2627
REM Create test.txt files with specified content
2728
echo 123456 > "%BASE_DIR%run\files\old\test.txt"

0 commit comments

Comments
 (0)