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/15455

Vanessa98a9635dd30a
diff --git a/app/src/plugin/index.ts b/app/src/plugin/index.ts
index 6036a5daf7..efc4cf97e1 100644
--- a/app/src/plugin/index.ts
+++ b/app/src/plugin/index.ts
@@ -6,7 +6,7 @@ import {isMobile, isWindow} from "../util/functions";
import {Custom} from "../layout/dock/Custom";
import {getAllModels} from "../layout/getAll";
import {Tab} from "../layout/Tab";
-import {setPanelFocus} from "../layout/util";
+import {resizeTopBar, setPanelFocus} from "../layout/util";
import {getDockByType} from "../layout/tabUtil";
///#else
import {MobileCustom} from "../mobile/dock/MobileCustom";
@@ -194,6 +194,17 @@ export class Plugin {
iconElement.innerHTML = options.icon.startsWith("icon") ? `<svg><use xlink:href="#${options.icon}"></use></svg>` : options.icon;
iconElement.addEventListener("click", options.callback);
iconElement.setAttribute("data-location", options.position || "right");
+ resizeTopBar();
+ }
+ if (isMobile()) {
+ if (!window.siyuan.storage[Constants.LOCAL_PLUGINTOPUNPIN].includes(iconElement.id)) {
+ document.querySelector("#menuAbout")?.after(iconElement);
+ }
+ } else if (!isWindow()) {
+ if (window.siyuan.storage[Constants.LOCAL_PLUGINTOPUNPIN].includes(iconElement.id)) {
+ iconElement.classList.add("fn__none");
+ }
+ document.querySelector("#" + (iconElement.getAttribute("data-location") === "right" ? "barPlugins" : "drag"))?.before(iconElement);
}
this.topBarIcons.push(iconElement);
return iconElement;
@@ -206,6 +217,14 @@ export class Plugin {
/// #if !MOBILE
options.element.setAttribute("data-location", options.position || "right");
this.statusBarIcons.push(options.element);
+ const statusElement = document.getElementById("status");
+ if (statusElement) {
+ if (options.element.getAttribute("data-location") === "right") {
+ statusElement.insertAdjacentElement("beforeend", options.element);
+ } else {
+ statusElement.insertAdjacentElement("afterbegin", options.element);
+ }
+ }
return options.element;
/// #endif
}
diff --git a/app/src/plugin/loader.ts b/app/src/plugin/loader.ts
index 0e6b122ac9..98b39a7e1b 100644
--- a/app/src/plugin/loader.ts
+++ b/app/src/plugin/loader.ts
@@ -9,7 +9,7 @@ import {getFrontend, isMobile, isWindow} from "../util/functions";
import {Constants} from "../constants";
import {uninstall} from "./uninstall";
import {setStorageVal} from "../protyle/util/compatibility";
-import { getAllEditor } from "../layout/getAll";
+import {getAllEditor} from "../layout/getAll";
const requireFunc = (key: string) => {
const modules = {
@@ -92,7 +92,7 @@ export const loadPlugin = async (app: App, item: IPluginData) => {
afterLoadPlugin(plugin);
saveLayout();
getAllEditor().forEach(editor => {
- editor.protyle.toolbar.update(editor.protyle);
+ editor.protyle.toolbar.update(editor.protyle);
});
return plugin;
};
@@ -129,6 +129,9 @@ export const afterLoadPlugin = (plugin: Plugin) => {
if (!isWindow() || isMobile()) {
plugin.topBarIcons.forEach(element => {
+ if (document.contains(element)) {
+ return;
+ }
if (isMobile()) {
if (!window.siyuan.storage[Constants.LOCAL_PLUGINTOPUNPIN].includes(element.id)) {
document.querySelector("#menuAbout").after(element);
@@ -144,6 +147,9 @@ export const afterLoadPlugin = (plugin: Plugin) => {
/// #if !MOBILE
resizeTopBar();
plugin.statusBarIcons.forEach(element => {
+ if (document.contains(element)) {
+ return;
+ }
const statusElement = document.getElementById("status");
if (element.getAttribute("data-location") === "right") {
statusElement.insertAdjacentElement("beforeend", element);
@@ -167,7 +173,7 @@ export const afterLoadPlugin = (plugin: Plugin) => {
updateDock(dockItem, index, plugin, "Bottom");
});
Object.keys(plugin.docks).forEach(key => {
- if (window.siyuan.storage[Constants.LOCAL_PLUGIN_DOCKS][plugin.name] && window.siyuan.storage[Constants.LOCAL_PLUGIN_DOCKS][plugin.name][key]) {
+ 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];
}
const dock = plugin.docks[key];