|
@@ -144,9 +144,15 @@ class SidebarManager {
|
|
const wrapper = document.createElement("div");
|
|
const wrapper = document.createElement("div");
|
|
wrapper.id = this.wrapperId;
|
|
wrapper.id = this.wrapperId;
|
|
|
|
|
|
- // 添加初始样式
|
|
|
|
- wrapper.style.width = "100%";
|
|
|
|
-
|
|
|
|
|
|
+ // 保存body的原始样式
|
|
|
|
+ this.originalBodyStyle = {
|
|
|
|
+ width: document.body.style.width,
|
|
|
|
+ margin: document.body.style.margin,
|
|
|
|
+ position: document.body.style.position,
|
|
|
|
+ overflow: document.body.style.overflow,
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ // 包装内容
|
|
while (document.body.firstChild) {
|
|
while (document.body.firstChild) {
|
|
if (document.body.firstChild.id !== this.sidebarId) {
|
|
if (document.body.firstChild.id !== this.sidebarId) {
|
|
wrapper.appendChild(document.body.firstChild);
|
|
wrapper.appendChild(document.body.firstChild);
|
|
@@ -165,6 +171,11 @@ class SidebarManager {
|
|
const wrapper = document.getElementById(this.wrapperId);
|
|
const wrapper = document.getElementById(this.wrapperId);
|
|
if (!wrapper) return;
|
|
if (!wrapper) return;
|
|
|
|
|
|
|
|
+ // 恢复body的原始样式
|
|
|
|
+ if (this.originalBodyStyle) {
|
|
|
|
+ Object.assign(document.body.style, this.originalBodyStyle);
|
|
|
|
+ }
|
|
|
|
+
|
|
while (wrapper.firstChild) {
|
|
while (wrapper.firstChild) {
|
|
document.body.insertBefore(wrapper.firstChild, wrapper);
|
|
document.body.insertBefore(wrapper.firstChild, wrapper);
|
|
}
|
|
}
|
|
@@ -188,15 +199,8 @@ class SidebarManager {
|
|
|
|
|
|
// 使用 RAF 确保 DOM 更新后再添加动画类
|
|
// 使用 RAF 确保 DOM 更新后再添加动画类
|
|
requestAnimationFrame(() => {
|
|
requestAnimationFrame(() => {
|
|
- const wrapper = document.getElementById(this.wrapperId);
|
|
|
|
- const sidebar = document.getElementById(this.sidebarId);
|
|
|
|
-
|
|
|
|
- // 先触发重排
|
|
|
|
- sidebar.getBoundingClientRect();
|
|
|
|
-
|
|
|
|
- // 添加动画类
|
|
|
|
- if (wrapper) wrapper.classList.add("sidebar-open");
|
|
|
|
- if (sidebar) sidebar.classList.add("show");
|
|
|
|
|
|
+ document.body.classList.add("sidebar-open");
|
|
|
|
+ iframe.classList.add("show");
|
|
});
|
|
});
|
|
|
|
|
|
this.isOpen = true;
|
|
this.isOpen = true;
|
|
@@ -215,11 +219,9 @@ class SidebarManager {
|
|
|
|
|
|
try {
|
|
try {
|
|
const sidebar = document.getElementById(this.sidebarId);
|
|
const sidebar = document.getElementById(this.sidebarId);
|
|
- const wrapper = document.getElementById(this.wrapperId);
|
|
|
|
|
|
|
|
- if (sidebar && wrapper) {
|
|
|
|
- // 移除动画类
|
|
|
|
- wrapper.classList.remove("sidebar-open");
|
|
|
|
|
|
+ if (sidebar) {
|
|
|
|
+ document.body.classList.remove("sidebar-open");
|
|
sidebar.classList.remove("show");
|
|
sidebar.classList.remove("show");
|
|
|
|
|
|
// 等待动画完成后再移除元素
|
|
// 等待动画完成后再移除元素
|