diff --git a/app/src/config/bazaar.ts b/app/src/config/bazaar.ts index 8174b7704..175ad183b 100644 --- a/app/src/config/bazaar.ts +++ b/app/src/config/bazaar.ts @@ -6,6 +6,7 @@ import {confirmDialog} from "../dialog/confirmDialog"; import {highlightRender} from "../protyle/markdown/highlightRender"; import {exportLayout} from "../layout/util"; import {Constants} from "../constants"; +import {loadAssets} from "../util/assets"; export const bazaar = { element: undefined as Element, @@ -301,15 +302,27 @@ export const bazaar = { url = "/api/bazaar/installBazaarWidget"; } target.parentElement.insertAdjacentHTML("afterend", ""); + const name = target.parentElement.getAttribute("data-name") fetchPost(url, { repoURL: target.parentElement.getAttribute("data-url"), - packageName: target.parentElement.getAttribute("data-name"), + packageName: name, repoHash: target.parentElement.getAttribute("data-hash"), mode: target.parentElement.parentElement.getAttribute("data-type") === "dark" ? 1 : 0, update: true, }, response => { // 更新主题后不需要对该主题进行切换 https://github.com/siyuan-note/siyuan/issues/4966 bazaar.onBazaar(response, bazaarType, ["icons"].includes(bazaarType)); + // https://github.com/siyuan-note/siyuan/issues/5411 + if (bazaarType === "themes" && ( + (window.siyuan.config.appearance.mode === 0 && window.siyuan.config.appearance.themeLight === name) || + (window.siyuan.config.appearance.mode === 1 && window.siyuan.config.appearance.themeDark === name) + )) { + if (window.siyuan.config.appearance.themeJS) { + exportLayout(true); + } else { + loadAssets(window.siyuan.config.appearance); + } + } }); }); event.preventDefault();