@@ -219,7 +224,7 @@ export const bazaar = {
downloaded: [] as IBazaarItem[],
},
renderReadme(cardElement: HTMLElement, bazaarType: TBazaarType) {
- const isDownloaded = cardElement.getAttribute("data-type") === "downloaded";
+ const isDownloaded = cardElement.getAttribute("data-downloaded") === "true";
const repoURL = cardElement.querySelector(".b3-card__actions").getAttribute("data-url");
let data: IBazaarItem;
(isDownloaded ? bazaar.data.downloaded : bazaar.data[bazaarType]).find((item: IBazaarItem) => {
@@ -262,7 +267,7 @@ export const bazaar = {
+
@@ -312,22 +317,28 @@ export const bazaar = {
readmeElement.style.right = "0";
},
bindEvent() {
- fetchPost("/api/bazaar/getBazaarTheme", {}, response => {
- bazaar.onBazaar(response, "themes", false);
- bazaar.data.themes = response.data.packages;
- });
+ this._genMyHTML("themes");
bazaar.element.addEventListener("click", (event) => {
let target = event.target as HTMLElement;
while (target && !target.isEqualNode(bazaar.element)) {
const type = target.getAttribute("data-type");
- if (type === "myTheme" || type === "myTemplate" || type === "myIcon" || type === "myWidget") {
- target.parentElement.childNodes.forEach((item: HTMLElement) => {
- if (item.nodeType !== 3 && item.classList.contains("b3-button")) {
- item.classList.add("b3-button--outline");
- }
- })
- target.classList.remove("b3-button--outline");
- this._genMyHTML(type.replace("my", "").toLowerCase() + "s" as TBazaarType);
+ if (type === "open") {
+ /// #if !BROWSER
+ shell.openPath(path.join(window.siyuan.config.system.confDir, "appearance", "themes", target.parentElement.getAttribute("data-name")));
+ /// #endif
+ event.preventDefault();
+ event.stopPropagation();
+ break;
+ } else if (type === "myTheme" || type === "myTemplate" || type === "myIcon" || type === "myWidget") {
+ if (target.classList.contains("b3-button--outline")) {
+ target.parentElement.childNodes.forEach((item: HTMLElement) => {
+ if (item.nodeType !== 3 && item.classList.contains("b3-button")) {
+ item.classList.add("b3-button--outline");
+ }
+ })
+ target.classList.remove("b3-button--outline");
+ this._genMyHTML(type.replace("my", "").toLowerCase() + "s" as TBazaarType);
+ }
event.preventDefault();
event.stopPropagation();
break;
@@ -389,7 +400,11 @@ export const bazaar = {
update: true,
}, response => {
// 更新主题后不需要对该主题进行切换 https://github.com/siyuan-note/siyuan/issues/4966
- bazaar.onBazaar(response, bazaarType, ["icons"].includes(bazaarType));
+ if (cardElement && cardElement.getAttribute("data-downloaded") === "true") {
+ this._genMyHTML(bazaarType);
+ } else {
+ 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) ||
@@ -431,7 +446,7 @@ export const bazaar = {
fetchPost(url, {
packageName
}, response => {
- if (cardElement && cardElement.getAttribute("data-type") === "downloaded") {
+ if (cardElement && cardElement.getAttribute("data-downloaded") === "true") {
this._genMyHTML(bazaarType);
} else {
bazaar.onBazaar(response, bazaarType, ["themes", "icons"].includes(bazaarType));
@@ -527,8 +542,11 @@ export const bazaar = {
bazaar.onBazaar(response, "widgets", false);
bazaar.data.widgets = response.data.packages;
});
- } else if (type === "downloaded") {
- this._genMyHTML("themes");
+ } else if (type === "theme") {
+ fetchPost("/api/bazaar/getBazaarTheme", {}, response => {
+ bazaar.onBazaar(response, "themes", false);
+ bazaar.data.themes = response.data.packages;
+ });
}
item.setAttribute("data-init", "true");
}