mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-16 00:50:56 +08:00
This commit is contained in:
parent
7aa4aacfc3
commit
0e5cae3001
@ -1,7 +1,7 @@
|
|||||||
import {fetchPost} from "../util/fetch";
|
import {fetchPost} from "../util/fetch";
|
||||||
/// #if !BROWSER
|
/// #if !BROWSER
|
||||||
import {afterExport} from "../protyle/export/util";
|
import {afterExport} from "../protyle/export/util";
|
||||||
import { ipcRenderer } from "electron";
|
import {ipcRenderer} from "electron";
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
/// #endif
|
/// #endif
|
||||||
import {isBrowser} from "../util/functions";
|
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
|
/// #if BROWSER
|
||||||
fetchPost("/api/export/exportData", {}, response => {
|
fetchPost("/api/export/exportData", {}, response => {
|
||||||
window.location.href = response.data.zip;
|
window.location.href = response.data.zip;
|
||||||
});
|
});
|
||||||
/// #else
|
/// #else
|
||||||
const filePaths = await ipcRenderer.invoke(Constants.SIYUAN_GET,{
|
const result = await ipcRenderer.invoke(Constants.SIYUAN_GET, {
|
||||||
cmd: "showOpenDialog",
|
cmd: "showOpenDialog",
|
||||||
title: window.siyuan.languages.export + " " + "Data",
|
title: window.siyuan.languages.export + " " + "Data",
|
||||||
properties: ["createDirectory", "openDirectory"],
|
properties: ["createDirectory", "openDirectory"],
|
||||||
});
|
});
|
||||||
if (filePaths && 0 < filePaths.length) {
|
if (result.canceled || result.filePaths.length === 0) {
|
||||||
const savePath = filePaths[0];
|
return;
|
||||||
const msgId = showMessage(window.siyuan.languages.exporting, -1);
|
|
||||||
fetchPost("/api/export/exportDataInFolder", {
|
|
||||||
folder: savePath,
|
|
||||||
}, response => {
|
|
||||||
afterExport(path.join(savePath, response.data.name), msgId);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
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
|
/// #endif
|
||||||
});
|
});
|
||||||
/// #if !BROWSER
|
/// #if !BROWSER
|
||||||
@ -211,7 +210,7 @@ export const exportConfig = {
|
|||||||
});
|
});
|
||||||
const pandocBinElement = exportConfig.element.querySelector("#pandocBin") as HTMLInputElement;
|
const pandocBinElement = exportConfig.element.querySelector("#pandocBin") as HTMLInputElement;
|
||||||
pandocBinElement.addEventListener("click", async () => {
|
pandocBinElement.addEventListener("click", async () => {
|
||||||
const localPath = await ipcRenderer.invoke(Constants.SIYUAN_GET,{
|
const localPath = await ipcRenderer.invoke(Constants.SIYUAN_GET, {
|
||||||
cmd: "showOpenDialog",
|
cmd: "showOpenDialog",
|
||||||
defaultPath: window.siyuan.config.system.homeDir,
|
defaultPath: window.siyuan.config.system.homeDir,
|
||||||
properties: ["openFile"],
|
properties: ["openFile"],
|
||||||
|
@ -173,11 +173,10 @@ export const openFile = async (options: IOpenFileOptions) => {
|
|||||||
// https://github.com/siyuan-note/siyuan/issues/7491
|
// https://github.com/siyuan-note/siyuan/issues/7491
|
||||||
let hasMatch = false;
|
let hasMatch = false;
|
||||||
const optionsClone = Object.assign({}, options);
|
const optionsClone = Object.assign({}, options);
|
||||||
delete optionsClone.app;
|
delete optionsClone.app; // 防止 JSON.stringify 时产生递归
|
||||||
delete optionsClone.afterOpen;
|
|
||||||
hasMatch = await ipcRenderer.invoke(Constants.SIYUAN_GET, {
|
hasMatch = await ipcRenderer.invoke(Constants.SIYUAN_GET, {
|
||||||
cmd: Constants.SIYUAN_OPEN_FILE,
|
cmd: Constants.SIYUAN_OPEN_FILE,
|
||||||
options: optionsClone,
|
options: JSON.stringify(optionsClone),
|
||||||
});
|
});
|
||||||
if (hasMatch) {
|
if (hasMatch) {
|
||||||
if (options.afterOpen) {
|
if (options.afterOpen) {
|
||||||
|
@ -30,6 +30,7 @@ export const loadPlugins = async (app: App) => {
|
|||||||
css += item.css || "" + "\n";
|
css += item.css || "" + "\n";
|
||||||
});
|
});
|
||||||
const styleElement = document.createElement("style");
|
const styleElement = document.createElement("style");
|
||||||
|
styleElement.id = "pluginsStyle"
|
||||||
styleElement.textContent = css;
|
styleElement.textContent = css;
|
||||||
document.head.append(styleElement);
|
document.head.append(styleElement);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user