✨ Complete the document saving service
This commit is contained in:
@@ -16,6 +16,21 @@ const (
|
||||
TabTypeTab TabType = "tab"
|
||||
)
|
||||
|
||||
// SaveOptions 保存选项
|
||||
type SaveOptions struct {
|
||||
// 自动保存延迟(毫秒)- 内容变更后多久自动保存
|
||||
AutoSaveDelay int `json:"autoSaveDelay"`
|
||||
// 变更字符阈值,超过此阈值立即触发保存
|
||||
ChangeThreshold int `json:"changeThreshold"`
|
||||
// 最小保存间隔(毫秒)- 两次保存之间的最小时间间隔,避免频繁IO
|
||||
MinSaveInterval int `json:"minSaveInterval"`
|
||||
}
|
||||
|
||||
// DocumentConfig 定义文档配置
|
||||
type DocumentConfig struct {
|
||||
SaveOptions SaveOptions `json:"saveOptions"` // 详细保存选项
|
||||
}
|
||||
|
||||
// EditorConfig 定义编辑器配置
|
||||
type EditorConfig struct {
|
||||
FontSize int `json:"fontSize"` // 字体大小
|
||||
@@ -45,6 +60,7 @@ type PathsConfig struct {
|
||||
// AppConfig 应用配置 - 包含业务配置和路径配置
|
||||
type AppConfig struct {
|
||||
Editor EditorConfig `json:"editor"` // 编辑器配置
|
||||
Document DocumentConfig `json:"document"` // 文档配置
|
||||
Paths PathsConfig `json:"paths"` // 路径配置
|
||||
Metadata ConfigMetadata `json:"metadata"` // 配置元数据
|
||||
}
|
||||
@@ -65,6 +81,7 @@ func NewDefaultAppConfig() *AppConfig {
|
||||
|
||||
// 默认路径配置
|
||||
rootDir := filepath.Join(homePath, ".voidraft")
|
||||
dataDir := filepath.Join(rootDir, "data")
|
||||
|
||||
return &AppConfig{
|
||||
Editor: EditorConfig{
|
||||
@@ -75,9 +92,16 @@ func NewDefaultAppConfig() *AppConfig {
|
||||
Language: LangZhCN,
|
||||
AlwaysOnTop: false,
|
||||
},
|
||||
Document: DocumentConfig{
|
||||
SaveOptions: SaveOptions{
|
||||
AutoSaveDelay: 5000, // 5秒后自动保存
|
||||
ChangeThreshold: 500, // 500个字符变更触发保存
|
||||
MinSaveInterval: 1000, // 最小间隔1000毫秒
|
||||
},
|
||||
},
|
||||
Paths: PathsConfig{
|
||||
LogPath: filepath.Join(rootDir, "logs"),
|
||||
DataPath: filepath.Join(rootDir, "data"),
|
||||
DataPath: dataDir,
|
||||
},
|
||||
Metadata: ConfigMetadata{
|
||||
Version: "1.0.0",
|
||||
|
Reference in New Issue
Block a user