Vanessa 2023-06-03 21:45:24 +08:00
parent f99d9e19bc
commit f43770d8d2
7 changed files with 43 additions and 20 deletions

View file

@ -77,7 +77,7 @@ export class Plugin {
const iconElement = document.createElement("div");
iconElement.setAttribute("data-menu", "true");
iconElement.addEventListener("click", options.callback);
iconElement.id = "plugin" + genUUID();
iconElement.id = `plugin_${this.name}_${this.topBarIcons.length}`;
if (isMobile()) {
iconElement.className = "b3-menu__item";
iconElement.innerHTML = (options.icon.startsWith("icon") ? `<svg class="b3-menu__icon"><use xlink:href="#${options.icon}"></use></svg>` : options.icon) +

View file

@ -2,10 +2,11 @@ import {fetchSyncPost} from "../util/fetch";
import {App} from "../index";
import {Plugin} from "./index";
/// #if !MOBILE
import {exportLayout} from "../layout/util";
import {exportLayout, resizeTopbar} from "../layout/util";
/// #endif
import {API} from "./API";
import {getFrontend, isMobile, isWindow} from "../util/functions";
import {Constants} from "../constants";
const getObject = (key: string) => {
const api = {
@ -141,9 +142,13 @@ export const afterLoadPlugin = (plugin: Plugin) => {
if (isMobile()) {
document.querySelector("#menuAbout").after(element);
} else if (!isWindow()) {
if (window.siyuan.storage[Constants.LOCAL_PLUGINTOPUNPIN].includes(element.id)) {
element.classList.add("fn__none");
}
document.querySelector("#" + (element.getAttribute("data-position") === "right" ? "barPlugins" : "drag")).before(element);
}
});
resizeTopbar();
}
/// #if !MOBILE
mergePluginHotkey(plugin);

View file

@ -1,7 +1,7 @@
import {App} from "../index";
import {Plugin} from "../plugin";
import {getAllModels} from "../layout/getAll";
import {exportLayout} from "../layout/util";
import {exportLayout, resizeTopbar} from "../layout/util";
import {Constants} from "../constants";
export const uninstall = (app: App, name: string) => {
@ -24,6 +24,7 @@ export const uninstall = (app: App, name: string) => {
plugin.topBarIcons.forEach(item => {
item.remove();
});
resizeTopbar();
// rm statusBar
/// #if !MOBILE
plugin.statusBarIcons.forEach(item => {