From bb218089ba861e6064b055089ffb8445422d0819 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Sat, 21 Oct 2023 23:48:27 +0800 Subject: [PATCH] :art: fix https://github.com/siyuan-note/siyuan/issues/9467 --- app/src/config/bazaar.ts | 80 +++++++++++++++++++++++++++------------- 1 file changed, 55 insertions(+), 25 deletions(-) diff --git a/app/src/config/bazaar.ts b/app/src/config/bazaar.ts index 6c07763e6..f62b3b560 100644 --- a/app/src/config/bazaar.ts +++ b/app/src/config/bazaar.ts @@ -94,6 +94,10 @@ export const bazaar = {
+
+
+
+
${loadingHTML} @@ -112,12 +116,14 @@ export const bazaar = { -
+
+
+
@@ -138,6 +144,10 @@ export const bazaar = { +
+
+
+
${loadingHTML} @@ -156,6 +166,10 @@ export const bazaar = { +
+
+
+
${loadingHTML} @@ -174,6 +188,10 @@ export const bazaar = { +
+
+
+
${loadingHTML} @@ -192,6 +210,10 @@ export const bazaar = { +
+
+
+
${loadingHTML} @@ -287,27 +309,33 @@ export const bazaar = { if (["icons", "themes"].includes(bazaarType)) { showSwitch = true; } - response.data.packages.forEach((item: IBazaarItem) => { - const dataObj = { - bazaarType, - themeMode: item.modes?.toString(), - updated: item.updated, - name: item.name, - repoURL: item.repoURL, - repoHash: item.repoHash, - downloaded: true - }; - let hasSetting = false; - if (bazaarType === "plugins") { - app.plugins.find((item: Plugin) => { - if (item.name === dataObj.name) { - // @ts-ignore - hasSetting = item.setting || item.__proto__.hasOwnProperty("openSetting"); - return true; - } - }); - } - html += `
+ const counterElement = contentElement.parentElement.querySelector(".counter") + if (response.data.packages.length === 0) { + counterElement.classList.add("fn__none") + } else { + counterElement.classList.remove("fn__none") + counterElement.textContent = response.data.packages.length; + response.data.packages.forEach((item: IBazaarItem) => { + const dataObj = { + bazaarType, + themeMode: item.modes?.toString(), + updated: item.updated, + name: item.name, + repoURL: item.repoURL, + repoHash: item.repoHash, + downloaded: true + }; + let hasSetting = false; + if (bazaarType === "plugins") { + app.plugins.find((item: Plugin) => { + if (item.name === dataObj.name) { + // @ts-ignore + hasSetting = item.setting || item.__proto__.hasOwnProperty("openSetting"); + return true; + } + }); + } + html += `
@@ -338,7 +366,8 @@ export const bazaar = {
`; - }); + }); + } bazaar._data.downloaded = response.data.packages; if (bazaarType === "plugins") { html = `
@@ -839,7 +868,7 @@ export const bazaar = { }); bazaar.element.querySelectorAll(".b3-select").forEach((selectElement: HTMLSelectElement) => { - selectElement.addEventListener("change", () => { + selectElement.addEventListener("change", (event) => { if (selectElement.id === "bazaarSelect") { // theme select bazaar.element.querySelectorAll("#configBazaarTheme .b3-card").forEach((item) => { @@ -860,6 +889,7 @@ export const bazaar = { item.classList.remove("fn__none"); } }); + (event.target as HTMLElement).parentElement.querySelector(".counter").textContent = bazaar.element.querySelectorAll("#configBazaarTheme .b3-card:not(.fn__none)").length.toString(); } else { // sort const localSort = window.siyuan.storage[Constants.LOCAL_BAZAAR]; @@ -925,7 +955,7 @@ export const bazaar = { }); bazaar._data[bazaarType] = response.data.packages; element.innerHTML = `
${html}
`; - + element.parentElement.querySelector(".counter").textContent = element.querySelectorAll(".b3-card:not(.fn__none)").length.toString(); const localSort = window.siyuan.storage[Constants.LOCAL_BAZAAR]; if (localSort[bazaarType.replace("s", "")] === "1") { html = "";