Skip to content

Commit

Permalink
💄 fix #9206
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed Oct 10, 2023
1 parent 7aa4aac commit 0e5cae3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
25 changes: 12 additions & 13 deletions app/src/config/exportConfig.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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
Expand All @@ -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"],
Expand Down
5 changes: 2 additions & 3 deletions app/src/editor/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions app/src/plugin/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
Expand Down

0 comments on commit 0e5cae3

Please sign in to comment.