renamer.go 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // Package renamer 提供「智能重命名」共享导出类型。
  2. // 该包只定义纯数据类型(无数据库 / 框架依赖),供 internal/ai 纯逻辑与
  3. // renamerstore.go / renamerservice.go 的持久化与 Wails 服务共同引用,
  4. // 避免 AI 包与 store 之间重复定义结构体。
  5. package renamer
  6. // Pair 一对「旧文件名 → 新文件名」。
  7. type Pair struct {
  8. From string `json:"from"`
  9. To string `json:"to"`
  10. }
  11. // Config AI 接入商配置(单行存储)。
  12. type Config struct {
  13. Provider string `json:"provider"` // openai | ollama
  14. BaseURL string `json:"baseURL"`
  15. APIKey string `json:"apiKey"`
  16. Model string `json:"model"`
  17. }
  18. // FileEntry 目录扫描结果中的单个文件。
  19. type FileEntry struct {
  20. Name string `json:"name"` // 相对路径(递归时 ToSlash)
  21. Size int64 `json:"size"` // 字节数
  22. ModTime string `json:"modTime"` // 修改时间 "2006-01-02 15:04"
  23. }
  24. // ScanResult 目录扫描结果。
  25. type ScanResult struct {
  26. Dir string `json:"dir"` // 绝对目录路径
  27. Files []FileEntry `json:"files"` // 文件列表(按名称排序)
  28. }
  29. // PreviewEntry AI 预览结果行。
  30. type PreviewEntry struct {
  31. From string `json:"from"`
  32. To string `json:"to"`
  33. Status string `json:"status"` // ok | same | error
  34. Reason string `json:"reason,omitempty"`
  35. }
  36. // RenameResult 单文件重命名执行结果。
  37. type RenameResult struct {
  38. From string `json:"from"`
  39. To string `json:"to"`
  40. OK bool `json:"ok"`
  41. Error string `json:"error,omitempty"`
  42. }
  43. // HistoryItem 单个文件的重命名记录。
  44. type HistoryItem struct {
  45. From string `json:"from"`
  46. To string `json:"to"`
  47. }
  48. // History 一次批量重命名的历史记录。
  49. type History struct {
  50. ID int64 `json:"id"`
  51. CreatedAt string `json:"createdAt"`
  52. Dir string `json:"dir"`
  53. Count int `json:"count"`
  54. Undone bool `json:"undone"` // 该批次是否已撤回
  55. Details []HistoryItem `json:"details"`
  56. }