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: 导出 PDF 和 Word 时支持覆盖已有文件 https://github.com/siyuan-note/siyuan/issues/5309
Liang Dingc819b63fa725
diff --git a/app/src/protyle/export/index.ts b/app/src/protyle/export/index.tsindex 40a2775750..6326549a3b 100644--- a/app/src/protyle/export/index.ts+++ b/app/src/protyle/export/index.ts@@ -121,8 +121,30 @@ const getExportPath = (option: { type: string, id: string }, pdfOption?: PrintTolockFile(response.data);return;}++ let exportType = "HTML (SiYuan)"+ let extension = "html"+ switch (option.type) {+ case "htmlmd":+ exportType = "HTML (Markdown)";+ break;+ case "word":+ exportType = "Word .docx";+ extension = "docx";+ break;+ case "pdf":+ exportType = "PDF";+ extension = "pdf";+ break;+ }+dialog.showSaveDialog({- defaultPath: response.data.rootTitle,+ title: window.siyuan.languages.export + " " + exportType,+ defaultPath: response.data.rootTitle + "." + extension,+ filters: [{+ name: "Word",+ extensions: [extension]+ }],properties: ["showOverwriteConfirmation"],}).then((result: SaveDialogReturnValue) => {if (!result.canceled) {diff --git a/kernel/model/export.go b/kernel/model/export.goindex a70a2d5725..cda63d2260 100644--- a/kernel/model/export.go+++ b/kernel/model/export.go@@ -180,13 +180,17 @@ func ExportDocx(id, savePath string) (err error) {return errors.New(msg)}- if err = gulu.File.Copy(tmpDocxPath, filepath.Join(savePath, name+".docx")); nil != err {+ if 1 < strings.Count(savePath, filepath.Base(savePath)) {+ savePath = filepath.Dir(savePath)+ }++ if err = gulu.File.Copy(tmpDocxPath, savePath); nil != err {logging.LogErrorf("export docx failed: %s", err)return errors.New(fmt.Sprintf(Conf.Language(14), err))}tmpAssets := filepath.Join(tmpDir, "assets")if gulu.File.IsDir(tmpAssets) {- if err = gulu.File.Copy(tmpAssets, filepath.Join(savePath, "assets")); nil != err {+ if err = gulu.File.Copy(tmpAssets, filepath.Join(filepath.Dir(savePath), "assets")); nil != err {logging.LogErrorf("export docx failed: %s", err)return errors.New(fmt.Sprintf(Conf.Language(14), err))}@@ -199,6 +203,9 @@ func ExportMarkdownHTML(id, savePath string, docx bool) (name, dom string) {tree = exportTree(tree, true)name = path.Base(tree.HPath)+ if 1 < strings.Count(savePath, filepath.Base(savePath)) {+ savePath = filepath.Dir(savePath)+ }if err := os.MkdirAll(savePath, 0755); nil != err {logging.LogErrorf("mkdir [%s] failed: %s", savePath, err)@@ -283,6 +290,10 @@ func ExportHTML(id, savePath string, pdf bool) (name, dom string) {tree = exportTree(tree, true)name = path.Base(tree.Path)+ if 1 < strings.Count(savePath, filepath.Base(savePath)) {+ savePath = filepath.Dir(savePath)+ }+if err := os.MkdirAll(savePath, 0755); nil != err {logging.LogErrorf("mkdir [%s] failed: %s", savePath, err)return