Vanessa 2025-04-01 15:31:00 +08:00
parent 7e09c1b704
commit ee46c6cb01
3 changed files with 24 additions and 14 deletions

View file

@ -99,9 +99,7 @@ export class Tab {
tabElement.style.opacity = "0.38"; tabElement.style.opacity = "0.38";
window.siyuan.dragElement = this.headElement; window.siyuan.dragElement = this.headElement;
} }
if (isWindow() && this.headElement.getBoundingClientRect().top <= 0) { ipcRenderer.send(Constants.SIYUAN_SEND_WINDOWS, {cmd: "resetTabsStyle", data: "removeRegionStyle"});
((this.headElement.parentElement.parentElement.querySelector(".item--readonly .fn__flex-1") as HTMLElement).style as CSSStyleDeclarationElectron).WebkitAppRegion = "";
}
}); });
this.headElement.addEventListener("dragend", (event: DragEvent & { target: HTMLElement }) => { this.headElement.addEventListener("dragend", (event: DragEvent & { target: HTMLElement }) => {
const tabElement = hasClosestByTag(event.target, "LI"); const tabElement = hasClosestByTag(event.target, "LI");
@ -116,7 +114,7 @@ export class Tab {
openNewWindow(this); openNewWindow(this);
} }
}, Constants.TIMEOUT_LOAD); // 等待主进程发送关闭消息 }, Constants.TIMEOUT_LOAD); // 等待主进程发送关闭消息
ipcRenderer.send(Constants.SIYUAN_SEND_WINDOWS, {cmd: "resetTabsStyle"}); ipcRenderer.send(Constants.SIYUAN_SEND_WINDOWS, {cmd: "resetTabsStyle", data: "rmDragStyle"});
/// #else /// #else
document.querySelectorAll(".layout-tab-bars--drag").forEach(item => { document.querySelectorAll(".layout-tab-bars--drag").forEach(item => {
item.classList.remove("layout-tab-bars--drag"); item.classList.remove("layout-tab-bars--drag");
@ -139,9 +137,7 @@ export class Tab {
} }
}); });
} }
if (isWindow() && this.headElement.getBoundingClientRect().top <= 0) { ipcRenderer.send(Constants.SIYUAN_SEND_WINDOWS, {cmd: "resetTabsStyle", data: "addRegionStyle"});
((this.headElement.parentElement.parentElement.querySelector(".item--readonly .fn__flex-1") as HTMLElement).style as CSSStyleDeclarationElectron).WebkitAppRegion = "drag";
}
}); });
} }

View file

@ -471,7 +471,7 @@ export class Files extends Model {
}); });
window.siyuan.dragElement = undefined; window.siyuan.dragElement = undefined;
/// #if !BROWSER /// #if !BROWSER
ipcRenderer.send(Constants.SIYUAN_SEND_WINDOWS, {cmd: "resetTabsStyle"}); ipcRenderer.send(Constants.SIYUAN_SEND_WINDOWS, {cmd: "resetTabsStyle", data: "rmDragStyle"});
/// #else /// #else
document.querySelectorAll(".layout-tab-bars--drag").forEach(item => { document.querySelectorAll(".layout-tab-bars--drag").forEach(item => {
item.classList.remove("layout-tab-bars--drag"); item.classList.remove("layout-tab-bars--drag");

View file

@ -2,6 +2,7 @@ import {exportLayout, getInstanceById} from "../layout/util";
import {Tab} from "../layout/Tab"; import {Tab} from "../layout/Tab";
import {fetchPost} from "../util/fetch"; import {fetchPost} from "../util/fetch";
import {redirectToCheckAuth} from "../util/pathName"; import {redirectToCheckAuth} from "../util/pathName";
import {isWindow} from "../util/functions";
const closeTab = (ipcData: IWebSocketData) => { const closeTab = (ipcData: IWebSocketData) => {
const tab = getInstanceById(ipcData.data); const tab = getInstanceById(ipcData.data);
@ -15,12 +16,25 @@ export const onWindowsMsg = (ipcData: IWebSocketData) => {
closeTab(ipcData); closeTab(ipcData);
break; break;
case "resetTabsStyle": case "resetTabsStyle":
document.querySelectorAll(".layout-tab-bars--drag").forEach(item => { // data: addRegionStyle, rmDragStyle, rmDragStyleRegionStyle
item.classList.remove("layout-tab-bars--drag"); if (ipcData.data === "rmDragStyle") {
}); document.querySelectorAll(".layout-tab-bars--drag").forEach(item => {
document.querySelectorAll(".layout-tab-bar li[data-clone='true']").forEach(tabItem => { item.classList.remove("layout-tab-bars--drag");
tabItem.remove(); });
}); document.querySelectorAll(".layout-tab-bar li[data-clone='true']").forEach(tabItem => {
tabItem.remove();
});
} else if (isWindow()) {
document.querySelectorAll(".layout-tab-bar--readonly > .fn__flex-1").forEach((item: HTMLElement) => {
if (item.getBoundingClientRect().top <= 0) {
if (ipcData.data === "addRegionStyle") {
(item.style as CSSStyleDeclarationElectron).WebkitAppRegion = "drag";
} else if (ipcData.data === "removeRegionStyle") {
(item.style as CSSStyleDeclarationElectron).WebkitAppRegion = "";
}
}
});
}
break; break;
case "lockscreen": case "lockscreen":
exportLayout({ exportLayout({