-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathapp_diagnose.go
More file actions
61 lines (56 loc) · 1.88 KB
/
Copy pathapp_diagnose.go
File metadata and controls
61 lines (56 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package main
// app_diagnose.go ── 薄壳。真正实现已迁到 backend/app/diagnose。
// - DiagnoseReport / DiagnoseCheck 类型字段保留在 main 包,确保 wails
// binding 路径 `main.DiagnoseReport` 不动。
// - App.RunDiagnostics 调子包 Run 拿 Report,再字段拷贝回 main 类型。
import "windsurf-tools-wails/backend/app/diagnose"
// DiagnoseCheck 单项诊断结果。字段必须与 wails binding main.DiagnoseCheck 一致。
type DiagnoseCheck struct {
ID string `json:"id"`
Title string `json:"title"`
Status string `json:"status"`
Detail string `json:"detail"`
FixHint string `json:"fix_hint"`
}
// DiagnoseReport 完整诊断报告。字段必须与 wails binding main.DiagnoseReport 一致。
type DiagnoseReport struct {
Platform string `json:"platform"`
Arch string `json:"arch"`
OK int `json:"ok"`
Warn int `json:"warn"`
Error int `json:"error"`
Checks []DiagnoseCheck `json:"checks"`
}
// RunDiagnostics 跑全套诊断,返回报告。
//
// 实现细节:
// - 数据来源(DataDir / Clash 配置)通过 Deps 注入子包;
// - 子包返回 diagnose.Report,本 wrapper 字段拷贝成 main.DiagnoseReport。
func (a *App) RunDiagnostics() DiagnoseReport {
deps := diagnose.Deps{}
if a != nil && a.store != nil {
deps.DataDir = a.store.DataDir()
s := a.store.GetSettings()
deps.ClashControllerURL = s.ClashControllerURL
deps.ClashSecret = s.ClashSecret
}
r := diagnose.Run(deps)
checks := make([]DiagnoseCheck, len(r.Checks))
for i, c := range r.Checks {
checks[i] = DiagnoseCheck{
ID: c.ID,
Title: c.Title,
Status: c.Status,
Detail: c.Detail,
FixHint: c.FixHint,
}
}
return DiagnoseReport{
Platform: r.Platform,
Arch: r.Arch,
OK: r.OK,
Warn: r.Warn,
Error: r.Error,
Checks: checks,
}
}