This commit is contained in:
Vanessa 2023-10-10 20:40:38 +08:00
parent 7aa4aacfc3
commit 0e5cae3001
3 changed files with 15 additions and 16 deletions

View File

@ -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"],

View File

@ -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) {

View File

@ -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);
};