Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: https://github.com/siyuan-note/siyuan/issues/16485

Vanessa748784554aa9
diff --git a/app/src/config/bazaar.ts b/app/src/config/bazaar.ts
index 7242aab2ae..eb294f5c38 100644
--- a/app/src/config/bazaar.ts
+++ b/app/src/config/bazaar.ts
@@ -840,7 +840,7 @@ export const bazaar = {
if (window.siyuan.config.bazaar.petalDisabled) {
bazaar.element.querySelectorAll("#configBazaarDownloaded .b3-card").forEach(item => {
item.classList.add("b3-card--disabled");
- uninstall(app, JSON.parse(item.getAttribute("data-obj")).name, false);
+ uninstall(app, JSON.parse(item.getAttribute("data-obj")).name, true);
});
} else {
bazaar.element.querySelectorAll("#configBazaarDownloaded .b3-card").forEach(item => {
@@ -878,7 +878,7 @@ export const bazaar = {
}
});
} else {
- uninstall(app, dataObj.name, false);
+ uninstall(app, dataObj.name, true);
target.parentElement.querySelector('[data-type="setting"]').classList.add("fn__none");
}
});
diff --git a/app/src/plugin/index.ts b/app/src/plugin/index.ts
index d6ec0e2683..7ec87cefe1 100644
--- a/app/src/plugin/index.ts
+++ b/app/src/plugin/index.ts
@@ -118,7 +118,7 @@ export class Plugin {
public onDataChanged() {
// 存储数据变更
// 兼容 3.4.1 以前同步数据使用重载插件的问题
- uninstall(this.app, this.name, false);
+ uninstall(this.app, this.name, true);
loadPlugins(this.app, [this.name], false).then(() => {
afterLoadPlugin(this);
getAllEditor().forEach(editor => {
diff --git a/app/src/plugin/loader.ts b/app/src/plugin/loader.ts
index 911a53201a..e2447d448c 100644
--- a/app/src/plugin/loader.ts
+++ b/app/src/plugin/loader.ts
@@ -229,10 +229,10 @@ export const reloadPlugin = async (app: App, data: {
} = {}) => {
const {upsertCodePlugins = [], upsertDataPlugins = [], removePlugins = []} = data;
removePlugins.forEach((item) => {
- uninstall(app, item, true);
+ uninstall(app, item, false);
});
upsertCodePlugins.forEach((item) => {
- uninstall(app, item, false);
+ uninstall(app, item, true);
});
loadPlugins(app, upsertCodePlugins, false).then(() => {
app.plugins.forEach(item => {
diff --git a/app/src/plugin/uninstall.ts b/app/src/plugin/uninstall.ts
index 5e4b6181e7..9615046d88 100644
--- a/app/src/plugin/uninstall.ts
+++ b/app/src/plugin/uninstall.ts
@@ -8,7 +8,7 @@ import {Constants} from "../constants";
import {setStorageVal} from "../protyle/util/compatibility";
import {getAllEditor} from "../layout/getAll";
-export const uninstall = (app: App, name: string, isUninstall: boolean) => {
+export const uninstall = (app: App, name: string, isReload: boolean) => {
app.plugins.find((plugin: Plugin, index) => {
if (plugin.name === name) {
try {
@@ -16,7 +16,7 @@ export const uninstall = (app: App, name: string, isUninstall: boolean) => {
} catch (e) {
console.error(`plugin ${plugin.name} onunload error:`, e);
}
- if (isUninstall) {
+ if (!isReload) {
try {
plugin.uninstall();
} catch (e) {
@@ -30,7 +30,13 @@ export const uninstall = (app: App, name: string, isUninstall: boolean) => {
const modelsKeys = Object.keys(plugin.models);
getAllModels().custom.forEach(custom => {
if (modelsKeys.includes(custom.type)) {
- custom.parent.parent.removeTab(custom.parent.id);
+ if (isReload) {
+ if (custom.update) {
+ custom.update();
+ }
+ } else {
+ custom.parent.parent.removeTab(custom.parent.id);
+ }
}
});
/// #endif