mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-23 01:50:12 +01:00
🐛 update msg
This commit is contained in:
parent
bc2d609be6
commit
ac2c973f2b
2 changed files with 10 additions and 5 deletions
|
|
@ -32,8 +32,13 @@ export const showMessage = (message: string, timeout = 6000, type = "info", mess
|
||||||
const messagesElement = document.getElementById("message").firstElementChild;
|
const messagesElement = document.getElementById("message").firstElementChild;
|
||||||
const existElement = messagesElement.querySelector(`.b3-snackbar[data-id="${id}"]`)
|
const existElement = messagesElement.querySelector(`.b3-snackbar[data-id="${id}"]`)
|
||||||
if (existElement) {
|
if (existElement) {
|
||||||
existElement.firstElementChild.innerHTML = message;
|
|
||||||
window.clearTimeout(parseInt(existElement.getAttribute("data-timeoutid")));
|
window.clearTimeout(parseInt(existElement.getAttribute("data-timeoutid")));
|
||||||
|
existElement.innerHTML = `<div class="b3-snackbar__content">${message}</div>${timeout === 0 ? '<svg class="b3-snackbar__close"><use xlink:href="#iconClose"></use></svg>' : ''}`;
|
||||||
|
if (type === "error") {
|
||||||
|
existElement.classList.add("b3-snackbar--error")
|
||||||
|
} else {
|
||||||
|
existElement.classList.remove("b3-snackbar--error")
|
||||||
|
}
|
||||||
if (timeout > 0) {
|
if (timeout > 0) {
|
||||||
const timeoutId = window.setTimeout(() => {
|
const timeoutId = window.setTimeout(() => {
|
||||||
hideMessage(id);
|
hideMessage(id);
|
||||||
|
|
@ -49,7 +54,7 @@ export const showMessage = (message: string, timeout = 6000, type = "info", mess
|
||||||
const timeoutId = window.setTimeout(() => {
|
const timeoutId = window.setTimeout(() => {
|
||||||
hideMessage(id);
|
hideMessage(id);
|
||||||
}, timeout);
|
}, timeout);
|
||||||
messageHTML.replace("<div data-id", `<div data-timeoutid="${timeoutId}" data-id`);
|
messageHTML = messageHTML.replace("<div data-id", `<div data-timeoutid="${timeoutId}" data-id`);
|
||||||
}
|
}
|
||||||
if (messagesElement.childElementCount === 0) {
|
if (messagesElement.childElementCount === 0) {
|
||||||
messagesElement.parentElement.classList.add("b3-snackbars--show");
|
messagesElement.parentElement.classList.add("b3-snackbars--show");
|
||||||
|
|
|
||||||
|
|
@ -342,11 +342,11 @@ pre code {
|
||||||
});
|
});
|
||||||
win.destroy();
|
win.destroy();
|
||||||
}).catch((error: string) => {
|
}).catch((error: string) => {
|
||||||
showMessage("Export PDF error:" + error, 0);
|
showMessage("Export PDF error:" + error, 0, "error", msgId);
|
||||||
win.destroy();
|
win.destroy();
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
showMessage("Export PDF error:" + e + ". Export HTML and use Chrome's printing function to convert to PDF", 0);
|
showMessage("Export PDF error:" + e + ". Export HTML and use Chrome's printing function to convert to PDF", 0, "error", msgId);
|
||||||
}
|
}
|
||||||
}, Math.min(timeout, 10000));
|
}, Math.min(timeout, 10000));
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue