This commit is contained in:
parent
e03644895d
commit
636039ea52
3 changed files with 21 additions and 7 deletions
|
@ -72,11 +72,11 @@ class App {
|
|||
initAssets();
|
||||
fetchPost("/api/setting/getCloudUser", {}, userResponse => {
|
||||
window.siyuan.user = userResponse.data;
|
||||
loadPlugins(siyuanApp);
|
||||
fetchPost("/api/system/getEmojiConf", {}, emojiResponse => {
|
||||
window.siyuan.emojis = emojiResponse.data as IEmoji[];
|
||||
initFramework();
|
||||
initRightMenu();
|
||||
loadPlugins(siyuanApp);
|
||||
openChangelog();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -5,6 +5,7 @@ import {Dialog} from "../dialog";
|
|||
import {MenuItem} from "../menus/Menu";
|
||||
import {Menu as SiyuanMenu} from "../menus/Menu";
|
||||
import {fetchGet, fetchPost, fetchSyncPost} from "../util/fetch";
|
||||
import {isMobile} from "../util/functions";
|
||||
|
||||
export class Menu {
|
||||
private menu: SiyuanMenu;
|
||||
|
@ -58,6 +59,7 @@ export class Menu {
|
|||
return;
|
||||
}
|
||||
this.menu.fullscreen(position);
|
||||
this.menu.element.style.zIndex = "310";
|
||||
}
|
||||
|
||||
close() {
|
||||
|
@ -74,4 +76,5 @@ export const API = {
|
|||
Plugin: Plugin,
|
||||
Dialog,
|
||||
Menu,
|
||||
isMobile
|
||||
};
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import {App} from "../index";
|
||||
import {EventBus} from "./EventBus";
|
||||
import {fetchPost} from "../util/fetch";
|
||||
import {isMobile, isWindow} from "../util/functions";
|
||||
|
||||
export class Plugin {
|
||||
public i18n: IObject;
|
||||
|
@ -28,12 +29,22 @@ export class Plugin {
|
|||
callback: (evt: MouseEvent) => void
|
||||
}) {
|
||||
const iconElement = document.createElement("div");
|
||||
iconElement.className = "toolbar__item b3-tooltips b3-tooltips__sw";
|
||||
iconElement.setAttribute("aria-label", options.title);
|
||||
iconElement.setAttribute("data-menu", "true");
|
||||
iconElement.innerHTML = options.icon.startsWith("icon") ? `<svg><use xlink:href="#${options.icon}"></use></svg>` : options.icon;
|
||||
iconElement.addEventListener("click", options.callback);
|
||||
document.querySelector("#" + (options.position === "right" ? "barSearch" : "drag")).before(iconElement);
|
||||
if (isMobile()) {
|
||||
iconElement.className = "b3-menu__item";
|
||||
iconElement.setAttribute("aria-label", options.title);
|
||||
iconElement.setAttribute("data-menu", "true");
|
||||
iconElement.innerHTML = (options.icon.startsWith("icon") ? `<svg class="b3-menu__icon"><use xlink:href="#${options.icon}"></use></svg>` : options.icon) +
|
||||
`<span class="b3-menu__label">${options.title}</span>`;
|
||||
iconElement.addEventListener("click", options.callback);
|
||||
document.querySelector("#menuAbout").after(iconElement);
|
||||
} else if (!isWindow()) {
|
||||
iconElement.className = "toolbar__item b3-tooltips b3-tooltips__sw";
|
||||
iconElement.setAttribute("aria-label", options.title);
|
||||
iconElement.setAttribute("data-menu", "true");
|
||||
iconElement.innerHTML = options.icon.startsWith("icon") ? `<svg><use xlink:href="#${options.icon}"></use></svg>` : options.icon;
|
||||
iconElement.addEventListener("click", options.callback);
|
||||
document.querySelector("#" + (options.position === "right" ? "barSearch" : "drag")).before(iconElement);
|
||||
}
|
||||
return iconElement;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue