diff --git a/app/src/layout/dock/index.ts b/app/src/layout/dock/index.ts index d148c03d9..beec2df38 100644 --- a/app/src/layout/dock/index.ts +++ b/app/src/layout/dock/index.ts @@ -825,6 +825,9 @@ export class Dock { if (custom.parent) { custom.parent.parent.removeTab(custom.parent.id); } + if (this.element.querySelectorAll(".dock__item").length === 1 ) { + this.element.classList.add("fn__none"); + } delete this.data[key]; } diff --git a/app/src/plugin/uninstall.ts b/app/src/plugin/uninstall.ts index 0e19e4c32..1bb2b3790 100644 --- a/app/src/plugin/uninstall.ts +++ b/app/src/plugin/uninstall.ts @@ -56,16 +56,40 @@ export const uninstall = (app: App, name: string, isReload: boolean) => { // rm dock const docksKeys = Object.keys(plugin.docks); docksKeys.forEach(key => { - if (window.siyuan.storage[Constants.LOCAL_PLUGIN_DOCKS][plugin.name] && window.siyuan.storage[Constants.LOCAL_PLUGIN_DOCKS][plugin.name][key]) { - window.siyuan.storage[Constants.LOCAL_PLUGIN_DOCKS][plugin.name][key].show = - !!document.querySelector(`.dock__item[data-type="${key}"]`)?.classList.contains("dock__item--active"); + let dockIconElement; + if (window.siyuan.storage[Constants.LOCAL_PLUGIN_DOCKS][plugin.name] && + window.siyuan.storage[Constants.LOCAL_PLUGIN_DOCKS][plugin.name][key]) { + dockIconElement = document.querySelector(`.dock__item[data-type="${key}"]`); + if (dockIconElement) { + window.siyuan.storage[Constants.LOCAL_PLUGIN_DOCKS][plugin.name][key].show = dockIconElement.classList.contains("dock__item--active"); + window.siyuan.storage[Constants.LOCAL_PLUGIN_DOCKS][plugin.name][key].size = { + height: parseInt(dockIconElement.getAttribute("data-height")) || null, + width: parseInt(dockIconElement.getAttribute("data-width")) || null + }; + } } + if (Object.keys(window.siyuan.layout.leftDock.data).includes(key)) { window.siyuan.layout.leftDock.remove(key); + if (dockIconElement) { + window.siyuan.storage[Constants.LOCAL_PLUGIN_DOCKS][plugin.name][key].position = + "Left" + (dockIconElement.getAttribute("data-index") === "0" ? "Top" : "Bottom"); + } } else if (Object.keys(window.siyuan.layout.rightDock.data).includes(key)) { window.siyuan.layout.rightDock.remove(key); + if (dockIconElement) { + window.siyuan.storage[Constants.LOCAL_PLUGIN_DOCKS][plugin.name][key].position = + "Right" + (dockIconElement.getAttribute("data-index") === "0" ? "Top" : "Bottom"); + } } else if (Object.keys(window.siyuan.layout.bottomDock.data).includes(key)) { window.siyuan.layout.bottomDock.remove(key); + if (dockIconElement) { + window.siyuan.storage[Constants.LOCAL_PLUGIN_DOCKS][plugin.name][key].position = + "Bottom" + (dockIconElement.getAttribute("data-index") === "0" ? "Left" : "Right"); + } + } + if (dockIconElement) { + setStorageVal(Constants.LOCAL_PLUGIN_DOCKS, window.siyuan.storage[Constants.LOCAL_PLUGIN_DOCKS]); } }); /// #endif