Prechádzať zdrojové kódy

:sparkles: fix https://github.com/siyuan-note/siyuan/issues/5772

Vanessa 2 rokov pred
rodič
commit
010a3eb002

+ 6 - 0
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;

+ 4 - 0
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 ? `<span class="b3-menu__icon">${iconElement.innerHTML}</span>` : "",
+                icon: graphicElement ? graphicElement.firstElementChild.getAttribute("xlink:href").substring(1) : "",
                 click: () => {
                     this.switchTab(item, true);
                 },

+ 6 - 1
app/src/menus/Menu.ts

@@ -127,7 +127,12 @@ export class MenuItem {
                 window.siyuan.menus.menu.remove();
             });
         }
-        let html = `<svg class="b3-menu__icon${["HTML (SiYuan)", window.siyuan.languages.template].includes(options.label) ? " ft__error" : ""}" style="${options.icon === "iconClose" ? "height:10px;" : ""}"><use xlink:href="#${options.icon || ""}"></use></svg><span class="b3-menu__label">${options.label}</span>`;
+        let html = `<span class="b3-menu__label">${options.label}</span>`;
+        if (options.iconHTML) {
+            html = options.iconHTML + html;
+        } else {
+            html = `<svg class="b3-menu__icon${["HTML (SiYuan)", window.siyuan.languages.template].includes(options.label) ? " ft__error" : ""}" style="${options.icon === "iconClose" ? "height:10px;" : ""}"><use xlink:href="#${options.icon || ""}"></use></svg>${html}`;
+        }
         if (options.accelerator) {
             html += `<span class="b3-menu__accelerator">${updateHotkeyTip(options.accelerator)}</span>`;
         }

+ 1 - 0
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
 }