Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

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

Vanessa010a3eb00206
diff --git a/app/src/assets/scss/_menu.scss b/app/src/assets/scss/_menu.scss
index b34988b302..1cc89535bd 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 d6c5b3c040..2363f7db13 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 ? `<span class="b3-menu__icon">${iconElement.innerHTML}</span>` : "",
+ 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 d54db0ae13..6711032c8b 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 = `<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>`;
}
diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.ts
index 75a4fda70b..43f2a23736 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
}