Skip to content

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

:art: fix https://github.com/siyuan-note/siyuan/issues/6797

Vanessafb8300a8a399
diff --git a/app/src/protyle/export/index.ts b/app/src/protyle/export/index.ts
index c6e83dadc2..5015f8aeca 100644
--- a/app/src/protyle/export/index.ts
+++ b/app/src/protyle/export/index.ts
@@ -488,7 +488,10 @@ const getExportPath = (option: { type: string, id: string }, removeAssets?: bool
} else if (option.type === "word") {
url = "/api/export/exportDocx";
}
- let savePath = result.filePaths[0].endsWith(response.data.rootTitle) ? result.filePaths[0] : path.join(result.filePaths[0], replaceLocalPath(response.data.rootTitle));
+ let savePath = result.filePaths[0];
+ if (option.type !== "word" && !savePath.endsWith(response.data.rootTitle)) {
+ savePath = path.join(savePath, replaceLocalPath(response.data.rootTitle));
+ }
savePath = savePath.trim();
fetchPost(url, {
id: option.id,
diff --git a/app/src/util/onGetConfig.ts b/app/src/util/onGetConfig.ts
index f13422bf58..599e86eb59 100644
--- a/app/src/util/onGetConfig.ts
+++ b/app/src/util/onGetConfig.ts
@@ -27,9 +27,9 @@ import {openHistory} from "./history";
import {initStatus} from "../layout/status";
import {syncGuide} from "../sync/syncGuide";
import {showMessage} from "../dialog/message";
-import {replaceLocalPath} from "../editor/rename";
import {editor} from "../config/editor";
import {goBack, goForward} from "./backForward";
+import {replaceLocalPath} from "../editor/rename";
const matchKeymap = (keymap: Record<string, IKeymapItem>, key1: "general" | "editor", key2?: "general" | "insert" | "heading" | "list" | "table") => {
if (key1 === "general") {
@@ -372,7 +372,6 @@ const initWindow = () => {
return;
}
const msgId = showMessage(window.siyuan.languages.exporting, -1);
- const filePath = result.filePaths[0].endsWith(ipcData.rootTitle) ? result.filePaths[0] : path.join(result.filePaths[0], replaceLocalPath(ipcData.rootTitle));
localStorage.setItem(Constants.LOCAL_EXPORTPDF, JSON.stringify(Object.assign(ipcData.pdfOptions, {
removeAssets: ipcData.removeAssets,
keepFold: ipcData.keepFold
@@ -383,9 +382,9 @@ const initWindow = () => {
id: ipcData.rootId,
pdf: true,
removeAssets: ipcData.removeAssets,
- savePath: filePath
+ savePath: result.filePaths[0]
}, () => {
- const pdfFilePath = path.join(filePath, path.basename(filePath) + ".pdf");
+ const pdfFilePath = path.join(result.filePaths[0], replaceLocalPath(ipcData.rootTitle) + ".pdf");
fs.writeFileSync(pdfFilePath, pdfData);
destroyPrintWindow();
fetchPost("/api/export/addPDFOutline", {
@@ -413,7 +412,7 @@ const initWindow = () => {
});
});
};
- removePromise(path.join(filePath, "assets"));
+ removePromise(path.join(result.filePaths[0], "assets"));
}
});
});