Skip to content

Commit 791ec8d

Browse files
committed
fix:添加UI配置参数对接
1 parent bab3da8 commit 791ec8d

File tree

2 files changed

+52
-7
lines changed

2 files changed

+52
-7
lines changed

ui/executor.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ func NewCommandExecutor(outputCallback func(string)) *CommandExecutor {
3636
}
3737
}
3838

39-
func (e *CommandExecutor) Execute(selectedOptions map[string]bool, language string, testUpload bool, testDownload bool, chinaModeEnabled bool) error {
39+
func (e *CommandExecutor) Execute(selectedOptions map[string]bool, language string, testUpload bool, testDownload bool, chinaModeEnabled bool,
40+
cpuMethod, threadMode, memoryMethod, diskMethod, diskPath string, diskMulti bool,
41+
nt3Location, nt3Type string, spNum int) error {
4042
// 设置测试选项
4143
basicStatus := selectedOptions["basic"]
4244
cpuTestStatus := selectedOptions["cpu"]
@@ -135,7 +137,7 @@ func (e *CommandExecutor) Execute(selectedOptions map[string]bool, language stri
135137
// 2. CPU测试
136138
if cpuTestStatus {
137139
outputMutex.Lock()
138-
realTestMethod, res := cputest.CpuTest(language, "sysbench", "multi")
140+
realTestMethod, res := cputest.CpuTest(language, cpuMethod, threadMode)
139141
if language == "zh" {
140142
ecsutils.PrintCenteredTitle(fmt.Sprintf("CPU测试-通过%s测试", realTestMethod), 82)
141143
} else {
@@ -148,7 +150,7 @@ func (e *CommandExecutor) Execute(selectedOptions map[string]bool, language stri
148150
// 3. 内存测试
149151
if memoryTestStatus {
150152
outputMutex.Lock()
151-
realTestMethod, res := memorytest.MemoryTest(language, "auto")
153+
realTestMethod, res := memorytest.MemoryTest(language, memoryMethod)
152154
if language == "zh" {
153155
ecsutils.PrintCenteredTitle(fmt.Sprintf("内存测试-通过%s测试", realTestMethod), 82)
154156
} else {
@@ -161,7 +163,7 @@ func (e *CommandExecutor) Execute(selectedOptions map[string]bool, language stri
161163
// 4. 磁盘测试
162164
if diskTestStatus {
163165
outputMutex.Lock()
164-
realTestMethod, res := disktest.DiskTest(language, "fio", "", false, true)
166+
realTestMethod, res := disktest.DiskTest(language, diskMethod, diskPath, diskMulti, true)
165167
if language == "zh" {
166168
ecsutils.PrintCenteredTitle(fmt.Sprintf("硬盘测试-通过%s测试", realTestMethod), 82)
167169
} else {
@@ -255,7 +257,7 @@ func (e *CommandExecutor) Execute(selectedOptions map[string]bool, language stri
255257
} else {
256258
ecsutils.PrintCenteredTitle("NextTrace-3Networks-Check", 82)
257259
}
258-
nexttrace.NextTrace3Check(language, "GZ", "ipv4")
260+
nexttrace.NextTrace3Check(language, nt3Location, nt3Type)
259261
outputMutex.Unlock()
260262
}
261263

@@ -286,7 +288,7 @@ func (e *CommandExecutor) Execute(selectedOptions map[string]bool, language stri
286288
if testUpload || testDownload {
287289
speedtest.NearbySP()
288290
if language == "zh" {
289-
speedtest.CustomSP("net", "global", 2, language)
291+
speedtest.CustomSP("net", "global", spNum, language)
290292
} else {
291293
speedtest.CustomSP("net", "global", -1, language)
292294
}

ui/ui_executor.go

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,55 @@ func (ui *TestUI) runTestsWithExecutor() {
3737
// 获取中国模式配置
3838
chinaModeEnabled := ui.ChinaModeCheck.Checked
3939

40+
// 获取CPU配置
41+
cpuMethod := ui.CpuMethodSelect.Selected
42+
if cpuMethod == "" {
43+
cpuMethod = "sysbench"
44+
}
45+
threadMode := ui.ThreadModeSelect.Selected
46+
if threadMode == "" {
47+
threadMode = "multi"
48+
}
49+
50+
// 获取内存配置
51+
memoryMethod := ui.MemoryMethodSelect.Selected
52+
if memoryMethod == "" {
53+
memoryMethod = "auto"
54+
}
55+
56+
// 获取磁盘配置
57+
diskMethod := ui.DiskMethodSelect.Selected
58+
if diskMethod == "" {
59+
diskMethod = "auto"
60+
}
61+
diskPath := ui.DiskPathEntry.Text
62+
diskMulti := ui.DiskMultiCheck.Checked
63+
64+
// 获取NT3配置
65+
nt3Location := ui.Nt3LocationSelect.Selected
66+
if nt3Location == "" {
67+
nt3Location = "GZ"
68+
}
69+
nt3Type := ui.Nt3TypeSelect.Selected
70+
if nt3Type == "" {
71+
nt3Type = "ipv4"
72+
}
73+
74+
// 获取测速节点数
75+
spNum := 2 // 默认值
76+
if ui.SpNumEntry.Text != "" {
77+
// 尝试解析spNum,如果失败则使用默认值
78+
fmt.Sscanf(ui.SpNumEntry.Text, "%d", &spNum)
79+
}
80+
4081
// 更新进度
4182
ui.ProgressBar.SetValue(0.1)
4283
ui.StatusLabel.SetText("正在执行测试...")
4384

4485
// 执行测试(输出会实时显示在terminal widget中)
45-
err := executor.Execute(selectedOptions, language, testUpload, testDownload, chinaModeEnabled)
86+
err := executor.Execute(selectedOptions, language, testUpload, testDownload, chinaModeEnabled,
87+
cpuMethod, threadMode, memoryMethod, diskMethod, diskPath, diskMulti,
88+
nt3Location, nt3Type, spNum)
4689

4790
// 显示结束信息
4891
endTime := time.Now()

0 commit comments

Comments
 (0)