diff --git a/app/src/config/exportConfig.ts b/app/src/config/exportConfig.ts index 330db9289..f629cf3ea 100644 --- a/app/src/config/exportConfig.ts +++ b/app/src/config/exportConfig.ts @@ -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, diff --git a/app/src/dialog/message.ts b/app/src/dialog/message.ts index 62d550810..55afd2d55 100644 --- a/app/src/dialog/message.ts +++ b/app/src/dialog/message.ts @@ -4,9 +4,7 @@ import {Constants} from "../constants"; export const initMessage = () => { const messageElement = document.getElementById("message"); messageElement.innerHTML = `
-`; +`; 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 = `
${message}
${timeout === 0 ? '' : ''}`; + existElement.innerHTML = `
${message}
${timeout === 0 ? '' : ""}`; 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(() => { diff --git a/app/src/protyle/export/index.ts b/app/src/protyle/export/index.ts index 93553e3f3..f997ee62a 100644 --- a/app/src/protyle/export/index.ts +++ b/app/src/protyle/export/index.ts @@ -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"; diff --git a/app/src/protyle/upload/index.ts b/app/src/protyle/upload/index.ts index 8f2699034..4c5f23eab 100644 --- a/app/src/protyle/upload/index.ts +++ b/app/src/protyle/upload/index.ts @@ -65,7 +65,7 @@ const validateFile = (protyle: IProtyle, files: File[]) => { uploadingStr += `
  • ${filename} ${window.siyuan.languages.uploading}
  • `; } } - let msgId + let msgId; if (errorTip !== "" || uploadingStr !== "") { msgId = showMessage(``); } @@ -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); }); }; diff --git a/app/src/protyle/util/onGet.ts b/app/src/protyle/util/onGet.ts index 050791ec4..0734acd71 100644 --- a/app/src/protyle/util/onGet.ts +++ b/app/src/protyle/util/onGet.ts @@ -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";