Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Database .json follows the doc tree single line save setting https://github.com/siyuan-note/siyuan/issues/10571

Daniel7f82fc21afc1
diff --git a/app/appearance/langs/en_US.json b/app/appearance/langs/en_US.json
index 97478c4783..20490008ac 100644
--- a/app/appearance/langs/en_US.json
+++ b/app/appearance/langs/en_US.json
@@ -968,7 +968,7 @@
"fileTree18": "Allows creation of sub-documents deeper than 7 levels",
"fileTree19": "Some operating systems have technical limitations that may prevent manual copying of workspace data after creating sub-documents greater than 7 levels",
"fileTree20": "Save with a single line",
- "fileTree21": "After enabling, the single-line JSON format will be used when saving .sy files, which can reduce the file size by about 30% and improve read and write efficiency by 50%",
+ "fileTree21": "After enabling, the single-line JSON format will be used when saving .sy docs and database .json files, which can reduce the file size by about 30% and improve read and write efficiency by 50%",
"export11": "Content handling method of content ref block when exporting",
"export12": "Content handling method of content embed block when exporting",
"export13": "Anchor text wrapping symbol",
diff --git a/app/appearance/langs/es_ES.json b/app/appearance/langs/es_ES.json
index 077fcd39bb..1975f80afc 100644
--- a/app/appearance/langs/es_ES.json
+++ b/app/appearance/langs/es_ES.json
@@ -968,7 +968,7 @@
"fileTree18": "Permite la creación de subdocumentos de más de 7 niveles",
"fileTree19": "Algunos sistemas operativos tienen limitaciones técnicas que pueden impedir la copia manual de los datos del espacio de trabajo después de crear subdocumentos de más de 7 niveles",
"fileTree20": "Guardar con una sola línea",
- "fileTree21": "Después de habilitarlo, se usará un formato JSON de una sola línea al guardar archivos .sy, lo que puede reducir el tamaño del archivo en aproximadamente un 30 % y mejorar la eficiencia de lectura y escritura en un 50 %",
+ "fileTree21": "Después de habilitarlo, se utilizará el formato JSON de una sola línea al guardar documentos .sy y archivos .json de bases de datos, lo que puede reducir el tamaño del archivo en aproximadamente un 30 % y mejorar la eficiencia de lectura y escritura en un 50 %.",
"export11": "Método de manejo de contenido del bloque de referencia de contenido al exportar",
"export12": "Método de manejo de contenido del bloque de incrustación de contenido al exportar",
"export13": "Símbolo de envoltura de texto ancla",
diff --git a/app/appearance/langs/fr_FR.json b/app/appearance/langs/fr_FR.json
index 287d51d00b..f3c681ae3c 100644
--- a/app/appearance/langs/fr_FR.json
+++ b/app/appearance/langs/fr_FR.json
@@ -968,7 +968,7 @@
"fileTree18": "Permet la création de sous-documents de plus de 7 niveaux",
"fileTree19": "Certains systèmes d'exploitation ont des limitations techniques qui peuvent empêcher la copie manuelle des données de l'espace de travail après la création de sous-documents supérieurs à 7 niveaux",
"fileTree20": "Enregistrer avec une seule ligne",
- "fileTree21": "Après l'activation, un format JSON à une seule ligne sera utilisé lors de l'enregistrement des fichiers .sy, ce qui peut réduire la taille du fichier d'environ 30 % et améliorer l'efficacité de lecture et d'écriture de 50 %",
+ "fileTree21": "Après activation, le format JSON sur une seule ligne sera utilisé lors de l'enregistrement des documents .sy et des fichiers .json de base de données, ce qui peut réduire la taille du fichier d'environ 30 % et améliorer l'efficacité de lecture et d'écriture de 50 %",
"export11": "Traitement du contenu des blocs de référence lors de l'exportation",
"export12": "Gestion du contenu des blocs intégrés lors de l'exportation",
"export13": "Symbole d'enveloppement du texte d'ancrage",
diff --git a/app/appearance/langs/zh_CHT.json b/app/appearance/langs/zh_CHT.json
index 8fc2c48aab..8ea9e21771 100644
--- a/app/appearance/langs/zh_CHT.json
+++ b/app/appearance/langs/zh_CHT.json
@@ -968,7 +968,7 @@
"fileTree18": "允許建立深度大於 7 層的子文檔",
"fileTree19": "一些操作系統存在技術限制導致建立大於 7 層的子文檔後可能無法正常手動複製工作空間資料",
"fileTree20": "使用單行保存",
- "fileTree21": "啟用後保存 .sy 文件時將使用單行 JSON 格式,大約能減少 30% 文件大小並提升 50% 讀寫效率",
+ "fileTree21": "啟用後儲存 .sy 文件和資料庫 .json 時將使用單行 JSON 格式,大約能減少 30% 檔案大小並提升 50% 讀寫效率",
"export11": "匯出時關於引用塊內容的處理方式",
"export12": "匯出時關於嵌入塊內容的處理方式",
"export13": "錨文字包裹符號",
diff --git a/app/appearance/langs/zh_CN.json b/app/appearance/langs/zh_CN.json
index fb3055ccce..56ae864caa 100644
--- a/app/appearance/langs/zh_CN.json
+++ b/app/appearance/langs/zh_CN.json
@@ -968,7 +968,7 @@
"fileTree18": "允许创建深度大于 7 层的子文档",
"fileTree19": "一些操作系统存在技术限制导致创建大于 7 层的子文档后可能无法正常手动复制工作空间数据",
"fileTree20": "使用单行保存",
- "fileTree21": "启用后保存 .sy 文件时将使用单行 JSON 格式,大约能减少 30% 文件大小并提升 50% 读写效率",
+ "fileTree21": "启用后保存 .sy 文档和数据库 .json 时将使用单行 JSON 格式,大约能减少 30% 文件大小并提升 50% 读写效率",
"export11": "导出时关于引用块内容的处理方式",
"export12": "导出时关于嵌入块内容的处理方式",
"export13": "锚文本包裹符号",
diff --git a/kernel/av/av.go b/kernel/av/av.go
index 8cb77e8f87..7abddfdd2e 100644
--- a/kernel/av/av.go
+++ b/kernel/av/av.go
@@ -468,7 +468,12 @@ func SaveAttributeView(av *AttributeView) (err error) {
}
}
- data, err := gulu.JSON.MarshalJSON(av)
+ var data []byte
+ if util.UseSingleLineSave {
+ data, err = gulu.JSON.MarshalJSON(av)
+ } else {
+ data, err = gulu.JSON.MarshalIndentJSON(av, "", "\t")
+ }
if nil != err {
logging.LogErrorf("marshal attribute view [%s] failed: %s", av.ID, err)
return
diff --git a/kernel/conf/filetree.go b/kernel/conf/filetree.go
index ee9dfc3531..86f4ce1f50 100644
--- a/kernel/conf/filetree.go
+++ b/kernel/conf/filetree.go
@@ -30,7 +30,7 @@ type FileTree struct {
AllowCreateDeeper bool `json:"allowCreateDeeper"` // 允许创建超过 7 层深度的子文档
RemoveDocWithoutConfirm bool `json:"removeDocWithoutConfirm"` // 删除文档时是否不需要确认
CloseTabsOnStart bool `json:"closeTabsOnStart"` // 启动时关闭所有页签
- UseSingleLineSave bool `json:"useSingleLineSave"` // 使用单行保存 .sy 文件
+ UseSingleLineSave bool `json:"useSingleLineSave"` // 使用单行保存文档 .sy 和属性视图 .json
Sort int `json:"sort"` // 排序方式
}