Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

为桌面端窗口标题栏添加应用图标 #7032

Merged
merged 3 commits into from
Jan 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/src/assets/scss/_reset.scss
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ body {
-webkit-font-smoothing: auto;

.toolbar {
padding: 0 0 0 5px;
padding: 0;
}

.fullscreen {
Expand Down
7 changes: 7 additions & 0 deletions app/src/assets/scss/base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,13 @@ progressLoading: 400
padding-left: 0;
}

#windowAppIcon {
-webkit-app-region: drag;
width: 42px;
margin-left: 1px;
justify-content: center;
}

#windowControls {
top: 0;
z-index: 502;
Expand Down
17 changes: 14 additions & 3 deletions app/src/util/onGetConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ export const onGetConfig = (isStart: boolean) => {
};

const initBar = () => {
document.querySelector(".toolbar").innerHTML = `
const toolbar = document.getElementById("toolbar");
toolbar.innerHTML = `
<div id="barWorkspace" class="toolbar__item">
<span class="toolbar__text">${getWorkspaceName()}</span>
<svg class="toolbar__svg"><use xlink:href="#iconDown"></use></svg>
Expand Down Expand Up @@ -208,7 +209,7 @@ const initBar = () => {
<svg><use xlink:href="#icon${window.siyuan.config.appearance.modeOS ? "Mode" : (window.siyuan.config.appearance.mode === 0 ? "Light" : "Dark")}"></use></svg>
</div>
<div class="fn__flex" id="windowControls"></div>`;
document.querySelector(".toolbar").addEventListener("click", (event: MouseEvent) => {
toolbar.addEventListener("click", (event: MouseEvent) => {
let target = event.target as HTMLElement;
while (!target.classList.contains("toolbar")) {
if (target.id === "barBack") {
Expand Down Expand Up @@ -463,8 +464,18 @@ const initWindow = () => {
}
return;
}
const controlsElement = document.querySelector("#windowControls");
document.body.classList.add("body--win32");

//添加应用图标
const toolbar = document.getElementById("toolbar");
toolbar.insertAdjacentHTML("afterbegin", `<div class="toolbar__item" id="windowAppIcon">
<svg>
<use xlink:href="#iconSiYuan"></use>
</svg>
</div>`);

//添加窗口控件
const controlsElement = document.getElementById("windowControls");
controlsElement.innerHTML = `<div class="toolbar__item b3-tooltips b3-tooltips__sw" aria-label="${window.siyuan.languages.min}" id="minWindow">
<svg>
<use xlink:href="#iconMin"></use>
Expand Down