快递报价:工作区 iframe 内不再重复显示已打开页面标签栏

- 已打开页面标签栏只在最外层窗口渲染,iframe 子页面不再出现同一条标签栏,
  避免点标签时在 iframe 内部再套一层快递报价工作区(页面上出现两份同样的页签+标签行)
- 快递报价工作区注入的样式同时隐藏 .open-tabs,兜住浏览器缓存的旧子页面
This commit is contained in:
renshen 2026-10-13 15:51:04 +08:00
parent 1c00548396
commit 45a28aa76c
3 changed files with 10 additions and 2 deletions

View File

@ -83,7 +83,8 @@
}
// Preserve each page's own scripts, forms and routes in its document.
const style = doc.createElement('style');
style.textContent = '.js-menu,body>.container,#header [data-page-title-first]{display:none!important} #panel{margin:0!important;padding:0!important} #main-body>.container{margin:0!important;padding:0!important;width:100%!important} #header{padding:0!important;margin:0!important}';
// 子页面在 iframe 里不再显示外层那一整排菜单和标签栏,只保留页面本身。
style.textContent = '.js-menu,body>.container,#header [data-page-title-first],.open-tabs{display:none!important} #panel{margin:0!important;padding:0!important} #main-body>.container{margin:0!important;padding:0!important;width:100%!important} #header{padding:0!important;margin:0!important}';
doc.head.appendChild(style);
frame.style.visibility = 'visible';
delete frame.dataset.failed;

View File

@ -79,6 +79,11 @@
if (!root) {
return;
}
// 目录里有用 iframe 打开子页面的页面(例如快递报价)。iframe 内不再显示标签栏:
// 它既和外层那条重复,点标签也只会在 iframe 内部再套一层同样的页面。
if (window.self !== window.top) {
return;
}
const list = root.querySelector('[data-open-tabs-list]');
const userId = root.dataset.userId || 'anon';
const storageKey = 'caiwu.open-pages.v1.' + userId;

View File

@ -202,7 +202,9 @@ class NavigationTest extends FeatureTestCase
// 已打开页面标签栏(固定在页面上方,点开的页面并排显示)。
->assertSee('data-open-tabs', false)
->assertSee('data-open-tabs-list', false)
->assertSee('caiwu.open-pages.v1.', false);
->assertSee('caiwu.open-pages.v1.', false)
// 目录 iframe 里的子页面不再重复渲染这条标签栏。
->assertSee('window.self !== window.top', false);
}
public function testProcessStatisticsPageIsAvailableUnderRiskControl(): void