fix(frontend): restore homepage card grid

This commit is contained in:
2026-08-17 21:58:16 +08:00
parent 5d45eb053b
commit e745b2e54b
3 changed files with 54 additions and 12 deletions
@@ -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);
+28 -7
View File
@@ -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];
}
}
// 积分相关:已登录 + 启用积分功能时全站加载
@@ -22,6 +22,27 @@ test('post list DOM follows the Zibll flex and multi-image contract', () => {
assert.match(data, /<a class=\"thumb-items contain\"/);
});
test('homepage card mode keeps the Zibll inline-block three-column flow', () => {
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');