From 2c433b69e47b81b3750d77b7c694c5064c082f23 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Mon, 25 Mar 2024 10:50:23 +0800 Subject: [PATCH] :art: fix https://github.com/siyuan-note/siyuan/issues/10714 --- app/src/block/popover.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/app/src/block/popover.ts b/app/src/block/popover.ts index a32c0f404..d041cede5 100644 --- a/app/src/block/popover.ts +++ b/app/src/block/popover.ts @@ -4,9 +4,9 @@ import { hasClosestByAttribute, hasClosestByClassName, } from "../protyle/util/hasClosest"; -import {fetchSyncPost} from "../util/fetch"; +import {fetchPost, fetchSyncPost} from "../util/fetch"; import {hideTooltip, showTooltip} from "../dialog/tooltip"; -import {getIdFromSYProtocol} from "../util/pathName"; +import {getIdFromSYProtocol, isLocalPath} from "../util/pathName"; import {App} from "../index"; import {Constants} from "../constants"; import {getCellText} from "../protyle/render/av/cell"; @@ -42,9 +42,17 @@ export const initBlockPopover = (app: App) => { } } if (!tip) { - tip = aElement.getAttribute("data-href")?.substring(0, Constants.SIZE_TITLE) || ""; + const href = aElement.getAttribute("data-href") || ""; + tip = href.substring(0, Constants.SIZE_TITLE) || ""; const title = aElement.getAttribute("data-title"); - if (title) { + if (tip && isLocalPath(href) && !aElement.classList.contains("b3-tooltips")) { + let assetTip = tip; + fetchPost("/api/asset/statAsset", {path: href}, (response) => { + assetTip += ` ${response.data.hSize}${title ? "
" + title : ""}
${window.siyuan.languages.modifiedAt} ${response.data.hCreated}
${window.siyuan.languages.createdAt} ${response.data.hUpdated}`; + showTooltip(assetTip, aElement); + }); + tip = ""; + } else if (title) { tip += "
" + title; } }