This commit is contained in:
Vanessa 2022-06-07 15:01:40 +08:00
parent 785cb50e85
commit 27da48354d
5 changed files with 11 additions and 12 deletions

View file

@ -5,7 +5,7 @@ import {SaveDialogReturnValue, shell} from "electron";
import {afterExport} from "../protyle/export/util";
/// #endif
import {isBrowser} from "../util/functions";
import {hideMessage, showMessage} from "../dialog/message";
import {showMessage} from "../dialog/message";
export const exportConfig = {
element: undefined as Element,

View file

@ -4,9 +4,7 @@ import {Constants} from "../constants";
export const initMessage = () => {
const messageElement = document.getElementById("message");
messageElement.innerHTML = `<div class="fn__flex-1"></div>
<button class="b3-button b3-button--outline">
<svg><use xlink:href="#iconTrashcan"></use></svg> ${window.siyuan.languages.clearMessage}
</button>`;
<button class="b3-button b3-tooltips b3-tooltips__w" aria-label="${window.siyuan.languages.clearMessage}"><svg style="margin-right: 0"><use xlink:href="#iconTrashcan"></use></svg></button>`;
messageElement.addEventListener("click", (event) => {
let target = event.target as HTMLElement;
while (target && !target.isEqualNode(messageElement)) {
@ -27,17 +25,18 @@ export const initMessage = () => {
});
};
// type: info/error; timeout: 0 手动关闭;-1 用不关闭
export const showMessage = (message: string, timeout = 6000, type = "info", messageId?: string) => {
const id = messageId || genUUID();
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) {
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>' : ''}`;
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")
existElement.classList.add("b3-snackbar--error");
} else {
existElement.classList.remove("b3-snackbar--error")
existElement.classList.remove("b3-snackbar--error");
}
if (timeout > 0) {
const timeoutId = window.setTimeout(() => {

View file

@ -1,4 +1,4 @@
import {hideMessage, showMessage} from "../../dialog/message";
import {showMessage} from "../../dialog/message";
import {Constants} from "../../constants";
/// #if !BROWSER
import {PrintToPDFOptions, SaveDialogReturnValue} from "electron";

View file

@ -65,7 +65,7 @@ const validateFile = (protyle: IProtyle, files: File[]) => {
uploadingStr += `<li>${filename} ${window.siyuan.languages.uploading}</li>`;
}
}
let msgId
let msgId;
if (errorTip !== "" || uploadingStr !== "") {
msgId = showMessage(`<ul>${errorTip}${uploadingStr}</ul>`);
}
@ -135,7 +135,7 @@ export const uploadLocalFiles = (files: string[], protyle: IProtyle) => {
assetPaths: files,
id: protyle.block.rootID
}, (response) => {
hideMessage(id)
hideMessage(id);
genUploadedLabel(JSON.stringify(response), protyle);
});
};

View file

@ -7,7 +7,7 @@ import {fetchPost} from "../../util/fetch";
import {processRender} from "./processCode";
import {highlightRender} from "../markdown/highlightRender";
import {blockRender} from "../markdown/blockRender";
import {highlightById, scrollCenter} from "../../util/highlightById";
import {highlightById} from "../../util/highlightById";
import {pushBack} from "../../util/backForward";
import {focusBlock} from "./selection";
import {hasClosestByAttribute, hasClosestByClassName} from "./hasClosest";