This commit is contained in:
Vanessa 2023-05-24 20:06:32 +08:00
parent 1744d6b5cd
commit 580fb4007e
6 changed files with 37 additions and 33 deletions

View file

@ -80,7 +80,7 @@ export const loadPlugin = (app: App, item: IPluginData) => {
const updateDock = (dockItem: IDockTab[], index: number, plugin: Plugin, type: string) => {
const dockKeys = Object.keys(plugin.docks)
const dockKeys = Object.keys(plugin.docks);
dockItem.forEach((tabItem: IDockTab, tabIndex: number) => {
if (dockKeys.includes(tabItem.type)) {
if (type === "Left") {
@ -94,8 +94,8 @@ const updateDock = (dockItem: IDockTab[], index: number, plugin: Plugin, type: s
plugin.docks[tabItem.type].config.show = tabItem.show;
plugin.docks[tabItem.type].config.size = tabItem.size;
}
})
}
});
};
export const afterLoadPlugin = (plugin: Plugin) => {
try {
@ -113,14 +113,14 @@ export const afterLoadPlugin = (plugin: Plugin) => {
});
window.siyuan.config.uiLayout.left.data.forEach((dockItem: IDockTab[], index: number) => {
updateDock(dockItem, index, plugin, "Left")
})
updateDock(dockItem, index, plugin, "Left");
});
window.siyuan.config.uiLayout.right.data.forEach((dockItem: IDockTab[], index: number) => {
updateDock(dockItem, index, plugin, "Right")
})
updateDock(dockItem, index, plugin, "Right");
});
window.siyuan.config.uiLayout.bottom.data.forEach((dockItem: IDockTab[], index: number) => {
updateDock(dockItem, index, plugin, "Bottom")
})
updateDock(dockItem, index, plugin, "Bottom");
});
Object.keys(plugin.docks).forEach(key => {
const dock = plugin.docks[key];
if (dock.config.position.startsWith("Left")) {
@ -153,4 +153,4 @@ export const afterLoadPlugin = (plugin: Plugin) => {
}
});
// 等待 tab 完成后再 init Tab model
}
};

View file

@ -2,6 +2,7 @@ import {App} from "../index";
import {Plugin} from "../plugin";
import {getAllModels} from "../layout/getAll";
import {exportLayout} from "../layout/util";
import {Constants} from "../constants";
export const uninstall = (app: App, name: string) => {
app.plugins.find((plugin: Plugin, index) => {
@ -43,11 +44,14 @@ export const uninstall = (app: App, name: string) => {
});
// rm plugin
app.plugins.splice(index, 1);
exportLayout({
reload: false,
onlyData: false,
errorExit: false
});
setTimeout(() => {
exportLayout({
reload: false,
onlyData: false,
errorExit: false
});
}, Constants.TIMEOUT_LOAD); // 移除页签时切换到新的文档页签,需等待新页签初始化完成,才有 editor.protyle.block 等数据
return true;
}
});