types.ts 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /** 前端传入 Rust 端的项目信息 */
  2. export interface ProjectBackupInfo {
  3. id: string
  4. path: string
  5. name: string
  6. }
  7. export type ProjectBackupSection =
  8. | "content"
  9. | "memory"
  10. | "analysis"
  11. | "indexes"
  12. | "trash"
  13. export interface SelectedProjectBackupInfo extends ProjectBackupInfo {
  14. sections: ProjectBackupSection[]
  15. }
  16. export interface BackupExportOptions {
  17. includeGlobalConfig: boolean
  18. includeUiPreferences: boolean
  19. includeCredentials: boolean
  20. projects: SelectedProjectBackupInfo[]
  21. }
  22. /** 导出参数 */
  23. export interface ExportParams {
  24. savePath: string
  25. includeGlobalConfig: boolean
  26. includeUiPreferences: boolean
  27. includeCredentials: boolean
  28. localStorageData: Record<string, string>
  29. projects: SelectedProjectBackupInfo[]
  30. }
  31. /** 导出结果 */
  32. export interface ExportResult {
  33. success: boolean
  34. warnings: string[]
  35. fileCount: number
  36. totalSize: number
  37. error: string | null
  38. }
  39. /** 导入策略 */
  40. export type ImportStrategy = "full" | "global-only" | "selective"
  41. /** 选择性导入时的项目恢复信息 */
  42. export interface ProjectRestoreInfo {
  43. id: string
  44. targetPath: string
  45. }
  46. /** 导入参数 */
  47. export interface ImportParams {
  48. zipPath: string
  49. strategy: ImportStrategy
  50. projects?: ProjectRestoreInfo[]
  51. projectPathOverrides?: Record<string, string>
  52. }
  53. /** 项目恢复结果 */
  54. export interface ProjectRestoreResult {
  55. id: string
  56. path: string
  57. name: string
  58. success: boolean
  59. error: string | null
  60. }
  61. /** 导入结果 */
  62. export interface ImportResult {
  63. success: boolean
  64. appState: Record<string, unknown> | null
  65. localStorageData: Record<string, string> | null
  66. projects: ProjectRestoreResult[]
  67. warnings: string[]
  68. error: string | null
  69. replaceLocalStorage?: boolean
  70. }
  71. export interface BackupContents {
  72. globalConfig: boolean
  73. uiPreferences: boolean
  74. credentials: boolean
  75. }
  76. /** 备份清单(zip 内 manifest.json) */
  77. export interface BackupManifest {
  78. backupVersion: number
  79. createdAt: string
  80. appVersion: string
  81. contents?: BackupContents
  82. projects: Array<ProjectBackupInfo & { sections?: ProjectBackupSection[] }>
  83. }
  84. /** manifest 项目条目(含路径可达性) */
  85. export interface ProjectManifestEntry {
  86. id: string
  87. path: string
  88. name: string
  89. pathAccessible: boolean
  90. sections: ProjectBackupSection[]
  91. }
  92. export interface BackupManifestPreview {
  93. backupVersion: number
  94. contents: BackupContents
  95. projects: ProjectManifestEntry[]
  96. }
  97. /** 进度事件载荷 */
  98. export interface BackupProgressPayload {
  99. operation: "export" | "import"
  100. stage: string
  101. current: number
  102. total: number
  103. message: string
  104. }
  105. /** 进度回调 */
  106. export type BackupProgressCallback = (payload: BackupProgressPayload) => void