This commit is contained in:
Vanessa 2023-05-17 15:36:21 +08:00
parent c12547f6fd
commit 63c83a2685
2 changed files with 11 additions and 5 deletions

View file

@ -43,6 +43,10 @@ export class Plugin {
// 加载
}
public onunload() {
// 禁用/卸载
}
public addTopBar(options: {
icon: string,
title: string,

View file

@ -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 => {
@ -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) {
@ -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;
}
});