-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
The plugin was not executed uninstall() when being uninstalled #16243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -211,8 +211,11 @@ export const afterLoadPlugin = (plugin: Plugin) => { | |
| }; | ||
|
|
||
| export const reloadPlugin = async (app: App, data: { upsertPlugins: string[], removePlugins: string[] }) => { | ||
| data.removePlugins.concat(data.upsertPlugins).forEach((item) => { | ||
| uninstall(app, item); | ||
| data.removePlugins.forEach((item) => { | ||
| uninstall(app, item, true); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 之前缺少 true 参数,导致没有执行插件的 uninstall() 方法 |
||
| }); | ||
| data.upsertPlugins.forEach((item) => { | ||
| uninstall(app, item, false); | ||
| }); | ||
| loadPlugins(app, data.upsertPlugins).then(() => { | ||
| app.plugins.forEach(item => { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| import {App} from "../index"; | ||
| import {Plugin} from "../plugin"; | ||
| import {Plugin} from "./index"; | ||
| /// #if !MOBILE | ||
| import {getAllModels} from "../layout/getAll"; | ||
| import {resizeTopBar} from "../layout/util"; | ||
|
|
@@ -8,20 +8,23 @@ import {Constants} from "../constants"; | |
| import {setStorageVal} from "../protyle/util/compatibility"; | ||
| import {getAllEditor} from "../layout/getAll"; | ||
|
|
||
| export const uninstall = (app: App, name: string, isUninstall = false) => { | ||
| export const uninstall = (app: App, name: string, isUninstall: boolean) => { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. uninstall() 函数之前默认是不执行 uninstall 的,太迷惑人了,改成必选参数以避免以后使用时混淆用途 |
||
| app.plugins.find((plugin: Plugin, index) => { | ||
| if (plugin.name === name) { | ||
| // 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]); | ||
| } | ||
|
Comment on lines
-14
to
+27
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 改进卸载流程 |
||
| // rm tab | ||
| /// #if !MOBILE | ||
| const modelsKeys = Object.keys(plugin.models); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
内核推送,前端不再需要处理