Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: https://github.com/siyuan-note/siyuan/issues/17506

Vanessa79caaf248f21
diff --git a/app/src/plugin/index.ts b/app/src/plugin/index.ts
index 8207f39185..c948673de8 100644
--- a/app/src/plugin/index.ts
+++ b/app/src/plugin/index.ts
@@ -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];
}
diff --git a/app/src/plugin/loader.ts b/app/src/plugin/loader.ts
index fbe746232d..0ba86d63ce 100644
--- a/app/src/plugin/loader.ts
+++ b/app/src/plugin/loader.ts
@@ -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()) {
- return;
- }
+ addPluginDock(plugin);
+};
+export const addPluginDock = (plugin: Plugin) => {
/// #if !MOBILE
+ if (isWindow() || !window.siyuan.layout.leftDock) {
+ return;
+ }
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];
}