Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:bug: export msg

Vanessa432fe6be1ec0
diff --git a/app/src/config/exportConfig.ts b/app/src/config/exportConfig.ts
index da7aedaadb..330db9289f 100644
--- a/app/src/config/exportConfig.ts
+++ b/app/src/config/exportConfig.ts
@@ -166,8 +166,7 @@ export const exportConfig = {
fetchPost("/api/export/exportDataInFolder", {
folder: result.filePath
}, () => {
- hideMessage(id);
- afterExport(result.filePath);
+ afterExport(result.filePath, id);
});
}
});
diff --git a/app/src/dialog/message.ts b/app/src/dialog/message.ts
index 69ed6ed6f7..8ec9b39b41 100644
--- a/app/src/dialog/message.ts
+++ b/app/src/dialog/message.ts
@@ -33,15 +33,23 @@ export const showMessage = (message: string, timeout = 6000, type = "info", mess
const existElement = messagesElement.querySelector(`.b3-snackbar[data-id="${id}"]`)
if (existElement) {
existElement.firstElementChild.innerHTML = message;
+ window.clearTimeout(parseInt(existElement.getAttribute("data-timeoutid")));
+ if (timeout > 0) {
+ const timeoutId = window.setTimeout(() => {
+ hideMessage(id);
+ }, timeout);
+ existElement.setAttribute("data-timeoutid", timeoutId.toString());
+ }
return;
}
let messageHTML = `<div data-id="${id}" class="b3-snackbar--hide b3-snackbar${type === "error" ? " b3-snackbar--error" : ""}"><div class="b3-snackbar__content">${message}</div>`;
if (timeout === 0) {
messageHTML += '<svg class="b3-snackbar__close"><use xlink:href="#iconClose"></use></svg>';
} else if (timeout !== -1) { // -1 时需等待请求完成后手动关闭
- window.setTimeout(() => {
+ const timeoutId = window.setTimeout(() => {
hideMessage(id);
}, timeout);
+ messageHTML.replace("<div data-id", `<div data-timeoutid="${timeoutId}" data-id`);
}
if (messagesElement.childElementCount === 0) {
messagesElement.parentElement.classList.add("b3-snackbars--show");
diff --git a/app/src/dialog/processSystem.ts b/app/src/dialog/processSystem.ts
index 1505674aea..432484b96a 100644
--- a/app/src/dialog/processSystem.ts
+++ b/app/src/dialog/processSystem.ts
@@ -84,8 +84,8 @@ export const kernelError = () => {
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 3f882266c0..fc299163df 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 dd535bc569..6e1a66e620 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(`<div class="fn__flex">
- <div class="fn__flex-center">${window.siyuan.languages.exported}${escapeHtml(exportPath)}</div>
- <div class="fn__space"></div>
- <div class="fn__space"></div>
- <button class="b3-button b3-button--white">${window.siyuan.languages.showInFolder}</button>
-</div>`, 6000);
- document.querySelector("#message button").addEventListener("click", () => {
+export const afterExport = (exportPath: string, msgId: string) => {
+ showMessage(`${window.siyuan.languages.exported}${escapeHtml(exportPath)}
+<div class="fn__space"></div>
+<button class="b3-button b3-button--white">${window.siyuan.languages.showInFolder}</button>`, 6000, "info", msgId);
+ document.querySelector(`#message [data-id="${msgId}"] button`).addEventListener("click", () => {
shell.showItemInFolder(path.join(exportPath));
- hideMessage(id);
+ hideMessage(msgId);
});
};
/// #endif