feat: 重构

This commit is contained in:
chenxiangtong
2026-05-28 17:37:57 +08:00
parent 88a0c45f5b
commit 3ff2454c63
26 changed files with 1248 additions and 2055 deletions

39
scan.go Normal file
View File

@@ -0,0 +1,39 @@
package main
import (
"os"
"path/filepath"
tea "github.com/charmbracelet/bubbletea"
)
type versionInfo struct {
name string
path string
}
type versionsFoundMsg []versionInfo
type scanErrorMsg struct{ err error }
func scanVersions(exeDir string) tea.Cmd {
return func() tea.Msg {
pattern := filepath.Join(exeDir, ".minecraft", "versions", "*")
matches, err := filepath.Glob(pattern)
if err != nil {
return scanErrorMsg{err: err}
}
var versions []versionInfo
for _, m := range matches {
info, err := os.Stat(m)
if err != nil || !info.IsDir() {
continue
}
versions = append(versions, versionInfo{
name: filepath.Base(m),
path: m,
})
}
return versionsFoundMsg(versions)
}
}