🎨 Optimize storage logic

This commit is contained in:
2025-07-13 22:32:58 +08:00
parent 6d8fdf62f1
commit b4b0ad9bba
11 changed files with 671 additions and 45 deletions

View File

@@ -124,6 +124,7 @@ type AppConfig struct {
Editing EditingConfig `json:"editing"` // 编辑设置
Appearance AppearanceConfig `json:"appearance"` // 外观设置
Updates UpdatesConfig `json:"updates"` // 更新设置
Sync GitSyncConfig `json:"sync"` // Git同步设置
Metadata ConfigMetadata `json:"metadata"` // 配置元数据
}
@@ -138,6 +139,7 @@ func NewDefaultAppConfig() *AppConfig {
currentDir, _ := os.UserHomeDir()
dataDir := filepath.Join(currentDir, ".voidraft", "data")
repoPath := filepath.Join(currentDir, ".voidraft", "sync-repo")
return &AppConfig{
General: GeneralConfig{
@@ -173,7 +175,7 @@ func NewDefaultAppConfig() *AppConfig {
CustomTheme: *NewDefaultCustomThemeConfig(),
},
Updates: UpdatesConfig{
Version: "1.0.0",
Version: "1.2.0",
AutoUpdate: true,
PrimarySource: UpdateSourceGithub,
BackupSource: UpdateSourceGitea,
@@ -189,9 +191,25 @@ func NewDefaultAppConfig() *AppConfig {
Repo: "voidraft",
},
},
Sync: GitSyncConfig{
Enabled: false,
RepoURL: "",
Branch: "main",
AuthMethod: Token,
Username: "",
Password: "",
Token: "",
SSHKeyPath: "",
SyncInterval: 60,
LastSyncTime: time.Time{},
AutoSync: true,
LocalRepoPath: repoPath,
SyncStrategy: LocalFirst,
FilesToSync: []string{"voidraft.db"},
},
Metadata: ConfigMetadata{
LastUpdated: time.Now().Format(time.RFC3339),
Version: "1.0.0",
Version: "1.2.0",
},
}
}