From fe0e0cf8b74abb9f47f4f85dbfaa1fd0778d6a14 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 11 Aug 2026 07:05:42 +0000 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=E5=88=87=E6=8D=A2=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E6=97=B6=E9=A1=B5=E9=9D=A2=E6=BB=9A=E5=8A=A8=E5=88=B0=E9=A1=B6?= =?UTF-8?q?=E9=83=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在 ExamplePage 中监听 current 变化,将 window 与 Layout 内容区滚动复位到顶部。 Co-authored-by: Linzp --- src/ExamplePage.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/ExamplePage.js b/src/ExamplePage.js index c6c8c8c..5b66c05 100644 --- a/src/ExamplePage.js +++ b/src/ExamplePage.js @@ -70,6 +70,22 @@ const ExamplePage = createWithRemoteLoader({ modules: ["components-core:Layout@Page", "components-core:Layout@Menu", "components-core:Global@useGlobalContext"] })(({remoteModules, data, current, menuProps = {}, items, pageProps = {}}) => { const [Page, Menu] = remoteModules; + + useEffect(() => { + window.scrollTo(0, 0); + const mainContent = document.querySelector('.core-page-main-content'); + if (!mainContent) { + return; + } + let el = mainContent; + while (el && el !== document.body) { + if (el.scrollTop) { + el.scrollTop = 0; + } + el = el.parentElement; + } + }, [current]); + return 0 && } {...pageProps}> From fc308cd112cb9c191121f328b16722b502f46d33 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 11 Aug 2026 07:08:44 +0000 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=E7=94=A8=20Common.getScrollEl=20?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E5=88=87=E6=8D=A2=E7=BB=84=E4=BB=B6=E6=BB=9A?= =?UTF-8?q?=E9=A1=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 通过 components-core 的 getScrollEl 获取滚动容器,去掉 DOM 向上遍历。 Co-authored-by: Linzp --- src/ExamplePage.js | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/ExamplePage.js b/src/ExamplePage.js index 5b66c05..13b724e 100644 --- a/src/ExamplePage.js +++ b/src/ExamplePage.js @@ -67,24 +67,16 @@ export const ExampleContent = createWithRemoteLoader({ }); const ExamplePage = createWithRemoteLoader({ - modules: ["components-core:Layout@Page", "components-core:Layout@Menu", "components-core:Global@useGlobalContext"] + modules: ["components-core:Layout@Page", "components-core:Layout@Menu", "components-core:Global@useGlobalContext", "components-core:Common@getScrollEl"] })(({remoteModules, data, current, menuProps = {}, items, pageProps = {}}) => { - const [Page, Menu] = remoteModules; + const [Page, Menu, , getScrollEl] = remoteModules; useEffect(() => { - window.scrollTo(0, 0); - const mainContent = document.querySelector('.core-page-main-content'); - if (!mainContent) { - return; - } - let el = mainContent; - while (el && el !== document.body) { - if (el.scrollTop) { - el.scrollTop = 0; - } - el = el.parentElement; + const scrollEl = getScrollEl(); + if (scrollEl) { + scrollEl.scrollTop = 0; } - }, [current]); + }, [current, getScrollEl]); return 0 &&