';
} else if (timeout !== -1) { // -1 时需等待请求完成后手动关闭
- window.setTimeout(() => {
+ const timeoutId = window.setTimeout(() => {
hideMessage(id);
}, timeout);
+ messageHTML.replace("
{
export const exitSiYuan = () => {
fetchPost("/api/system/exit", {force: false}, (response) => {
if (response.code === 1) {
- showMessage(response.msg, response.data.closeTimeout, "error");
- const buttonElement = document.querySelector("#message button");
+ const msgId = showMessage(response.msg, response.data.closeTimeout, "error");
+ const buttonElement = document.querySelector(`#message [data-id="${msgId}"] button`);
if (buttonElement) {
buttonElement.addEventListener("click", () => {
fetchPost("/api/system/exit", {force: true}, () => {
diff --git a/app/src/protyle/export/index.ts b/app/src/protyle/export/index.ts
index 3f882266c..fc299163d 100644
--- a/app/src/protyle/export/index.ts
+++ b/app/src/protyle/export/index.ts
@@ -138,11 +138,10 @@ const getExportPath = (option: { type: string, id: string }, pdfOption?: PrintTo
pdf: option.type === "pdf",
savePath: result.filePath
}, exportResponse => {
- hideMessage(id);
if (option.type === "word") {
- afterExport(result.filePath);
+ afterExport(result.filePath, id);
} else {
- onExport(exportResponse, result.filePath, option.type, pdfOption, removeAssets);
+ onExport(exportResponse, result.filePath, option.type, pdfOption, removeAssets, id);
}
});
}
@@ -150,7 +149,7 @@ const getExportPath = (option: { type: string, id: string }, pdfOption?: PrintTo
});
};
-const onExport = (data: IWebSocketData, filePath: string, type: string, pdfOptions?: PrintToPDFOptions, removeAssets?: boolean) => {
+const onExport = (data: IWebSocketData, filePath: string, type: string, pdfOptions?: PrintToPDFOptions, removeAssets?: boolean, msgId?:string) => {
let themeName = window.siyuan.config.appearance.themeLight;
let mode = 0;
if (["html", "htmlmd"].includes(type) && window.siyuan.config.appearance.mode === 1) {
@@ -319,7 +318,7 @@ pre code {
id: data.data.id,
path: pdfFilePath
}, () => {
- afterExport(pdfFilePath);
+ afterExport(pdfFilePath, msgId);
if (removeAssets) {
const removePromise = (dir: string) => {
return new Promise(function (resolve) {
@@ -354,7 +353,7 @@ pre code {
} else {
const htmlPath = path.join(filePath, "index.html");
fs.writeFileSync(htmlPath, html);
- afterExport(htmlPath);
+ afterExport(htmlPath, msgId);
}
};
/// #endif
diff --git a/app/src/protyle/export/util.ts b/app/src/protyle/export/util.ts
index dd535bc56..6e1a66e62 100644
--- a/app/src/protyle/export/util.ts
+++ b/app/src/protyle/export/util.ts
@@ -4,16 +4,13 @@ import {escapeHtml} from "../../util/escape";
import {shell} from "electron";
import * as path from "path";
-export const afterExport = (exportPath: string) => {
- const id = showMessage(`
-
${window.siyuan.languages.exported}${escapeHtml(exportPath)}
-
-
-
-
`, 6000);
- document.querySelector("#message button").addEventListener("click", () => {
+export const afterExport = (exportPath: string, msgId: string) => {
+ showMessage(`${window.siyuan.languages.exported}${escapeHtml(exportPath)}
+
+
`, 6000, "info", msgId);
+ document.querySelector(`#message [data-id="${msgId}"] button`).addEventListener("click", () => {
shell.showItemInFolder(path.join(exportPath));
- hideMessage(id);
+ hideMessage(msgId);
});
};
/// #endif