An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: `新建文档名模板` 改为 `新建文档存放位置` 并支持设置路径 https://github.com/siyuan-note/siyuan/issues/4494
Liang Ding551cbb8c1878
diff --git a/app/appearance/langs/en_US.json b/app/appearance/langs/en_US.jsonindex c2ef012b80..982d4abc47 100644--- a/app/appearance/langs/en_US.json+++ b/app/appearance/langs/en_US.json@@ -655,14 +655,14 @@"fileTree3": "No confirmation required when deleting documents","fileTree4": "If not enabled, a confirmation box will pop up every time you delete a document","fileTree5": "Ref create doc save location",- "fileTree6": "When using <code class='fn__code'>((</code>, the save path of the new document (for example, <code class='fn__code'>/folder1/{{now | date \"20060102150405\"}}/</code>, the relative path of the current doc is used if it does not start with /)",+ "fileTree6": "When using <code class='fn__code'>((</code>, the save path of the new document (for example, <code class='fn__code'>/folder1/{{now | date \"20060102150405\"}}/</code>, the relative path of the current doc is used if it does not start with <code class='fn__code'>/</code>)","fileTree7": "Open in the current tab","fileTree8": "The newly opened document tab will replace the unmodified tab","fileTree9": "Close all tabs at startup","fileTree10": "After enabling, the unpinned tabs that were opened the last time will be automatically closed every time the interface is started","fileTree11": "New daily note",- "fileTree12": "New doc name template",- "fileTree13": "The template snippet is used by default when creating a new doc for naming (for example <code class='fn__code'>{{now | date \"20060102150405\"}}</code>)",+ "fileTree12": "New document save location",+ "fileTree13": "When using <code class='fn__code'>Ctrl+N</code>, the save path of the new document (for example, <code class='fn__code'>/folder1/{{now | date \"20060102150405\"}}</code>)","fileTree14": "Save path (support date format template variables, such as <code class='fn__code'>/Daily Notes/{{now | date \"2006/01\"}}/{{now | date \"2006-01-02\"}}</code>)","fileTree15": "Template path (for example, <code class='fn__code'>dailynote.md</code>, the file needs to be placed under the workspace/data/templates/)","fileTree16": "Maximum number to list",diff --git a/app/appearance/langs/es_ES.json b/app/appearance/langs/es_ES.jsonindex 6d3d4ed407..54ec37a430 100644--- a/app/appearance/langs/es_ES.json+++ b/app/appearance/langs/es_ES.json@@ -655,14 +655,14 @@"fileTree3": "No se requiere confirmación al borrar documentos","fileTree4": "Si no se activa, aparecerá un cuadro de confirmación cada vez que se elimine un documento","fileTree5": "Ref crear ubicación de guardado de documentos",- "fileTree6": "Al utilizar <code class='fn__code'>((</code>, la ruta de guardado del nuevo documento (por ejemplo, <code class='fn__code'>/carpeta1/{{now | date \"20060102150405\"}}/</code>, se utiliza la ruta relativa del documento actual si no empieza por /)",+ "fileTree6": "Al utilizar <code class='fn__code'>((</code>, la ruta de guardado del nuevo documento (por ejemplo, <code class='fn__code'>/carpeta1/{{now | date \"20060102150405\"}}/</code>, se utiliza la ruta relativa del documento actual si no empieza por <code class='fn__code'>/</code>)","fileTree7": "Abrir en la pestaña actual","fileTree8": "La pestaña del documento recién abierto sustituirá a la pestaña no modificada","fileTree9": "Cerrar todas las pestañas al inicio","fileTree10": "Cuando está habilitado, las pestañas no fijadas que se abrieron la última vez se cerrarán automáticamente cada vez que se inicie la interfaz","fileTree11": "Nueva nota diaria",- "fileTree12": "Nueva pantilla de nombre de documento",- "fileTree13": "El fragmento de plantilla se utiliza por defecto cuando se crea un nuevo documento para nombrar (por ejemplo <code class='fn__code'>{{now | date \"20060102150405\"}}</code>)",+ "fileTree12": "Nueva ubicación para guardar el documento",+ "fileTree13": "Al usar <code class='fn__code'>Ctrl+N</code>, la ruta de guardado del nuevo documento (por ejemplo, <code class='fn__code'>/folder1/{{now | date \"20060102150405\"}}</código>)","fileTree14": "Ruta de guardado (admite variables de plantilla de formato de fecha, como <code class='fn__code'>/Notas del día/{{now | date \"2006/01\"}}/{{now | date \"2006-01-02\"}}</code>)","fileTree15": "Ruta de la plantilla (por ejemplo, <code class='fn__code'>dailynote.md</code>, el archivo debe colocarse en el espacio de trabajo/data/templates/)","fileTree16": "Número máximo a listar",diff --git a/app/appearance/langs/fr_FR.json b/app/appearance/langs/fr_FR.jsonindex dd0ec790a0..5ae3789730 100644--- a/app/appearance/langs/fr_FR.json+++ b/app/appearance/langs/fr_FR.json@@ -655,14 +655,14 @@"fileTree3": "Aucune confirmation requise lors de la suppression de documents","fileTree4": "Si non activé, une boîte de confirmation apparaîtra à chaque fois que vous supprimerez un document","fileTree5": "Référence créer doc enregistrer emplacement",- "fileTree6": "Lors de l'utilisation de <code class='fn__code'>((</code>, le chemin d'enregistrement du nouveau document (par exemple, <code class='fn__code'>/dossier1/{{now | date \"20060102150405\"}}/</code>, le chemin relatif du doc actuel est utilisé s'il ne commence pas par /).",+ "fileTree6": "Lors de l'utilisation de <code class='fn__code'>((</code>, le chemin d'enregistrement du nouveau document (par exemple, <code class='fn__code'>/dossier1/{{now | date \"20060102150405\"}}/</code>, le chemin relatif du doc actuel est utilisé s'il ne commence pas par <code class='fn__code'>/</code>).","fileTree7": "Ouvrir dans l'Onglet actuel","fileTree8": "L'onglet du document nouvellement ouvert remplacera l'Onglet non modifié.","fileTree9": "Fermer tous les onglets au démarrage","fileTree10": "Lorsqu'il est activé, les onglets non épinglés qui ont été ouverts la dernière fois seront automatiquement fermés à chaque démarrage de l'interface","fileTree11": "Nouvelle note quotidienne",- "fileTree12": "Nouveau template de nom de document",- "fileTree13": "L'extrait de modèle est utilisé par défaut lors de la création d'un nouveau document pour le nommage (par exemple <code class='fn__code'>{{maintenant | date \"20060102150405\"}}</code>).",+ "fileTree12": "Emplacement de sauvegarde du nouveau document",+ "fileTree13": "Lorsque vous utilisez <code class='fn__code'>Ctrl+N</code>, le chemin d'enregistrement du nouveau document (par exemple, <code class='fn__code'>/folder1/{{now | date \"20060102150405\"}}</code>)","fileTree14": "Chemin d'enregistrement (prise en charge des variables de modèle de format de date, telles que <code class='fn__code'>/Notes quotidiennes/{{mais | date \"2006/01\"}}/{{mais | date \"2006-01-02\"}}</code>)","fileTree15": "Chemin du modèle (par exemple, <code class='fn__code'>dailynote.md</code>, le fichier doit être placé sous \"l'espace de travail/data/templates/\")","fileTree16": "Nombre maximum à lister",diff --git a/app/appearance/langs/zh_CHT.json b/app/appearance/langs/zh_CHT.jsonindex fa0e42d445..a29ca4fb44 100644--- a/app/appearance/langs/zh_CHT.json+++ b/app/appearance/langs/zh_CHT.json@@ -655,14 +655,14 @@"fileTree3": "刪除文檔時不需要確認","fileTree4": "不啟用時每次刪除文檔都會彈出確認框","fileTree5": "塊引新建文檔存放位置",- "fileTree6": "使用 <code class='fn__code'>((</code> 時新建文檔的存放路徑(例如 <code class='fn__code'>/folder1/{{now | date \"20060102150405\"}}/</code>,不以 / 開頭則使用當前文檔相對路徑)",+ "fileTree6": "使用 <code class='fn__code'>((</code> 時新建文檔的存放路徑(例如 <code class='fn__code'>/folder1/{{now | date \"20060102150405\"}}/</code>,不以 <code class='fn__code'>/</code> 開頭則使用當前文檔相對路徑)","fileTree7": "在當前分頁中打開","fileTree8": "新打開的文檔分頁將會替換沒有修改過的分頁","fileTree9": "啟動時關閉所有頁籤","fileTree10": "啟用後每次啟動界面後都會自動關閉上次打開未釘住的頁籤","fileTree11": "新建日記",- "fileTree12": "新建文檔名範本",- "fileTree13": "使用該範本片段進行命名(例如<code class='fn__code'>{{now | date \"20060102150405\"}}</code>)",+ "fileTree12": "新建文檔存放位置",+ "fileTree13": "使用 <code class='fn__code'>Ctrl+N</code> 時新建文檔的存放路徑(例如 <code class='fn__code'>/folder1/{{now | date \"20060102150405\"}}</code>)","fileTree14": "存放路徑(可使用日期格式範本變數,例如 <code class='fn__code'>/日記/{{now | date \"2006/01\"}}/{{now | date \"2006-01-02\"}}</code>)","fileTree15": "範本路徑(例如 <code class='fn__code'>dailynote.md</code>,需要將該檔放置於工作空間/data/templates/ 下)","fileTree16": "最大列出數量",diff --git a/app/appearance/langs/zh_CN.json b/app/appearance/langs/zh_CN.jsonindex e9dcdc7e2e..5ffcf143c6 100644--- a/app/appearance/langs/zh_CN.json+++ b/app/appearance/langs/zh_CN.json@@ -655,14 +655,14 @@"fileTree3": "删除文档时不需要确认","fileTree4": "不启用时每次删除文档都会弹出确认框","fileTree5": "块引新建文档存放位置",- "fileTree6": "使用 <code class='fn__code'>((</code> 时新建文档的存放路径(例如 <code class='fn__code'>/folder1/{{now | date \"20060102150405\"}}/</code>,不以 / 开头则使用当前文档相对路径)",+ "fileTree6": "使用 <code class='fn__code'>((</code> 时新建文档的存放路径(例如 <code class='fn__code'>/folder1/{{now | date \"20060102150405\"}}/</code>,不以 <code class='fn__code'>/</code> 开头则使用当前文档相对路径)","fileTree7": "在当前页签中打开","fileTree8": "新打开的文档页签将会替换没有修改过的页签","fileTree9": "启动时关闭所有页签","fileTree10": "启用后每次启动界面后都会自动关闭上次打开未钉住的页签","fileTree11": "新建日记",- "fileTree12": "新建文档名模板",- "fileTree13": "使用该模板片段进行命名(例如 <code class='fn__code'>{{now | date \"20060102150405\"}}</code>)",+ "fileTree12": "新建文档存放位置",+ "fileTree13": "使用 <code class='fn__code'>Ctrl+N</code> 时新建文档的存放路径(例如 <code class='fn__code'>/folder1/{{now | date \"20060102150405\"}}</code>)","fileTree14": "存放路径(可使用日期格式模板变量,例如 <code class='fn__code'>/日记/{{now | date \"2006/01\"}}/{{now | date \"2006-01-02\"}}</code>)","fileTree15": "模板路径(例如 <code class='fn__code'>dailynote.md</code>,需要将该文件放置于工作空间/data/templates/ 下)","fileTree16": "最大列出数量",diff --git a/app/src/config/fileTree.ts b/app/src/config/fileTree.tsindex 26b2e70569..058246675f 100644--- a/app/src/config/fileTree.ts+++ b/app/src/config/fileTree.ts@@ -49,7 +49,7 @@ export const fileTree = {<div class="b3-label__text">${window.siyuan.languages.fileTree13}</div></div><span class="fn__space"></span>- <input class="b3-text-field fn__flex-center fn__size200" id="createDocNameTemplate" value="">+ <input class="b3-text-field fn__flex-center fn__size200" id="docCreateSavePath" value=""></label><label class="b3-label fn__flex config__item"><div class="fn__flex-1">@@ -92,7 +92,7 @@ export const fileTree = {sort: window.siyuan.config.fileTree.sort,alwaysSelectOpenedFile: (fileTree.element.querySelector("#alwaysSelectOpenedFile") as HTMLInputElement).checked,refCreateSavePath: (fileTree.element.querySelector("#refCreateSavePath") as HTMLInputElement).value,- createDocNameTemplate: (fileTree.element.querySelector("#createDocNameTemplate") as HTMLInputElement).value,+ docCreateSavePath: (fileTree.element.querySelector("#docCreateSavePath") as HTMLInputElement).value,openFilesUseCurrentTab: (fileTree.element.querySelector("#openFilesUseCurrentTab") as HTMLInputElement).checked,closeTabsOnStart: (fileTree.element.querySelector("#closeTabsOnStart") as HTMLInputElement).checked,allowCreateDeeper: (fileTree.element.querySelector("#allowCreateDeeper") as HTMLInputElement).checked,@@ -104,7 +104,7 @@ export const fileTree = {});},bindEvent: () => {- (fileTree.element.querySelector("#createDocNameTemplate") as HTMLInputElement).value = window.siyuan.config.fileTree.createDocNameTemplate;+ (fileTree.element.querySelector("#docCreateSavePath") as HTMLInputElement).value = window.siyuan.config.fileTree.docCreateSavePath;(fileTree.element.querySelector("#refCreateSavePath") as HTMLInputElement).value = window.siyuan.config.fileTree.refCreateSavePath;fileTree.element.querySelectorAll("input").forEach((item) => {item.addEventListener("change", () => {diff --git a/app/src/layout/dock/Files.ts b/app/src/layout/dock/Files.tsindex 8962ddad74..cf69566532 100644--- a/app/src/layout/dock/Files.ts+++ b/app/src/layout/dock/Files.ts@@ -950,7 +950,7 @@ class="b3-list-item b3-list-item--hide-action" data-path="${item.path}">sort: window.siyuan.config.fileTree.sort,alwaysSelectOpenedFile: window.siyuan.config.fileTree.alwaysSelectOpenedFile,refCreateSavePath: window.siyuan.config.fileTree.refCreateSavePath,- createDocNameTemplate: window.siyuan.config.fileTree.createDocNameTemplate,+ docCreateSavePath: window.siyuan.config.fileTree.docCreateSavePath,openFilesUseCurrentTab: window.siyuan.config.fileTree.openFilesUseCurrentTab,maxListCount: window.siyuan.config.fileTree.maxListCount,}, () => {diff --git a/app/src/menus/onGetnotebookconf.ts b/app/src/menus/onGetnotebookconf.tsindex 8e18b5303f..de17248986 100644--- a/app/src/menus/onGetnotebookconf.ts+++ b/app/src/menus/onGetnotebookconf.ts@@ -10,7 +10,7 @@ export const onGetnotebookconf = (data: {box: string,conf: {refCreateSavePath: string- createDocNameTemplate: string+ docCreateSavePath: stringdailyNoteSavePath: stringdailyNoteTemplatePath: string}@@ -24,7 +24,7 @@ export const onGetnotebookconf = (data: {<div class="fn__hr"></div><div class="b3-label__text">${window.siyuan.languages.fileTree13}</div><div class="fn__hr"></div>- <input class="b3-text-field fn__flex-center fn__block" id="createDocNameTemplate" value="">+ <input class="b3-text-field fn__flex-center fn__block" id="docCreateSavePath" value=""></div><div class="b3-label">${window.siyuan.languages.fileTree5}@@ -65,8 +65,8 @@ export const onGetnotebookconf = (data: {});const dailyNoteSavePathElement = contentElement.querySelector("#dailyNoteSavePath") as HTMLInputElement;dailyNoteSavePathElement.value = data.conf.dailyNoteSavePath;- const createDocNameTemplateElement = contentElement.querySelector("#createDocNameTemplate") as HTMLInputElement;- createDocNameTemplateElement.value = data.conf.createDocNameTemplate;+ const docCreateSavePathElement = contentElement.querySelector("#docCreateSavePath") as HTMLInputElement;+ docCreateSavePathElement.value = data.conf.docCreateSavePath;const refCreateSavePathElement = contentElement.querySelector("#refCreateSavePath") as HTMLInputElement;refCreateSavePathElement.value = data.conf.refCreateSavePath;const dailyNoteTemplatePathElement = contentElement.querySelector("#dailyNoteTemplatePath") as HTMLInputElement;@@ -77,7 +77,7 @@ export const onGetnotebookconf = (data: {notebook: data.box,conf: {refCreateSavePath: refCreateSavePathElement.value,- createDocNameTemplate: createDocNameTemplateElement.value,+ docCreateSavePath: docCreateSavePathElement.value,dailyNoteSavePath: dailyNoteSavePathElement.value,dailyNoteTemplatePath: dailyNoteTemplatePathElement.value,}diff --git a/app/src/mobile/util/MobileFiles.ts b/app/src/mobile/util/MobileFiles.tsindex 3957fb157b..928fa4c060 100644--- a/app/src/mobile/util/MobileFiles.ts+++ b/app/src/mobile/util/MobileFiles.ts@@ -219,7 +219,7 @@ export class MobileFiles extends Model {sort: window.siyuan.config.fileTree.sort,alwaysSelectOpenedFile: window.siyuan.config.fileTree.alwaysSelectOpenedFile,refCreateSavePath: window.siyuan.config.fileTree.refCreateSavePath,- createDocNameTemplate: window.siyuan.config.fileTree.createDocNameTemplate,+ docCreateSavePath: window.siyuan.config.fileTree.docCreateSavePath,openFilesUseCurrentTab: window.siyuan.config.fileTree.openFilesUseCurrentTab,maxListCount: window.siyuan.config.fileTree.maxListCount,}, () => {diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.tsindex 1e8aae4e7b..65d7fd428a 100644--- a/app/src/types/index.d.ts+++ b/app/src/types/index.d.ts@@ -361,7 +361,7 @@ declare interface IFileTree {removeDocWithoutConfirm: booleanallowCreateDeeper: booleanrefCreateSavePath: string- createDocNameTemplate: string+ docCreateSavePath: stringsort: numbermaxOpenTabCount: numbermaxListCount: numberdiff --git a/kernel/api/filetree.go b/kernel/api/filetree.goindex ebb9cdd10d..bc54620600 100644--- a/kernel/api/filetree.go+++ b/kernel/api/filetree.go@@ -517,7 +517,7 @@ func lockFile(c *gin.Context) {}}-func getDocNameTemplate(c *gin.Context) {+func getDocCreateSavePath(c *gin.Context) {ret := gulu.Ret.NewResult()defer c.JSON(http.StatusOK, ret)@@ -528,22 +528,22 @@ func getDocNameTemplate(c *gin.Context) {notebook := arg["notebook"].(string)box := model.Conf.Box(notebook)- nameTemplate := model.Conf.FileTree.CreateDocNameTemplate+ docCreateSavePathTpl := model.Conf.FileTree.DocCreateSavePathif nil != box {- nameTemplate = box.GetConf().CreateDocNameTemplate+ docCreateSavePathTpl = box.GetConf().DocCreateSavePath}- if "" == nameTemplate {- nameTemplate = model.Conf.FileTree.CreateDocNameTemplate+ if "" == docCreateSavePathTpl {+ docCreateSavePathTpl = model.Conf.FileTree.DocCreateSavePath}- name, err := model.RenderGoTemplate(nameTemplate)+ path, err := model.RenderGoTemplate(docCreateSavePathTpl)if nil != err {ret.Code = -1ret.Msg = err.Error()return}ret.Data = map[string]interface{}{- "name": name,+ "path": path,}}diff --git a/kernel/api/router.go b/kernel/api/router.goindex 1afca1e148..0961fe81ee 100644--- a/kernel/api/router.go+++ b/kernel/api/router.go@@ -86,7 +86,7 @@ func ServeAPI(ginServer *gin.Engine) {ginServer.Handle("POST", "/api/filetree/searchDocs", model.CheckAuth, searchDocs)ginServer.Handle("POST", "/api/filetree/listDocsByPath", model.CheckAuth, listDocsByPath)ginServer.Handle("POST", "/api/filetree/getDoc", model.CheckAuth, getDoc)- ginServer.Handle("POST", "/api/filetree/getDocNameTemplate", model.CheckAuth, getDocNameTemplate)+ ginServer.Handle("POST", "/api/filetree/getDocCreateSavePath", model.CheckAuth, getDocCreateSavePath)ginServer.Handle("POST", "/api/filetree/getRefCreateSavePath", model.CheckAuth, getRefCreateSavePath)ginServer.Handle("POST", "/api/filetree/changeSort", model.CheckAuth, changeSort)ginServer.Handle("POST", "/api/filetree/lockFile", model.CheckAuth, lockFile)diff --git a/kernel/conf/box.go b/kernel/conf/box.goindex 1caa31166a..2108c78899 100644--- a/kernel/conf/box.go+++ b/kernel/conf/box.go@@ -22,8 +22,8 @@ type BoxConf struct {Sort int `json:"sort"` // 排序字段Icon string `json:"icon"` // 图标Closed bool `json:"closed"` // 是否处于关闭状态- RefCreateSavePath string `json:"refCreateSavePath"` // 块引时新建文档存储文件夹路径- CreateDocNameTemplate string `json:"createDocNameTemplate"` // 新建文档名模板+ RefCreateSavePath string `json:"refCreateSavePath"` // 块引时新建文档存储路径+ DocCreateSavePath string `json:"docCreateSavePath"` // 新建文档存储路径DailyNoteSavePath string `json:"dailyNoteSavePath"` // 新建日记存储路径DailyNoteTemplatePath string `json:"dailyNoteTemplatePath"` // 新建日记使用的模板路径}@@ -32,8 +32,6 @@ func NewBoxConf() *BoxConf {return &BoxConf{Name: "Untitled",Closed: true,- RefCreateSavePath: "",- CreateDocNameTemplate: "",DailyNoteSavePath: "/daily note/{{now | date \"2006/01\"}}/{{now | date \"2006-01-02\"}}",DailyNoteTemplatePath: "",}diff --git a/kernel/conf/filetree.go b/kernel/conf/filetree.goindex 1004430ef1..1e27de30f7 100644--- a/kernel/conf/filetree.go+++ b/kernel/conf/filetree.go@@ -23,8 +23,8 @@ import (type FileTree struct {AlwaysSelectOpenedFile bool `json:"alwaysSelectOpenedFile"` // 是否自动选中当前打开的文件OpenFilesUseCurrentTab bool `json:"openFilesUseCurrentTab"` // 在当前页签打开文件- RefCreateSavePath string `json:"refCreateSavePath"` // 块引时新建文档存储文件夹路径- CreateDocNameTemplate string `json:"createDocNameTemplate"` // 新建文档名模板+ RefCreateSavePath string `json:"refCreateSavePath"` // 块引时新建文档存储路径+ DocCreateSavePath string `json:"docCreateSavePath"` // 新建文档存储路径MaxListCount int `json:"maxListCount"` // 最大列出数量MaxOpenTabCount int `json:"maxOpenTabCount"` // 最大打开页签数量AllowCreateDeeper bool `json:"allowCreateDeeper"` // 允许创建超过 7 层深度的子文档@@ -39,7 +39,6 @@ func NewFileTree() *FileTree {AlwaysSelectOpenedFile: false,OpenFilesUseCurrentTab: false,Sort: util.SortModeCustom,- CreateDocNameTemplate: "",MaxListCount: 512,MaxOpenTabCount: 8,AllowCreateDeeper: false,