Skip to content

Conversation

@TCOTC
Copy link
Contributor

@TCOTC TCOTC commented Oct 29, 2025

fix #16156

卸载插件目前由内核推送,调用 reloadPlugin() 函数之后没有执行插件的 uninstall() 方法。

Comment on lines -841 to -843
if (bazaarType === "plugins") {
uninstall(app, packageName, true);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

内核推送,前端不再需要处理

data.removePlugins.concat(data.upsertPlugins).forEach((item) => {
uninstall(app, item);
data.removePlugins.forEach((item) => {
uninstall(app, item, true);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

之前缺少 true 参数,导致没有执行插件的 uninstall() 方法

import {getAllEditor} from "../layout/getAll";

export const uninstall = (app: App, name: string, isUninstall = false) => {
export const uninstall = (app: App, name: string, isUninstall: boolean) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uninstall() 函数之前默认是不执行 uninstall 的,太迷惑人了,改成必选参数以避免以后使用时混淆用途

Comment on lines -14 to +27
// rm command
try {
plugin.onunload();
if (isUninstall) {
plugin.uninstall();
window.siyuan.storage[Constants.LOCAL_PLUGIN_DOCKS][plugin.name] = {};
setStorageVal(Constants.LOCAL_PLUGIN_DOCKS, window.siyuan.storage[Constants.LOCAL_PLUGIN_DOCKS]);
}
} catch (e) {
console.error(`plugin ${plugin.name} onunload error:`, e);
}
if (isUninstall) {
try {
plugin.uninstall();
} catch (e) {
console.error(`plugin ${plugin.name} uninstall error:`, e);
}
window.siyuan.storage[Constants.LOCAL_PLUGIN_DOCKS][plugin.name] = {};
setStorageVal(Constants.LOCAL_PLUGIN_DOCKS, window.siyuan.storage[Constants.LOCAL_PLUGIN_DOCKS]);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

改进卸载流程

@TCOTC
Copy link
Contributor Author

TCOTC commented Nov 1, 2025

这个 PR 合并之后还需要合并 #16244

@88250
Copy link
Member

88250 commented Nov 1, 2025

收到

@Vanessa219 Vanessa219 merged commit 33d6312 into siyuan-note:dev Nov 2, 2025
1 check passed
@TCOTC TCOTC deleted the fix/uninstall branch November 2, 2025 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants