Vanessa 2023-01-26 20:15:54 +08:00
parent 2e773ade52
commit c701aeba83

View file

@ -29,6 +29,7 @@ import {goBack, goForward} from "./backForward";
import {replaceLocalPath} from "../editor/rename"; import {replaceLocalPath} from "../editor/rename";
import {workspaceMenu} from "../menus/workspace"; import {workspaceMenu} from "../menus/workspace";
import {getWorkspaceName} from "./noRelyPCFunction"; import {getWorkspaceName} from "./noRelyPCFunction";
import {setTabPosition} from "../window/setHeader";
const matchKeymap = (keymap: Record<string, IKeymapItem>, key1: "general" | "editor", key2?: "general" | "insert" | "heading" | "list" | "table") => { const matchKeymap = (keymap: Record<string, IKeymapItem>, key1: "general" | "editor", key2?: "general" | "insert" | "heading" | "list" | "table") => {
if (key1 === "general") { if (key1 === "general") {
@ -464,13 +465,21 @@ export const initWindow = () => {
}); });
const toolbarElement = document.getElementById("toolbar"); const toolbarElement = document.getElementById("toolbar");
currentWindow.on("enter-full-screen", () => { currentWindow.on("enter-full-screen", () => {
toolbarElement.style.paddingLeft = "0"; if (isWindow()) {
setTabPosition();
} else {
toolbarElement.style.paddingLeft = "0";
}
}); });
currentWindow.on("leave-full-screen", () => { currentWindow.on("leave-full-screen", () => {
toolbarElement.setAttribute("style", ""); if (isWindow()) {
setTabPosition();
} else {
toolbarElement.setAttribute("style", "");
}
}); });
if (currentWindow.isFullScreen()) { if (currentWindow.isFullScreen() && !isWindow()) {
toolbarElement.style.paddingLeft = "0"; toolbarElement.style.paddingLeft = "0";
} }
return; return;
@ -478,16 +487,17 @@ export const initWindow = () => {
document.body.classList.add("body--win32"); document.body.classList.add("body--win32");
// 添加应用图标 // 添加应用图标
const toolbar = document.getElementById("toolbar"); if (!isWindow()) {
toolbar.insertAdjacentHTML("afterbegin", `<div class="toolbar__item" id="windowAppIcon"> const toolbarElement = document.getElementById("toolbar");
toolbarElement.insertAdjacentHTML("afterbegin", `<div class="toolbar__item" id="windowAppIcon">
<svg> <svg>
<use xlink:href="#iconSiYuan"></use> <use xlink:href="#iconSiYuan"></use>
</svg> </svg>
</div>`); </div>`);
}
// 添加窗口控件 // 添加窗口控件
const controlsElement = document.getElementById("windowControls"); const controlsHTML = `<div class="toolbar__item b3-tooltips b3-tooltips__sw" aria-label="${window.siyuan.languages.min}" id="minWindow">
controlsElement.innerHTML = `<div class="toolbar__item b3-tooltips b3-tooltips__sw" aria-label="${window.siyuan.languages.min}" id="minWindow">
<svg> <svg>
<use xlink:href="#iconMin"></use> <use xlink:href="#iconMin"></use>
</svg> </svg>
@ -507,6 +517,11 @@ export const initWindow = () => {
<use xlink:href="#iconClose"></use> <use xlink:href="#iconClose"></use>
</svg> </svg>
</div>`; </div>`;
if (isWindow()) {
document.body.insertAdjacentHTML("beforeend", `<div style="position: fixed;top: 0;right: 0;display: flex;z-index: 502;">${controlsHTML}</div>`)
} else {
document.getElementById("windowControls").innerHTML = controlsHTML;
}
const maxBtnElement = document.getElementById("maxWindow"); const maxBtnElement = document.getElementById("maxWindow");
const restoreBtnElement = document.getElementById("restoreWindow"); const restoreBtnElement = document.getElementById("restoreWindow");