♻️ Unified marketplace Package Type Model (#17152)

This commit is contained in:
Jeffrey Chen 2026-03-08 11:09:46 +08:00 committed by GitHub
parent ab83e5d987
commit 3cac07dfd9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 1108 additions and 1919 deletions

View file

@ -700,7 +700,7 @@ type="checkbox">
}, async response => {
bazaar._onBazaar(response, bazaarType);
bazaar._genMyHTML(bazaarType, app, false);
if (bazaarType === "plugins") {
if (response.code === 0 && bazaarType === "plugins") {
if (window.siyuan.config.bazaar.petalDisabled) {
confirmDialog(window.siyuan.languages.confirm, window.siyuan.languages.enablePluginTip2);
} else {
@ -756,27 +756,17 @@ type="checkbox">
packageName: dataObj.name,
repoHash: dataObj.repoHash,
mode: dataObj.themeMode === "dark" ? 1 : 0,
update: true,
frontend: getFrontend()
}, async response => {
this._genMyHTML(bazaarType, app);
bazaar._onBazaar(response, bazaarType);
// TODO 集市包的相关逻辑应完全由内核处理并推送到所有前端实例,下面的代码需要确认
// https://github.com/siyuan-note/siyuan/issues/15177
if (bazaarType === "themes" && response.data.appearance?.themeVer) {
window.siyuan.config.appearance.themeVer = response.data.appearance.themeVer;
}
// 更新主题后不需要对该主题进行切换 https://github.com/siyuan-note/siyuan/issues/4966
// https://github.com/siyuan-note/siyuan/issues/5411
if (bazaarType === "plugins") {
app.plugins.find((item: Plugin) => {
if (item.name === dataObj.name) {
reloadPlugin(app, {
reloadPlugins: [dataObj.name],
});
return true;
}
});
}
});
});
}
@ -1099,12 +1089,6 @@ type="checkbox">
});
},
_onBazaar(response: IWebSocketData, bazaarType: TBazaarType) {
if (bazaar.element.querySelector("#configBazaarReadme").classList.contains("config-bazaar__readme--show")) {
const dataObj = JSON.parse(bazaar.element.querySelector("#configBazaarReadme > .item__side").getAttribute("data-obj"));
bazaar._renderReadme((dataObj.bazaarType) as TBazaarType,
response.data.packages.find((item: IBazaarItem) => item.repoURL === dataObj.repoURL),
dataObj.downloaded);
}
let id = "#configBazaarTemplate";
if (bazaarType === "themes") {
id = "#configBazaarTheme";
@ -1117,10 +1101,18 @@ type="checkbox">
}
const element = bazaar.element.querySelector(id);
if (response.code === 1) {
// 安装集市包 /api/bazaar/installBazaar* 失败
showMessage(response.msg);
element.querySelectorAll("img[data-type='img-loading']").forEach((item) => {
item.remove();
});
return;
}
if (bazaar.element.querySelector("#configBazaarReadme").classList.contains("config-bazaar__readme--show")) {
const dataObj = JSON.parse(bazaar.element.querySelector("#configBazaarReadme > .item__side").getAttribute("data-obj"));
bazaar._renderReadme((dataObj.bazaarType) as TBazaarType,
response.data.packages.find((item: IBazaarItem) => item.repoURL === dataObj.repoURL),
dataObj.downloaded);
}
let html = "";
response.data.packages.forEach((item: IBazaarItem) => {

View file

@ -878,8 +878,6 @@ interface IMenu {
}
interface IBazaarItem {
incompatible?: boolean; // 仅 plugin
enabled: boolean;
preferredName: string;
minAppVersion: string;
preferredDesc: string;
@ -895,13 +893,11 @@ interface IBazaarItem {
outdated: false;
name: string;
previewURL: string;
previewURLThumb: string;
repoHash: string;
repoURL: string;
url: string;
openIssues: number;
version: string;
modes: string[];
hSize: string;
hInstallSize: string;
hInstallDate: string;
@ -909,6 +905,9 @@ interface IBazaarItem {
preferredFunding: string;
disallowUpdate: boolean;
updateRequiredMinAppVer: string;
incompatible?: boolean; // 仅 plugin
enabled?: boolean; // 仅 plugin
modes?: string[]; // 仅 theme
}
interface IAV {