From e745b2e54b751d6355c52689ac1f5e2f7f34df21 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 17 Aug 2026 21:58:16 +0800 Subject: [PATCH] fix(frontend): restore homepage card grid --- assets/css/frontend/homepage-fixed/base-2.css | 10 +++--- src/Core/ScriptsPart1b.php | 35 +++++++++++++++---- .../post-visual-contract.test.cjs | 21 +++++++++++ 3 files changed, 54 insertions(+), 12 deletions(-) diff --git a/assets/css/frontend/homepage-fixed/base-2.css b/assets/css/frontend/homepage-fixed/base-2.css index 1d65f19e..7ec18baf 100644 --- a/assets/css/frontend/homepage-fixed/base-2.css +++ b/assets/css/frontend/homepage-fixed/base-2.css @@ -385,17 +385,18 @@ html.dark #index-tab-main > .posts-item.list:hover { ================================================================ */ .aksrt-homepage__posts[data-view="card"] { - display: flex; - flex-wrap: wrap; + display: block; margin: -8px; + font-size: 0; } .aksrt-homepage__posts[data-view="card"] > .posts-item { width: calc(33.333% - 16px); margin: 8px; padding: 10px; - display: flex; - flex-direction: column; + display: inline-block; + vertical-align: top; + font-size: 1rem; background: var(--surface-1, #fff); border: none; border-radius: var(--main-radius, var(--radius, 8px)); @@ -507,7 +508,6 @@ posts.posts-item, article.posts-item, #index-tab-main > .posts-item, .home-tab-content .posts-item { - display: block !important; opacity: 1 !important; visibility: visible !important; color: var(--color-ink, #333); diff --git a/src/Core/ScriptsPart1b.php b/src/Core/ScriptsPart1b.php index f0fca837..3f3df401 100644 --- a/src/Core/ScriptsPart1b.php +++ b/src/Core/ScriptsPart1b.php @@ -803,7 +803,6 @@ $hmb_js = get_template_directory() . '/assets/js/header-newadd.js'; if ($is_fixed_homepage) { $enqueue_module('header-components'); // header-slider / hero $enqueue_module('post-card'); - $homepage_css_path = get_template_directory() . '/assets/css/frontend/homepage-fixed.css'; $homepage_style_deps = file_exists($frontend_bundle) ? ['aksrt-frontend-bundle', 'aksrt-header-components', 'aksrt-post-card'] : ['aksrt-zibll-compat-vars', 'aksrt-layout', 'aksrt-header-components', 'aksrt-post-card']; @@ -811,12 +810,34 @@ $hmb_js = get_template_directory() . '/assets/js/header-newadd.js'; $homepage_style_deps, static fn(string $handle): bool => wp_style_is($handle, 'registered') )); - wp_enqueue_style( - 'aksrt-homepage-fixed', - $base_uri . '/assets/css/frontend/homepage-fixed.css', - $homepage_style_deps, - file_exists($homepage_css_path) ? (string) filemtime($homepage_css_path) : $version - ); + + // Enqueue split files directly so every leaf stylesheet receives its own + // cache version. A version on homepage-fixed.css cannot invalidate the + // unversioned nested @imports used by that legacy aggregate file. + $homepage_style_parts = [ + 'base-1', + 'base-2', + 'base-3', + 'ajax-tab-skeleton-placeholder', + 'ajax-tab-error-state', + ]; + $part_deps = $homepage_style_deps; + foreach ($homepage_style_parts as $part_index => $part_name) { + $is_last_part = $part_index === count($homepage_style_parts) - 1; + $part_handle = $is_last_part + ? 'aksrt-homepage-fixed' + : 'aksrt-homepage-fixed-' . sanitize_key($part_name); + $part_relative_path = '/assets/css/frontend/homepage-fixed/' . $part_name . '.css'; + $part_path = get_template_directory() . $part_relative_path; + + wp_enqueue_style( + $part_handle, + $base_uri . $part_relative_path, + $part_deps, + file_exists($part_path) ? (string) filemtime($part_path) : $version + ); + $part_deps = [$part_handle]; + } } // 积分相关:已登录 + 启用积分功能时全站加载 diff --git a/tests/widget-system/post-visual-contract.test.cjs b/tests/widget-system/post-visual-contract.test.cjs index 2e10bfd1..a485895f 100644 --- a/tests/widget-system/post-visual-contract.test.cjs +++ b/tests/widget-system/post-visual-contract.test.cjs @@ -22,6 +22,27 @@ test('post list DOM follows the Zibll flex and multi-image contract', () => { assert.match(data, / { + const css = read('assets/css/frontend/homepage-fixed/base-2.css'); + const scripts = read('src/Core/ScriptsPart1b.php'); + const cardModeStart = css.indexOf('.aksrt-homepage__posts[data-view="card"] {'); + const cardItemStart = css.indexOf('.aksrt-homepage__posts[data-view="card"] > .posts-item {'); + const cardMode = css.slice(cardModeStart, cardItemStart); + const cardItem = css.slice(cardItemStart, css.indexOf('\n}', cardItemStart) + 2); + const visibilityStart = css.indexOf('VISIBILITY LOCK'); + const visibilityEnd = css.indexOf('/* Minimal flex utilities', visibilityStart); + const visibility = css.slice(visibilityStart, visibilityEnd); + + assert.match(cardMode, /display:\s*block/); + assert.match(cardMode, /font-size:\s*0/); + assert.match(cardItem, /width:\s*calc\(33\.333% - 16px\)/); + assert.match(cardItem, /display:\s*inline-block/); + assert.doesNotMatch(visibility, /\.posts-item[\s\S]*?display:\s*block\s*!important/); + assert.match(scripts, /\$homepage_style_parts\s*=\s*\[/); + assert.match(scripts, /filemtime\(\$part_path\)/); + assert.doesNotMatch(scripts, /wp_enqueue_style\(\s*'aksrt-homepage-fixed',\s*\$base_uri\s*\.\s*'\/assets\/css\/frontend\/homepage-fixed\.css'/); +}); + test('site shell has one float owner and fluid zones sit outside main', () => { const layout = read('assets/css/frontend/layout.css'); const archive = read('inc/helpers/aksrt-archive.php');