Skip to content

Commit

Permalink
🎨 fix #8277
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed May 17, 2023
1 parent c12547f commit 63c83a2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
4 changes: 4 additions & 0 deletions app/src/plugin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ export class Plugin {
// 加载
}

public onunload() {
// 禁用/卸载
}

public addTopBar(options: {
icon: string,
title: string,
Expand Down
12 changes: 7 additions & 5 deletions app/src/plugin/uninstall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {exportLayout} from "../layout/util";
export const uninstall = (app: App, name: string) => {
app.plugins.find((plugin: Plugin, index) => {
if (plugin.name === name) {
// rm command
plugin.onunload();
// rm tab
const modelsKeys = Object.keys(plugin.models);
getAllModels().custom.forEach(custom => {
Expand All @@ -28,11 +30,6 @@ export const uninstall = (app: App, name: string) => {
window.siyuan.layout.bottomDock.remove(key);
}
});
exportLayout({
reload: false,
onlyData: false,
errorExit: false
});
// rm listen
Array.from(document.childNodes).find(item => {
if (item.nodeType === 8 && item.textContent === name) {
Expand All @@ -42,6 +39,11 @@ export const uninstall = (app: App, name: string) => {
});
// rm plugin
app.plugins.splice(index, 1);
exportLayout({
reload: false,
onlyData: false,
errorExit: false
});
return true;
}
});
Expand Down

0 comments on commit 63c83a2

Please sign in to comment.