diff --git a/app/src/config/exportConfig.ts b/app/src/config/exportConfig.ts index 42a9426da..3ee90a9e9 100644 --- a/app/src/config/exportConfig.ts +++ b/app/src/config/exportConfig.ts @@ -1,7 +1,7 @@ import {fetchPost} from "../util/fetch"; /// #if !BROWSER import {afterExport} from "../protyle/export/util"; -import { ipcRenderer } from "electron"; +import {ipcRenderer} from "electron"; import * as path from "path"; /// #endif import {isBrowser} from "../util/functions"; @@ -180,27 +180,26 @@ export const exportConfig = { }); } }); - exportConfig.element.querySelector("#exportData").addEventListener("click", async () => { + exportConfig.element.querySelector("#exportData").addEventListener("click", async () => { /// #if BROWSER fetchPost("/api/export/exportData", {}, response => { window.location.href = response.data.zip; }); /// #else - const filePaths = await ipcRenderer.invoke(Constants.SIYUAN_GET,{ + const result = await ipcRenderer.invoke(Constants.SIYUAN_GET, { cmd: "showOpenDialog", title: window.siyuan.languages.export + " " + "Data", properties: ["createDirectory", "openDirectory"], }); - if (filePaths && 0 < filePaths.length) { - const savePath = filePaths[0]; - const msgId = showMessage(window.siyuan.languages.exporting, -1); - fetchPost("/api/export/exportDataInFolder", { - folder: savePath, - }, response => { - afterExport(path.join(savePath, response.data.name), msgId); - }); + if (result.canceled || result.filePaths.length === 0) { + return; } - + const msgId = showMessage(window.siyuan.languages.exporting, -1); + fetchPost("/api/export/exportDataInFolder", { + folder: result.filePaths[0], + }, response => { + afterExport(path.join(result.filePaths[0], response.data.name), msgId); + }); /// #endif }); /// #if !BROWSER @@ -211,7 +210,7 @@ export const exportConfig = { }); const pandocBinElement = exportConfig.element.querySelector("#pandocBin") as HTMLInputElement; pandocBinElement.addEventListener("click", async () => { - const localPath = await ipcRenderer.invoke(Constants.SIYUAN_GET,{ + const localPath = await ipcRenderer.invoke(Constants.SIYUAN_GET, { cmd: "showOpenDialog", defaultPath: window.siyuan.config.system.homeDir, properties: ["openFile"], diff --git a/app/src/editor/util.ts b/app/src/editor/util.ts index 3b046729f..acc2d7af9 100644 --- a/app/src/editor/util.ts +++ b/app/src/editor/util.ts @@ -173,11 +173,10 @@ export const openFile = async (options: IOpenFileOptions) => { // https://github.com/siyuan-note/siyuan/issues/7491 let hasMatch = false; const optionsClone = Object.assign({}, options); - delete optionsClone.app; - delete optionsClone.afterOpen; + delete optionsClone.app; // 防止 JSON.stringify 时产生递归 hasMatch = await ipcRenderer.invoke(Constants.SIYUAN_GET, { cmd: Constants.SIYUAN_OPEN_FILE, - options: optionsClone, + options: JSON.stringify(optionsClone), }); if (hasMatch) { if (options.afterOpen) { diff --git a/app/src/plugin/loader.ts b/app/src/plugin/loader.ts index bf578f979..1ead63d25 100644 --- a/app/src/plugin/loader.ts +++ b/app/src/plugin/loader.ts @@ -30,6 +30,7 @@ export const loadPlugins = async (app: App) => { css += item.css || "" + "\n"; }); const styleElement = document.createElement("style"); + styleElement.id = "pluginsStyle" styleElement.textContent = css; document.head.append(styleElement); };