mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-24 09:16:09 +01:00
This commit is contained in:
parent
fdf9f0d9e4
commit
1ac623ebb1
5 changed files with 79 additions and 17 deletions
48
app/src/plugin/uninstall.ts
Normal file
48
app/src/plugin/uninstall.ts
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
import {App} from "../index";
|
||||
import {Plugin} from "../plugin";
|
||||
import {getAllModels} from "../layout/getAll";
|
||||
import {exportLayout} from "../layout/util";
|
||||
|
||||
export const uninstall = (app: App, name: string) => {
|
||||
app.plugins.find((plugin: Plugin, index) => {
|
||||
if (plugin.name === name) {
|
||||
// rm tab
|
||||
const modelsKeys = Object.keys(plugin.models)
|
||||
getAllModels().custom.forEach(custom => {
|
||||
if (modelsKeys.includes(custom.type)) {
|
||||
custom.parent.parent.removeTab(custom.parent.id)
|
||||
}
|
||||
})
|
||||
// rm topbar
|
||||
plugin.topBarIcons.forEach(item => {
|
||||
item.remove();
|
||||
})
|
||||
// rm dock
|
||||
const docksKeys = Object.keys(plugin.docks)
|
||||
docksKeys.forEach(key => {
|
||||
if (Object.keys(window.siyuan.layout.leftDock.data).includes(key)) {
|
||||
window.siyuan.layout.leftDock.remove(key)
|
||||
} else if (Object.keys(window.siyuan.layout.rightDock.data).includes(key)) {
|
||||
window.siyuan.layout.rightDock.remove(key)
|
||||
} else if (Object.keys(window.siyuan.layout.bottomDock.data).includes(key)) {
|
||||
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) {
|
||||
item.remove();
|
||||
return true;
|
||||
}
|
||||
})
|
||||
// rm plugin
|
||||
app.plugins.splice(index, 1)
|
||||
return true
|
||||
}
|
||||
})
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue