diff --git a/app/src/config/bazaar.ts b/app/src/config/bazaar.ts index 741bf227b..682f42bd7 100644 --- a/app/src/config/bazaar.ts +++ b/app/src/config/bazaar.ts @@ -293,49 +293,64 @@ export const bazaar = { `; }, - _genUpdateItemHTML (item: IBazaarItem) { - return `
+ _genUpdateItemHTML(item: IBazaarItem, bazaarType: TBazaarType) { + const dataObj = { + bazaarType, + themeMode: item.modes?.toString(), + updated: item.updated, + name: item.name, + repoURL: item.repoURL, + repoHash: item.repoHash, + downloaded: true + }; + return `
-
-
- ${item.preferredName} ${item.name} -
${item.preferredDesc || ""}
-
+
+
+ ${item.preferredName} ${item.name} +
${item.preferredDesc || ""}
+
- ${item.incompatible ? `${window.siyuan.languages.incompatible}` : ""} - ${item.preferredFunding ? `` : ""} + ${item.incompatible ? `${window.siyuan.languages.incompatible}` : ""} + ${item.preferredFunding ? `` : ""} + + + + + +
-
` +
`; }, _getUpdate() { fetchPost("/api/bazaar/getUpdatedPackage", {frontend: getFrontend()}, (response) => { let html = ""; response.data.plugins.forEach((item: IBazaarItem) => { - html += this._genUpdateItemHTML(item); + html += this._genUpdateItemHTML(item, "plugins"); }); response.data.themes.forEach((item: IBazaarItem) => { - html += this._genUpdateItemHTML(item); + html += this._genUpdateItemHTML(item, "themes"); }); response.data.icons.forEach((item: IBazaarItem) => { - html += this._genUpdateItemHTML(item); + html += this._genUpdateItemHTML(item, "icons"); }); response.data.templates.forEach((item: IBazaarItem) => { - html += this._genUpdateItemHTML(item); + html += this._genUpdateItemHTML(item, "templates"); }); response.data.widgets.forEach((item: IBazaarItem) => { - html += this._genUpdateItemHTML(item); + html += this._genUpdateItemHTML(item, "widgets"); }); this.element.querySelector('[data-type="downloaded-update"]').innerHTML = `
- +
${response.data.themes.length + response.data.icons.length + response.data.widgets.length + response.data.plugins.length + response.data.templates.length}
${html}
`; }) }, - _genMyHTML(bazaarType: TBazaarType, app: App) { + _genMyHTML(bazaarType: TBazaarType, app: App, updateUpdate = true) { const contentElement = bazaar.element.querySelector("#configBazaarDownloaded"); if (contentElement.getAttribute("data-loading") === "true" || contentElement.previousElementSibling.querySelector(`[data-type="my${bazaarType.replace(bazaarType[0], bazaarType[0].toUpperCase()).substring(0, bazaarType.length - 1)}"]`).classList.contains("b3-button--outline")) { @@ -430,6 +445,9 @@ export const bazaar = { } contentElement.innerHTML = html ? html : `
`; }); + if (updateUpdate) { + this._getUpdate(); + } }, _data: { themes: [] as IBazaarItem[], @@ -578,7 +596,6 @@ export const bazaar = { return; } this._genMyHTML("plugins", app); - this._getUpdate(); bazaar.element.firstElementChild.addEventListener("click", (event) => { let target = event.target as HTMLElement; const dataElement = hasClosestByAttribute(target, "data-obj", null); @@ -611,7 +628,7 @@ export const bazaar = { } }); target.classList.remove("b3-button--outline"); - this._genMyHTML(type.replace("my", "").toLowerCase() + "s" as TBazaarType, app); + this._genMyHTML(type.replace("my", "").toLowerCase() + "s" as TBazaarType, app, false); } event.preventDefault(); event.stopPropagation(); @@ -662,7 +679,7 @@ export const bazaar = { } } bazaar._onBazaar(response, bazaarType, ["themes", "icons"].includes(bazaarType)); - bazaar._genMyHTML(bazaarType, app); + bazaar._genMyHTML(bazaarType, app, false); if (bazaarType === "plugins") { if (window.siyuan.config.bazaar.petalDisabled) { confirmDialog(window.siyuan.languages.confirm, window.siyuan.languages.enablePluginTip2); @@ -674,7 +691,7 @@ export const bazaar = { frontend: getFrontend() }, (response) => { loadPlugin(app, response.data); - bazaar._genMyHTML(bazaarType, app); + bazaar._genMyHTML(bazaarType, app, false); }); }); } @@ -684,6 +701,11 @@ export const bazaar = { event.preventDefault(); event.stopPropagation(); break; + } else if (type === "install-all") { + fetchPost("/api/bazaar/batchUpdatePackage", {frontend: getFrontend()}); + event.preventDefault(); + event.stopPropagation(); + break; } else if (type === "install-t") { if (!target.classList.contains("b3-button--progress")) { confirmDialog(window.siyuan.languages.update, window.siyuan.languages.exportTplTip, () => { @@ -790,7 +812,7 @@ export const bazaar = { fetchPost("/api/setting/setAppearance", Object.assign({}, window.siyuan.config.appearance, { icon: packageName, }), (appearanceResponse) => { - this._genMyHTML(bazaarType, app); + this._genMyHTML(bazaarType, app, false); fetchPost("/api/bazaar/getBazaarIcon", {}, response => { response.data.appearance = appearanceResponse.data; bazaar._onBazaar(response, "icons", true); @@ -827,7 +849,7 @@ export const bazaar = { return; } } - this._genMyHTML("themes", app); + this._genMyHTML("themes", app, false); fetchPost("/api/bazaar/getBazaarTheme", {}, response => { response.data.appearance = appearanceResponse.data; bazaar._onBazaar(response, "themes", true);