From 6fa8ca54adbbe0429c8eded91ab6c828059b1a1e Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sun, 18 Oct 2026 14:29:48 +0800 Subject: [PATCH] fix(CherryMarkdown): fingerprint CSS asset Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../CherryMarkdown/CherryMarkdown.razor.cs | 13 ++++++++++++- .../CherryMarkdown/CherryMarkdown.razor.js | 6 +++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/components/BootstrapBlazor.CherryMarkdown/Components/CherryMarkdown/CherryMarkdown.razor.cs b/src/components/BootstrapBlazor.CherryMarkdown/Components/CherryMarkdown/CherryMarkdown.razor.cs index 259df74b4..321532916 100644 --- a/src/components/BootstrapBlazor.CherryMarkdown/Components/CherryMarkdown/CherryMarkdown.razor.cs +++ b/src/components/BootstrapBlazor.CherryMarkdown/Components/CherryMarkdown/CherryMarkdown.razor.cs @@ -12,6 +12,17 @@ namespace BootstrapBlazor.Components; /// public partial class CherryMarkdown { + private const string StylePath = "_content/BootstrapBlazor.CherryMarkdown/css/cherry-markdown.css"; + private const string KatexStylePath = "_content/BootstrapBlazor.CherryMarkdown/css/katex.min.css"; + +#if NET9_0_OR_GREATER + private string StyleUrl => Assets[StylePath]; + private string KatexStyleUrl => Assets[KatexStylePath]; +#else + private static string StyleUrl => StylePath; + private static string KatexStyleUrl => KatexStylePath; +#endif + /// /// 获得/设置 编辑器设置 /// @@ -114,7 +125,7 @@ protected override async Task OnAfterRenderAsync(bool firstRender) Locale = Language, Editor = EditorSettings ?? new(), Toolbars = ToolbarSettings ?? new() - }, nameof(Upload)); + }, nameof(Upload), StyleUrl, KatexStyleUrl); /// /// 文件上传回调 diff --git a/src/components/BootstrapBlazor.CherryMarkdown/Components/CherryMarkdown/CherryMarkdown.razor.js b/src/components/BootstrapBlazor.CherryMarkdown/Components/CherryMarkdown/CherryMarkdown.razor.js index 0a9a30bad..20e760b42 100644 --- a/src/components/BootstrapBlazor.CherryMarkdown/Components/CherryMarkdown/CherryMarkdown.razor.js +++ b/src/components/BootstrapBlazor.CherryMarkdown/Components/CherryMarkdown/CherryMarkdown.razor.js @@ -2,16 +2,16 @@ import '../../js/cherry-markdown.core.js' import { addLink, addScript } from '../../../BootstrapBlazor/modules/utility.js' import Data from '../../../BootstrapBlazor/modules/data.js' -export async function init(id, invoke, options, callback) { +export async function init(id, invoke, options, callback, styleUrl, katexStyleUrl) { const el = document.getElementById(id); if (el === null) { return; } - await addLink('./_content/BootstrapBlazor.CherryMarkdown/css/cherry-markdown.css') + await addLink(styleUrl) if (options.isSupportMath) { await addScript('./_content/BootstrapBlazor.CherryMarkdown/js/katex.min.js') - await addLink('./_content/BootstrapBlazor.CherryMarkdown/css/katex.min.css') + await addLink(katexStyleUrl) options.engine = { syntax: { mathBlock: { engine: 'katex', },