From fb8300a8a3995246075ea1f02ffac156723ddb23 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Sat, 10 Dec 2022 16:26:12 +0800 Subject: [PATCH] :art: fix https://github.com/siyuan-note/siyuan/issues/6797 --- app/src/protyle/export/index.ts | 5 ++++- app/src/util/onGetConfig.ts | 9 ++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/src/protyle/export/index.ts b/app/src/protyle/export/index.ts index c6e83dadc..5015f8aec 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 f13422bf5..599e86eb5 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, 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")); } }); });