fix:添加UI配置参数对接
Some checks failed
Build All UI APP / Prepare Version (push) Has been cancelled
Build All UI APP / Build Android APK (push) Has been cancelled
Build All UI APP / Build Desktop Apps (amd64, macos-amd64, macos-13, darwin) (push) Has been cancelled
Build All UI APP / Build Desktop Apps (amd64, windows-amd64, windows-latest, windows) (push) Has been cancelled
Build All UI APP / Build Desktop Apps (arm64, macos-arm64, macos-latest, darwin) (push) Has been cancelled

This commit is contained in:
spiritlhl
2025-11-02 18:59:03 +08:00
parent bab3da8da3
commit 791ec8df5e
2 changed files with 52 additions and 7 deletions

View File

@@ -36,7 +36,9 @@ func NewCommandExecutor(outputCallback func(string)) *CommandExecutor {
} }
} }
func (e *CommandExecutor) Execute(selectedOptions map[string]bool, language string, testUpload bool, testDownload bool, chinaModeEnabled bool) error { func (e *CommandExecutor) Execute(selectedOptions map[string]bool, language string, testUpload bool, testDownload bool, chinaModeEnabled bool,
cpuMethod, threadMode, memoryMethod, diskMethod, diskPath string, diskMulti bool,
nt3Location, nt3Type string, spNum int) error {
// 设置测试选项 // 设置测试选项
basicStatus := selectedOptions["basic"] basicStatus := selectedOptions["basic"]
cpuTestStatus := selectedOptions["cpu"] cpuTestStatus := selectedOptions["cpu"]
@@ -135,7 +137,7 @@ func (e *CommandExecutor) Execute(selectedOptions map[string]bool, language stri
// 2. CPU测试 // 2. CPU测试
if cpuTestStatus { if cpuTestStatus {
outputMutex.Lock() outputMutex.Lock()
realTestMethod, res := cputest.CpuTest(language, "sysbench", "multi") realTestMethod, res := cputest.CpuTest(language, cpuMethod, threadMode)
if language == "zh" { if language == "zh" {
ecsutils.PrintCenteredTitle(fmt.Sprintf("CPU测试-通过%s测试", realTestMethod), 82) ecsutils.PrintCenteredTitle(fmt.Sprintf("CPU测试-通过%s测试", realTestMethod), 82)
} else { } else {
@@ -148,7 +150,7 @@ func (e *CommandExecutor) Execute(selectedOptions map[string]bool, language stri
// 3. 内存测试 // 3. 内存测试
if memoryTestStatus { if memoryTestStatus {
outputMutex.Lock() outputMutex.Lock()
realTestMethod, res := memorytest.MemoryTest(language, "auto") realTestMethod, res := memorytest.MemoryTest(language, memoryMethod)
if language == "zh" { if language == "zh" {
ecsutils.PrintCenteredTitle(fmt.Sprintf("内存测试-通过%s测试", realTestMethod), 82) ecsutils.PrintCenteredTitle(fmt.Sprintf("内存测试-通过%s测试", realTestMethod), 82)
} else { } else {
@@ -161,7 +163,7 @@ func (e *CommandExecutor) Execute(selectedOptions map[string]bool, language stri
// 4. 磁盘测试 // 4. 磁盘测试
if diskTestStatus { if diskTestStatus {
outputMutex.Lock() outputMutex.Lock()
realTestMethod, res := disktest.DiskTest(language, "fio", "", false, true) realTestMethod, res := disktest.DiskTest(language, diskMethod, diskPath, diskMulti, true)
if language == "zh" { if language == "zh" {
ecsutils.PrintCenteredTitle(fmt.Sprintf("硬盘测试-通过%s测试", realTestMethod), 82) ecsutils.PrintCenteredTitle(fmt.Sprintf("硬盘测试-通过%s测试", realTestMethod), 82)
} else { } else {
@@ -255,7 +257,7 @@ func (e *CommandExecutor) Execute(selectedOptions map[string]bool, language stri
} else { } else {
ecsutils.PrintCenteredTitle("NextTrace-3Networks-Check", 82) ecsutils.PrintCenteredTitle("NextTrace-3Networks-Check", 82)
} }
nexttrace.NextTrace3Check(language, "GZ", "ipv4") nexttrace.NextTrace3Check(language, nt3Location, nt3Type)
outputMutex.Unlock() outputMutex.Unlock()
} }
@@ -286,7 +288,7 @@ func (e *CommandExecutor) Execute(selectedOptions map[string]bool, language stri
if testUpload || testDownload { if testUpload || testDownload {
speedtest.NearbySP() speedtest.NearbySP()
if language == "zh" { if language == "zh" {
speedtest.CustomSP("net", "global", 2, language) speedtest.CustomSP("net", "global", spNum, language)
} else { } else {
speedtest.CustomSP("net", "global", -1, language) speedtest.CustomSP("net", "global", -1, language)
} }

View File

@@ -37,12 +37,55 @@ func (ui *TestUI) runTestsWithExecutor() {
// 获取中国模式配置 // 获取中国模式配置
chinaModeEnabled := ui.ChinaModeCheck.Checked chinaModeEnabled := ui.ChinaModeCheck.Checked
// 获取CPU配置
cpuMethod := ui.CpuMethodSelect.Selected
if cpuMethod == "" {
cpuMethod = "sysbench"
}
threadMode := ui.ThreadModeSelect.Selected
if threadMode == "" {
threadMode = "multi"
}
// 获取内存配置
memoryMethod := ui.MemoryMethodSelect.Selected
if memoryMethod == "" {
memoryMethod = "auto"
}
// 获取磁盘配置
diskMethod := ui.DiskMethodSelect.Selected
if diskMethod == "" {
diskMethod = "auto"
}
diskPath := ui.DiskPathEntry.Text
diskMulti := ui.DiskMultiCheck.Checked
// 获取NT3配置
nt3Location := ui.Nt3LocationSelect.Selected
if nt3Location == "" {
nt3Location = "GZ"
}
nt3Type := ui.Nt3TypeSelect.Selected
if nt3Type == "" {
nt3Type = "ipv4"
}
// 获取测速节点数
spNum := 2 // 默认值
if ui.SpNumEntry.Text != "" {
// 尝试解析spNum如果失败则使用默认值
fmt.Sscanf(ui.SpNumEntry.Text, "%d", &spNum)
}
// 更新进度 // 更新进度
ui.ProgressBar.SetValue(0.1) ui.ProgressBar.SetValue(0.1)
ui.StatusLabel.SetText("正在执行测试...") ui.StatusLabel.SetText("正在执行测试...")
// 执行测试输出会实时显示在terminal widget中 // 执行测试输出会实时显示在terminal widget中
err := executor.Execute(selectedOptions, language, testUpload, testDownload, chinaModeEnabled) err := executor.Execute(selectedOptions, language, testUpload, testDownload, chinaModeEnabled,
cpuMethod, threadMode, memoryMethod, diskMethod, diskPath, diskMulti,
nt3Location, nt3Type, spNum)
// 显示结束信息 // 显示结束信息
endTime := time.Now() endTime := time.Now()