Skip to content

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

:art: fix https://github.com/siyuan-note/siyuan/issues/8408

Vanessaac662902d1a3
diff --git a/app/src/plugin/index.ts b/app/src/plugin/index.ts
index c3621657fa..2695e8d367 100644
--- a/app/src/plugin/index.ts
+++ b/app/src/plugin/index.ts
@@ -18,6 +18,7 @@ export class Plugin {
public data: any = {};
public name: string;
public topBarIcons: Element[] = [];
+ public statusBarIcons: Element[] = [];
public commands: ICommand[] = [];
public models: {
/// #if !MOBILE
@@ -68,7 +69,7 @@ export class Plugin {
public addTopBar(options: {
icon: string,
title: string,
- position?: "right",
+ position?: "right" | "left",
callback: (evt: MouseEvent) => void
}) {
const iconElement = document.createElement("div");
@@ -84,12 +85,23 @@ export class Plugin {
iconElement.setAttribute("aria-label", options.title);
iconElement.innerHTML = options.icon.startsWith("icon") ? `<svg><use xlink:href="#${options.icon}"></use></svg>` : options.icon;
iconElement.addEventListener("click", options.callback);
- iconElement.setAttribute("data-position", options.position);
+ iconElement.setAttribute("data-position", options.position || "right");
}
this.topBarIcons.push(iconElement);
return iconElement;
}
+ public addStatusBar(options: {
+ element: HTMLElement,
+ position?: "right" | "left",
+ }) {
+ /// #if !MOBILE
+ options.element.setAttribute("data-position", options.position || "right");
+ this.statusBarIcons.push(options.element);
+ return options.element;
+ /// #endif
+ }
+
public openSetting() {
// 打开设置
}
diff --git a/app/src/plugin/loader.ts b/app/src/plugin/loader.ts
index 9e82d1ba17..74536236b0 100644
--- a/app/src/plugin/loader.ts
+++ b/app/src/plugin/loader.ts
@@ -114,6 +114,16 @@ export const afterLoadPlugin = (plugin: Plugin) => {
}
});
}
+ /// #if !MOBILE
+ plugin.statusBarIcons.forEach(element => {
+ const statusElement = document.getElementById("status")
+ if (element.getAttribute("data-position") === "right") {
+ statusElement.insertAdjacentElement("beforeend", element);
+ } else {
+ statusElement.insertAdjacentElement("afterbegin", element);
+ }
+ });
+ /// #endif
if (isWindow()) {
return;
}
diff --git a/app/src/plugin/uninstall.ts b/app/src/plugin/uninstall.ts
index bad5d69a9b..14ac09a109 100644
--- a/app/src/plugin/uninstall.ts
+++ b/app/src/plugin/uninstall.ts
@@ -20,10 +20,16 @@ export const uninstall = (app: App, name: string) => {
custom.parent.parent.removeTab(custom.parent.id);
}
});
- // rm topbar
+ // rm topBar
plugin.topBarIcons.forEach(item => {
item.remove();
});
+ // rm statusBar
+ /// #if !MOBILE
+ plugin.statusBarIcons.forEach(item => {
+ item.remove();
+ });
+ /// #endif
// rm dock
const docksKeys = Object.keys(plugin.docks);
docksKeys.forEach(key => {