diff --git a/app/src/assets/scss/_menu.scss b/app/src/assets/scss/_menu.scss index b34988b30..1cc89535b 100644 --- a/app/src/assets/scss/_menu.scss +++ b/app/src/assets/scss/_menu.scss @@ -104,9 +104,15 @@ align-self: center; height: 14px; width: 14px; + line-height: 14px; margin-right: 8px; color: var(--b3-theme-on-surface); + & > svg { + height: 14px; + width: 14px; + } + &--arrow { margin: 0 0 0 8px; height: 10px; diff --git a/app/src/layout/Wnd.ts b/app/src/layout/Wnd.ts index d6c5b3c04..2363f7db1 100644 --- a/app/src/layout/Wnd.ts +++ b/app/src/layout/Wnd.ts @@ -456,8 +456,12 @@ export class Wnd { private renderTabList(event: MouseEvent) { window.siyuan.menus.menu.remove() Array.from(this.headersElement.children).forEach((item: HTMLElement) => { + const iconElement = item.querySelector(".item__icon") + const graphicElement = item.querySelector(".item__graphic") window.siyuan.menus.menu.append(new MenuItem({ label: item.querySelector(".item__text").textContent, + iconHTML: iconElement ? `${iconElement.innerHTML}` : "", + icon: graphicElement ? graphicElement.firstElementChild.getAttribute("xlink:href").substring(1) : "", click: () => { this.switchTab(item, true); }, diff --git a/app/src/menus/Menu.ts b/app/src/menus/Menu.ts index d54db0ae1..6711032c8 100644 --- a/app/src/menus/Menu.ts +++ b/app/src/menus/Menu.ts @@ -127,7 +127,12 @@ export class MenuItem { window.siyuan.menus.menu.remove(); }); } - let html = `${options.label}`; + let html = `${options.label}`; + if (options.iconHTML) { + html = options.iconHTML + html; + } else { + html = `${html}`; + } if (options.accelerator) { html += `${updateHotkeyTip(options.accelerator)}`; } diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.ts index 75a4fda70..43f2a2373 100644 --- a/app/src/types/index.d.ts +++ b/app/src/types/index.d.ts @@ -472,6 +472,7 @@ declare interface IMenu { submenu?: IMenu[] disabled?: boolean icon?: string + iconHTML?: string current?: boolean bind?: (element: HTMLElement) => void }