From 89fc4bfa120ba42f58ce4dc62856aa5d3ebc7702 Mon Sep 17 00:00:00 2001 From: Linc <762699299@qq.com> Date: Mon, 3 Mar 2025 15:15:25 +0800 Subject: [PATCH] fix: wiki link with anchor cause inf refresh2 --- src/ab_manager/abm_html/ABSelector_PostHtml.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/ab_manager/abm_html/ABSelector_PostHtml.ts b/src/ab_manager/abm_html/ABSelector_PostHtml.ts index a6bef11..c2cb0ba 100644 --- a/src/ab_manager/abm_html/ABSelector_PostHtml.ts +++ b/src/ab_manager/abm_html/ABSelector_PostHtml.ts @@ -80,6 +80,7 @@ export class ABSelector_PostHtml{ // 判断是否悬浮窗口。悬浮窗口禁用强制渲染 const view: View|null = app.workspace.getActiveViewOfType(MarkdownView); // 未聚焦(active)会返回null + // 判断方式一:内容与窗口的文件名是否一致 (切换页面时 (aIncludeB -> b),有可能检测有问题,要用另一判断方式) // @ts-ignore 类型“View”上不存在属性“file” const path = view?.file.path if (path && path !== ctx.sourcePath) { @@ -92,6 +93,18 @@ export class ABSelector_PostHtml{ is_subContent = true return } + // 判断方式二:是否是实时模式下显示阅读模式内容 + const el = view?.containerEl // .workspace-leaf-content + if (el && el.getAttribute('data-mode') != 'preview') { // source + if (this.settings.is_debug) console.log(` !! Cache check: [${path}] use ![[${ctx.sourcePath}]] in source Mode`) + cache_item = { // 注意,极难检测是否 `[[#]]`,不存cache_map,也不触发强制刷新 + name: ctx.sourcePath, + content: mdSrc.content_all + } + is_newContent = false + is_subContent = true + return + } // 先查缓存 for (let item of cache_map) {