2023-01-26 18:55:17 +08:00
|
|
|
import {isWindow} from "../util/functions";
|
|
|
|
|
import {Wnd} from "../layout/Wnd";
|
|
|
|
|
import {getCurrentWindow} from "@electron/remote";
|
2023-01-27 10:27:14 +08:00
|
|
|
import {Layout} from "../layout";
|
2023-01-26 18:55:17 +08:00
|
|
|
|
|
|
|
|
const getAllWnds = (layout: Layout, wnds: Wnd[]) => {
|
|
|
|
|
for (let i = 0; i < layout.children.length; i++) {
|
|
|
|
|
const item = layout.children[i];
|
|
|
|
|
if (item instanceof Wnd) {
|
|
|
|
|
wnds.push(item);
|
|
|
|
|
} else if (item instanceof Layout) {
|
|
|
|
|
getAllWnds(item, wnds);
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-01-26 23:29:32 +08:00
|
|
|
};
|
2023-01-26 18:55:17 +08:00
|
|
|
export const setTabPosition = () => {
|
|
|
|
|
if (!isWindow()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2023-01-26 23:29:32 +08:00
|
|
|
const wndsTemp: Wnd[] = [];
|
2023-01-26 18:55:17 +08:00
|
|
|
getAllWnds(window.siyuan.layout.layout, wndsTemp);
|
|
|
|
|
wndsTemp.forEach(item => {
|
|
|
|
|
const headerElement = item.headersElement.parentElement;
|
2023-01-26 23:29:32 +08:00
|
|
|
const rect = headerElement.getBoundingClientRect();
|
|
|
|
|
const dragElement = headerElement.querySelector(".item--readonly .fn__flex-1") as HTMLElement;
|
2023-01-26 23:27:30 +08:00
|
|
|
if (rect.top <= 0) {
|
2023-01-26 23:29:32 +08:00
|
|
|
dragElement.style.height = dragElement.parentElement.clientHeight + "px";
|
2023-01-26 18:55:17 +08:00
|
|
|
// @ts-ignore
|
|
|
|
|
dragElement.style.WebkitAppRegion = "drag";
|
|
|
|
|
} else {
|
|
|
|
|
// @ts-ignore
|
|
|
|
|
dragElement.style.WebkitAppRegion = "";
|
|
|
|
|
}
|
|
|
|
|
if ("darwin" === window.siyuan.config.system.os) {
|
|
|
|
|
if (rect.top <= 0 && rect.left <= 0 && !getCurrentWindow().isFullScreen()) {
|
|
|
|
|
item.headersElement.style.paddingLeft = "69px";
|
|
|
|
|
} else {
|
|
|
|
|
item.headersElement.style.paddingLeft = "";
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2023-02-13 11:52:26 +08:00
|
|
|
// 显示器缩放后像素存在小数点偏差 https://github.com/siyuan-note/siyuan/issues/7355
|
|
|
|
|
if (rect.top <= 0 && rect.right + 8 >= window.innerWidth) {
|
2023-01-26 22:52:22 +08:00
|
|
|
(headerElement.lastElementChild as HTMLElement).style.paddingRight = (42 * 3) + "px";
|
2023-01-26 18:55:17 +08:00
|
|
|
} else {
|
|
|
|
|
(headerElement.lastElementChild as HTMLElement).style.paddingRight = "";
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-01-26 23:29:32 +08:00
|
|
|
});
|
|
|
|
|
};
|