diff --git a/app/src/config/bazaar.ts b/app/src/config/bazaar.ts
index 99d956020..d97668ebd 100644
--- a/app/src/config/bazaar.ts
+++ b/app/src/config/bazaar.ts
@@ -341,7 +341,7 @@ export const bazaar = {
response.data.widgets.forEach((item: IBazaarItem) => {
html += this._genUpdateItemHTML(item, "widgets");
});
-
+ this._data.update = response.data;
const allCount = response.data.themes.length + response.data.icons.length + response.data.widgets.length + response.data.plugins.length + response.data.templates.length;
if (allCount === 0) {
this.element.querySelector('[data-type="downloaded-update"]').innerHTML = "";
@@ -357,6 +357,9 @@ export const bazaar = {
});
},
_genMyHTML(bazaarType: TBazaarType, app: App, updateUpdate = true) {
+ if (updateUpdate) {
+ this._getUpdate();
+ }
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")) {
@@ -451,9 +454,6 @@ export const bazaar = {
}
contentElement.innerHTML = html ? html : `
- ${window.siyuan.languages.emptyContent}
`;
});
- if (updateUpdate) {
- this._getUpdate();
- }
},
_data: {
themes: [] as IBazaarItem[],
@@ -462,16 +462,22 @@ export const bazaar = {
widgets: [] as IBazaarItem[],
plugins: [] as IBazaarItem[],
downloaded: [] as IBazaarItem[],
+ update: {
+ themes: [] as IBazaarItem[],
+ templates: [] as IBazaarItem[],
+ icons: [] as IBazaarItem[],
+ widgets: [] as IBazaarItem[],
+ plugins: [] as IBazaarItem[],
+ }
},
_renderReadme(cardElement: HTMLElement, bazaarType: TBazaarType) {
const dataObj = JSON.parse(cardElement.getAttribute("data-obj"));
let data: IBazaarItem;
- (dataObj.downloaded ? bazaar._data.downloaded : bazaar._data[bazaarType]).find((item: IBazaarItem) => {
- if (item.repoURL === dataObj.repoURL) {
- data = item;
- return true;
- }
- });
+ if (hasClosestByAttribute(cardElement, "data-type", "downloaded-update")) {
+ data = bazaar._data.update[bazaarType].find((item: IBazaarItem) => item.repoURL === dataObj.repoURL);
+ } else {
+ data = (dataObj.downloaded ? bazaar._data.downloaded : bazaar._data[bazaarType]).find((item: IBazaarItem) => item.repoURL === dataObj.repoURL);
+ }
const readmeElement = bazaar.element.querySelector("#configBazaarReadme") as HTMLElement;
const urls = data.repoURL.split("/");
urls.pop();
@@ -526,8 +532,8 @@ export const bazaar = {
${dataObj.downloaded ? window.siyuan.languages.installDate : window.siyuan.languages.releaseDate}
${dataObj.downloaded ? data.hInstallDate : data.hUpdated}
${dataObj.downloaded ? window.siyuan.languages.installSize : window.siyuan.languages.pkgSize}
${dataObj.downloaded ? data.hInstallSize : data.hSize}
-
-
+
+
@@ -569,8 +575,8 @@ export const bazaar = {
-
-

+
+
`;
if (dataObj.downloaded) {
@@ -732,7 +738,7 @@ export const bazaar = {
url = "/api/bazaar/installBazaarPlugin";
}
if (!target.classList.contains("b3-button")) {
- target.parentElement.insertAdjacentHTML("afterend", '
');
+ target.parentElement.insertAdjacentHTML("afterend", '
');
}
fetchPost(url, {
repoURL: dataObj.repoURL,