From 3fbf17d6cd891ca201d245a0701539ae95341069 Mon Sep 17 00:00:00 2001 From: qing <1776177662@qq.com> Date: Wed, 12 Aug 2026 15:38:03 +0800 Subject: [PATCH] =?UTF-8?q?Revert=20"fix(dnfs):=20=E4=B8=BB=E9=A2=98/?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E7=BB=A7=E6=89=BF=E6=94=B9=E4=B8=BA=E4=BB=85?= =?UTF-8?q?=E6=9F=A5=E7=9B=B4=E6=8E=A5=E7=88=B6=E8=8A=82=E7=82=B9=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20getNode=20=E6=9F=A5=E8=AF=A2=E7=9B=AE?= =?UTF-8?q?=E6=A0=87=E9=94=99=E8=AF=AF"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 1774d7d64bbac55f0dc5b2777e403ec8b53c701d. --- fsys/public/js/dnfs.js | 45 ++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/fsys/public/js/dnfs.js b/fsys/public/js/dnfs.js index b2ea1ab..65e397d 100644 --- a/fsys/public/js/dnfs.js +++ b/fsys/public/js/dnfs.js @@ -697,9 +697,11 @@ function formatBytes(n) { return n.toFixed(1) + units[i]; } -/* ===== 父节点主题/样式继承 ===== - * 当前节点不存在 theme/style 子节点时,查找父节点的对应子节点并自动注入 CSS。 - * 已存在的不重复搜索(hasTheme/hasStyle 分别控制)。 */ +/* ===== 祖先主题/样式继承 ===== + * 当前节点不存在 theme/style 子节点时,沿 stack 向根搜索最近祖先的对应节点, + * 自动注入其 CSS。已存在的不重复搜索(hasTheme/hasStyle 分别控制)。 + * 异步 getNode 可能跨导航——用 _inherit_gen 做取消,新导航的 clearAllEffects + * 会移除旧注入。 */ var _inherit_gen = 0; function inheritThemeStyle() { var hasTheme = false, hasStyle = false; @@ -711,28 +713,29 @@ function inheritThemeStyle() { } if (hasTheme && hasStyle) return; - // 仅查询直接父节点 - var parentPid = (stack.length === 0) ? 0 : (stack.length === 1 ? 0 : stack[stack.length - 2]); var gen = ++_inherit_gen; (async function() { - if (gen !== _inherit_gen) return; - try { - var children = await getNode(parentPid); - if (!Array.isArray(children)) return; - for (var j = 0; j < children.length; j++) { - var sp = parseSp(children[j].content); - if (!sp) continue; - if (!hasTheme && sp._sp === 'theme') { - injectSpCss(sp, 'inh-' + children[j].id); - hasTheme = true; - } - if (!hasStyle && sp._sp === 'style') { - injectSpCss(sp, 'inh-' + children[j].id); - hasStyle = true; + for (var i = stack.length - 1; i >= 0; i--) { + if (hasTheme && hasStyle) break; + if (gen !== _inherit_gen) return; + try { + var children = await getNode(stack[i]); + if (!Array.isArray(children)) continue; + for (var j = 0; j < children.length; j++) { + var sp = parseSp(children[j].content); + if (!sp) continue; + if (!hasTheme && sp._sp === 'theme') { + injectSpCss(sp, 'inh-' + children[j].id); + hasTheme = true; + } + if (!hasStyle && sp._sp === 'style') { + injectSpCss(sp, 'inh-' + children[j].id); + hasStyle = true; + } } + } catch (e) { + console.error('继承主题/样式失败:', e); } - } catch (e) { - console.error('继承主题/样式失败:', e); } })(); }