feat: 添加打包,修复bug

This commit is contained in:
chenxiangtong
2026-05-28 20:13:57 +08:00
parent 3927010bb9
commit b5ab610893
9 changed files with 95 additions and 9 deletions

View File

@@ -64,6 +64,28 @@ func executeAction(versionDir string, action Action, index int, backupDir string
}
return actionCompleteMsg{index: index}
}
case "new":
return func() tea.Msg {
absPath := filepath.Join(versionDir, action.Path)
if _, err := os.Stat(absPath); err == nil {
return actionCompleteMsg{index: index}
}
if action.IsDir {
if err := os.MkdirAll(absPath, 0o755); err != nil {
return actionErrorMsg{index: index, err: fmt.Errorf("create dir failed: %w", err)}
}
} else {
if err := os.MkdirAll(filepath.Dir(absPath), 0o755); err != nil {
return actionErrorMsg{index: index, err: fmt.Errorf("mkdir failed: %w", err)}
}
f, err := os.Create(absPath)
if err != nil {
return actionErrorMsg{index: index, err: fmt.Errorf("create file failed: %w", err)}
}
f.Close()
}
return actionCompleteMsg{index: index}
}
default:
return func() tea.Msg {
return actionErrorMsg{index: index, err: fmt.Errorf("unknown action type: %s", action.Type)}