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

Vanessa5046c8d8623a
diff --git a/app/src/plugin/loader.ts b/app/src/plugin/loader.ts
index 8510a22102..9eaac8f6ed 100644
--- a/app/src/plugin/loader.ts
+++ b/app/src/plugin/loader.ts
@@ -7,6 +7,7 @@ import {exportLayout, resizeTopbar} from "../layout/util";
import {API} from "./API";
import {getFrontend, isMobile, isWindow} from "../util/functions";
import {Constants} from "../constants";
+import {Menu} from "./Menu";
const getObject = (key: string) => {
const api = {
@@ -138,9 +139,20 @@ export const afterLoadPlugin = (plugin: Plugin) => {
}
if (!isWindow() || isMobile()) {
+ const pluginMenu: IMenu[] = []
plugin.topBarIcons.forEach(element => {
if (isMobile()) {
- document.querySelector("#menuAbout").after(element);
+ if (window.siyuan.storage[Constants.LOCAL_PLUGINTOPUNPIN].includes(element.id)) {
+ pluginMenu.push({
+ iconHTML: element.firstElementChild.outerHTML,
+ label: element.textContent.trim(),
+ click() {
+ element.dispatchEvent(new CustomEvent("click"));
+ }
+ })
+ } else {
+ document.querySelector("#menuAbout").after(element);
+ }
} else if (!isWindow()) {
if (window.siyuan.storage[Constants.LOCAL_PLUGINTOPUNPIN].includes(element.id)) {
element.classList.add("fn__none");
@@ -148,6 +160,20 @@ export const afterLoadPlugin = (plugin: Plugin) => {
document.querySelector("#" + (element.getAttribute("data-position") === "right" ? "barPlugins" : "drag")).before(element);
}
});
+ if (isMobile() && pluginMenu.length > 0) {
+ const pluginElement = document.createElement("div")
+ pluginElement.classList.add("b3-menu__item")
+ pluginElement.setAttribute("data-menu", "true")
+ pluginElement.innerHTML = `<svg class="b3-menu__icon"><use xlink:href="#iconPlugin"></use></svg><span class="b3-menu__label">${window.siyuan.languages.plugin}</span>`
+ pluginElement.addEventListener("click", () => {
+ const menu = new Menu()
+ pluginMenu.forEach(item => {
+ menu.addItem(item)
+ })
+ menu.fullscreen();
+ })
+ document.querySelector("#menuAbout").after(pluginElement);
+ }
}
/// #if !MOBILE
resizeTopbar();