diff --git a/app/src/config/bazaar.ts b/app/src/config/bazaar.ts index 4c9a3d17c..02cd2cf72 100644 --- a/app/src/config/bazaar.ts +++ b/app/src/config/bazaar.ts @@ -385,10 +385,9 @@ export const bazaar = { } else if (bazaarType === "plugins") { url = "/api/bazaar/getInstalledPlugin"; } - const keyword = (contentElement.previousElementSibling.querySelector(".b3-text-field") as HTMLInputElement)?.value?.trim() || ""; fetchPost(url, { frontend: getFrontend(), - ...(keyword ? { keyword } : {}), + keyword: (contentElement.previousElementSibling.querySelector(".b3-text-field") as HTMLInputElement)?.value || "", }, response => { contentElement.removeAttribute("data-loading"); let html = ""; @@ -691,9 +690,8 @@ type="checkbox"> } else if (bazaarType === "plugins") { url = "/api/bazaar/installBazaarPlugin"; } - const keyword = (bazaar.element.querySelector(".config-bazaar__panel:not(.fn__none) .b3-form__icon-input") as HTMLInputElement).value.trim(); fetchPost(url, { - ...(keyword ? { keyword } : {}), + keyword: (bazaar.element.querySelector(".config-bazaar__panel:not(.fn__none) .b3-form__icon-input") as HTMLInputElement).value, repoURL: dataObj.repoURL, packageName: dataObj.name, repoHash: dataObj.repoHash, @@ -752,9 +750,8 @@ type="checkbox"> if (!target.classList.contains("b3-button")) { target.parentElement.insertAdjacentHTML("afterend", ''); } - const keyword = (bazaar.element.querySelector(".config-bazaar__panel:not(.fn__none) .b3-form__icon-input") as HTMLInputElement).value.trim(); fetchPost(url, { - ...(keyword ? { keyword } : {}), + keyword: (bazaar.element.querySelector(".config-bazaar__panel:not(.fn__none) .b3-form__icon-input") as HTMLInputElement).value, repoURL: dataObj.repoURL, packageName: dataObj.name, repoHash: dataObj.repoHash, @@ -806,10 +803,9 @@ type="checkbox"> showMessage(window.siyuan.languages.uninstallTip); } else { confirmDialog("⚠️ " + window.siyuan.languages.uninstall, window.siyuan.languages.confirmUninstall.replace("${name}", packageName), () => { - const keyword = (bazaar.element.querySelector(".config-bazaar__panel:not(.fn__none) .b3-form__icon-input") as HTMLInputElement).value.trim(); fetchPost(url, { packageName, - ...(keyword ? { keyword } : {}), + keyword: (bazaar.element.querySelector(".config-bazaar__panel:not(.fn__none) .b3-form__icon-input") as HTMLInputElement).value, frontend: getFrontend() }, response => { this._genMyHTML(bazaarType, app); @@ -1001,29 +997,29 @@ type="checkbox"> const keyword = inputElement.value.trim(); const type = (hasClosestByClassName(inputElement, "config-bazaar__panel") as HTMLElement).getAttribute("data-type"); if (type === "template") { - fetchPost("/api/bazaar/getBazaarTemplate", keyword ? { keyword } : {}, response => { + fetchPost("/api/bazaar/getBazaarTemplate", {keyword}, response => { bazaar._onBazaar(response, "templates"); bazaar._data.templates = response.data.packages; }); } else if (type === "icon") { - fetchPost("/api/bazaar/getBazaarIcon", keyword ? { keyword } : {}, response => { + fetchPost("/api/bazaar/getBazaarIcon", {keyword}, response => { bazaar._onBazaar(response, "icons"); bazaar._data.icons = response.data.packages; }); } else if (type === "widget") { - fetchPost("/api/bazaar/getBazaarWidget", keyword ? { keyword } : {}, response => { + fetchPost("/api/bazaar/getBazaarWidget", {keyword}, response => { bazaar._onBazaar(response, "widgets"); bazaar._data.widgets = response.data.packages; }); } else if (type === "theme") { - fetchPost("/api/bazaar/getBazaarTheme", keyword ? { keyword } : {}, response => { + fetchPost("/api/bazaar/getBazaarTheme", {keyword}, response => { bazaar._onBazaar(response, "themes"); bazaar._data.themes = response.data.packages; }); } else if (type === "plugin") { fetchPost("/api/bazaar/getBazaarPlugin", { frontend: getFrontend(), - ...(keyword ? { keyword } : {}), + keyword }, response => { bazaar._onBazaar(response, "plugins"); bazaar._data.plugins = response.data.packages;