Vanessa
2026-04-22 12:12:05 +08:00
parent 71fa534124
commit 79caaf248f
2 changed files with 13 additions and 5 deletions
+2 -1
View File
@@ -17,7 +17,7 @@ import {Setting} from "./Setting";
import {clearOBG} from "../layout/dock/util";
import {Constants} from "../constants";
import {uninstall} from "./uninstall";
import {afterLoadPlugin, loadPlugins} from "./loader";
import {addPluginDock, afterLoadPlugin, loadPlugins} from "./loader";
import {normalizeStoragePath} from "../util/pathName";
export class Plugin {
@@ -450,6 +450,7 @@ export class Plugin {
}
window.siyuan.config.keymap.plugin[this.name][type2]["default"] = hotkey;
}
addPluginDock(this);
return this.docks[type2];
}
+11 -4
View File
@@ -112,7 +112,8 @@ export const loadPlugin = async (app: App, item: IPluginData) => {
const updateDock = (dockItem: Config.IUILayoutDockTab[], index: number, plugin: Plugin, type: string) => {
const dockKeys = Object.keys(plugin.docks);
dockItem.forEach((tabItem: Config.IUILayoutDockTab, tabIndex: number) => {
if (dockKeys.includes(tabItem.type)) {
if (dockKeys.includes(tabItem.type) &&
!document.querySelector(`.dock .dock__item[data-type="${tabItem.type}"]`)) {
if (type === "Left") {
plugin.docks[tabItem.type].config.position = index === 0 ? "LeftTop" : "LeftBottom";
} else if (type === "Right") {
@@ -170,11 +171,14 @@ export const afterLoadPlugin = (plugin: Plugin) => {
}
});
/// #endif
if (isWindow()) {
addPluginDock(plugin);
};
export const addPluginDock = (plugin: Plugin) => {
/// #if !MOBILE
if (isWindow() || !window.siyuan.layout.leftDock) {
return;
}
/// #if !MOBILE
window.siyuan.config.uiLayout.left.data.forEach((dockItem: Config.IUILayoutDockTab[], index: number) => {
updateDock(dockItem, index, plugin, "Left");
});
@@ -185,6 +189,9 @@ export const afterLoadPlugin = (plugin: Plugin) => {
updateDock(dockItem, index, plugin, "Bottom");
});
Object.keys(plugin.docks).forEach(key => {
if (document.querySelector(`.dock .dock__item[data-type="${key}"]`)) {
return;
}
if (window.siyuan.storage[Constants.LOCAL_PLUGIN_DOCKS][plugin.name] && window.siyuan.storage[Constants.LOCAL_PLUGIN_DOCKS][plugin.name][key]) {
plugin.docks[key].config = window.siyuan.storage[Constants.LOCAL_PLUGIN_DOCKS][plugin.name][key];
}