feat(frontend): align single post page 1:1 with Zibll

Restore Zibll float dual-column shell, fix single settings DTO key mapping,
reorder article footer/actions, and match author bar, prev/next, title/body
typography, and limit-height expand UX.
This commit is contained in:
kate522 committed 2026-07-13 08:26:36 +08:00
1 parent a651bd6d2d
commit 5ae1a9ad93
12 files changed
+626 -218

No files matched your search

@@ -45,6 +45,12 @@ export const pageSchema = {
post_article_video_cover_scale: 56,
item_heading_bold: false,
post_button_toptext: '喜欢就支持一下吧',
post_rewards_enabled: false,
post_rewards_text: '',
post_rewards_image: '',
post_rewards_btn_text: '赞赏',
article_maxheight_kg: false,
article_maxheight: 1000,
},
groups: [
{
@@ -121,6 +127,12 @@ export const pageSchema = {
{ key: 'post_copyright_enabled', label: '版权信息', type: 'switch', default: true },
{ key: 'post_copyright_text', label: '版权默认文案', type: 'textarea', default: '', help: '留空则自动生成"本文由 XX 原创发布"' },
{ key: 'post_button_toptext', label: '按钮上方文案', type: 'input', default: '喜欢就支持一下吧', help: '显示在点赞/打赏/分享按钮上方' },
{ key: 'post_rewards_enabled', label: '打赏', type: 'switch', default: false },
{ key: 'post_rewards_btn_text', label: '打赏按钮文案', type: 'input', default: '赞赏', dependsOn: { key: 'post_rewards_enabled', value: true } },
{ key: 'post_rewards_text', label: '打赏说明', type: 'input', default: '', dependsOn: { key: 'post_rewards_enabled', value: true } },
{ key: 'post_rewards_image', label: '打赏二维码 URL', type: 'input', default: '', dependsOn: { key: 'post_rewards_enabled', value: true } },
{ key: 'article_maxheight_kg', label: '正文限高', type: 'switch', default: false, help: '开启后长文默认折叠,可展开全文' },
{ key: 'article_maxheight', label: '限高像素', type: 'number', default: 1000, min: 200, max: 5000, dependsOn: { key: 'article_maxheight_kg', value: true } },
],
},
{
+1
View File
@@ -1,3 +1,4 @@
@import url("single-post/shell.css");
@import url("single-post/content.css");
@import url("single-post/code-blocks.css");
@import url("single-post/navigation.css");
@@ -440,3 +440,103 @@ html.dark .post-drop-meta__item:hover {
.author-box__posts a:hover { color: var(--color-primary); }
.author-box__posts a::before { content: '\2022'; color: var(--color-primary); }
/* ===== Zibll single-metabox / author bar ===== */
.article-avatar .user-info {
width: 100%;
}
.article-avatar .avatar-img img,
.article-avatar .avatar {
width: 42px;
height: 42px;
border-radius: 50%;
object-fit: cover;
}
.article-avatar .display-name {
font-weight: 600;
color: var(--key-color, #333);
}
.article-header .article-avatar .relative {
margin-top: 20px;
}
.single-metabox {
right: 0;
font-size: 15px;
--meta-color: var(--muted-color, #777);
}
.single-metabox .post-metas {
background: var(--body-bg-color, #f5f5f5);
right: 0;
padding: 2px 6px;
border-radius: 100px;
color: var(--meta-color);
display: inline-flex;
flex-wrap: wrap;
align-items: center;
gap: 0;
}
.single-metabox .post-metas item {
margin: 0 6px;
font-size: 13px;
}
.single-metabox .post-drop-meta {
position: relative;
display: inline-block;
}
.single-metabox.cover-meta {
font-size: 14px;
right: 1em;
top: 1.6em;
--meta-color: rgba(255, 255, 255, 0.8);
--body-bg-color: rgba(0, 0, 0, 0.3);
}
.line-form-line {
display: block;
height: 1px;
background: var(--main-border-color, rgba(50,50,50,.06));
margin: 12px 0 0;
}
.post-actions {
padding-bottom: 15px;
display: flex;
justify-content: center;
flex-wrap: wrap;
gap: 10px;
}
.post-actions .action {
min-width: 3.2em;
height: 3.2em;
border-radius: 100px;
border: 0;
background: var(--muted-bg-color, #f2f2f2);
color: var(--muted-color, #777);
display: inline-flex;
align-items: center;
justify-content: center;
gap: 4px;
padding: 0 14px;
cursor: pointer;
transition: .15s;
}
.post-actions .action:hover,
.post-actions .action.is-active {
color: var(--focus-color, #f04494);
background: var(--focus-color-opacity1, rgba(240,68,148,.1));
}
.post-actions .action i {
font-size: 16px;
}
+63 -12
View File
@@ -1,20 +1,31 @@
/* ========== Single Post ========== */
.entry-header,
.article-header {
margin-bottom: 28px;
padding-bottom: 18px;
border-bottom: 1px solid var(--color-line-soft);
margin-bottom: 10px;
padding-bottom: 0;
border-bottom: none;
}
/* 标题 — 对齐 zibll: 22px, bold, line-height 1.4 */
.entry-title,
.article-title {
font-size: 28px;
font-weight: 700;
margin: 0 0 18px;
line-height: 1.35;
letter-spacing: -0.01em;
color: var(--color-ink);
font-size: 22px;
font-weight: bold;
margin: 0;
line-height: 1.4;
letter-spacing: 0;
color: var(--key-color, var(--color-ink));
}
.article-header .article-title {
font-size: 22px;
font-weight: bold;
color: var(--key-color, var(--color-ink));
margin-top: 15px;
}
.article-header .article-avatar {
margin-top: 15px;
}
.entry-meta {
@@ -40,15 +51,55 @@
}
/* 内容区 — 对齐 zibll: 16px, line-height 2 */
.entry-content {
.entry-content,
.wp-posts-content {
font-size: 16px;
line-height: 1.95;
color: var(--color-ink);
line-height: 2;
color: var(--main-color, var(--color-ink));
overflow-wrap: break-word;
word-wrap: break-word;
min-height: 90px;
}
/* Zibll content heading bars */
.wp-posts-content > h1:not([class]),
.wp-posts-content > h2:not([class]),
.wp-posts-content > h3:not([class]),
.wp-posts-content > h4:not([class]),
.wp-posts-content > h1.wp-block-heading,
.wp-posts-content > h2.wp-block-heading,
.wp-posts-content > h3.wp-block-heading,
.wp-posts-content > h4.wp-block-heading {
position: relative;
padding-bottom: 8px;
}
.wp-posts-content > h1:not([class]):before,
.wp-posts-content > h2:not([class]):before,
.wp-posts-content > h3:not([class]):before,
.wp-posts-content > h4:not([class]):before,
.wp-posts-content > h1.wp-block-heading:before,
.wp-posts-content > h2.wp-block-heading:before,
.wp-posts-content > h3.wp-block-heading:before,
.wp-posts-content > h4.wp-block-heading:before {
content: "";
position: absolute;
left: 0;
bottom: 0;
width: 40px;
height: 3px;
background: var(--theme-color, var(--focus-color, #f04494));
border-radius: 5px;
}
.wp-posts-content > h3:not([class]):before,
.wp-posts-content > h4:not([class]):before,
.wp-posts-content > h3.wp-block-heading:before,
.wp-posts-content > h4.wp-block-heading:before {
width: 28px;
height: 2px;
}
.entry-content > *:first-child {
margin-top: 0;
}
@@ -1,3 +1,47 @@
/* ===== Zibll article-nav (prev/next) ===== */
.article-nav {
display: block;
width: 100%;
}
.article-nav .box-body {
width: calc(50% - 7px);
margin: 0;
display: inline-block;
vertical-align: top;
}
.article-nav .box-body + .box-body {
margin-right: 0;
float: right;
text-align: right;
}
.article-nav a {
display: block;
color: inherit;
text-decoration: none;
}
.article-nav a:hover {
color: var(--focus-color, #f04494);
}
.article-nav .text-ellipsis-2 {
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
font-size: 14px;
line-height: 1.5;
color: var(--key-color, #333);
}
.article-nav p {
margin: 0 0 6px;
font-size: 12px;
}
/* ===== Previous / Next Navigation ===== */
.post-nav-box {
display: grid;
@@ -112,12 +156,45 @@
/* ===== Comment Card Spacing ===== */
.comments-card { margin-bottom: 16px; }
/* ===== Content Height Clamp ===== */
/* ===== Content Height Clamp (Zibll) ===== */
.limit-height,
.wp-posts-content.limit-height {
position: relative;
overflow: hidden;
}
.limit-height .read-more {
position: absolute;
bottom: 0;
width: 100%;
text-align: center;
background-image: linear-gradient(0deg, var(--main-bg-color, #fff) 70px, rgba(255, 255, 255, 0) 100%);
animation: lazy_fade 0.5s;
z-index: 80;
}
html.dark .limit-height .read-more,
body.dark-theme .limit-height .read-more {
background-image: linear-gradient(0deg, var(--main-bg-color, #2a2a2a) 70px, rgba(53, 54, 55, 0) 100%);
}
.limit-height .read-more a,
.limit-height .read-more .read-more-open {
padding: 25px 0;
display: inline-block;
color: var(--focus-color, #f04494);
margin-top: 80px;
cursor: pointer;
background: none;
border: 0;
font-size: 14px;
}
@keyframes lazy_fade {
from { opacity: 0; }
to { opacity: 1; }
}
.wp-posts-content.limit-height::after {
content: '';
position: absolute;
+59
View File
@@ -0,0 +1,59 @@
/* Single page shell — Zibll float dual-column (scoped to body.single) */
body.single .container {
position: relative;
}
body.single .content-wrap {
float: left;
width: 100%;
}
/* Clear floats after main dual-column shell */
body.single main.container::after {
content: "";
display: table;
clear: both;
}
/* Default: no sidebar full width */
body.single.container--no-sidebar .content-layout,
body.single .container--no-sidebar .content-layout,
body.single main.container--no-sidebar .content-layout {
margin-right: 0;
}
/* Zibll site-layout-2: content left, sidebar right (311px) */
@media (min-width: 992px) {
body.single:not(.no-sidebar) main.container:not(.container--no-sidebar) .content-layout {
margin-right: calc(var(--sidebar-width, 311px) + 15px);
}
body.single:not(.no-sidebar) main.container:not(.container--no-sidebar) > .sidebar {
float: left;
width: var(--sidebar-width, 311px);
margin-left: calc(0px - var(--sidebar-width, 311px));
position: relative;
}
}
@media (max-width: 991.98px) {
body.single main.container > .sidebar {
display: none;
}
body.single main.container .content-layout {
margin-right: 0 !important;
}
}
/* Sidebar widgets spacing */
body.single .sidebar .zib-widget,
body.single .sidebar .widget {
margin-bottom: 15px;
}
body.single .sidebar .posts-nav-box.toc-widget {
position: sticky;
top: calc(var(--nav-height, 60px) + 16px);
}
+44 -32
View File
@@ -190,15 +190,27 @@
}
function initContentExpand() {
document.querySelectorAll('.entry-content[data-nav]').forEach(function (content) {
// Zibll-style: inject .read-more inside .limit-height and expand on click.
document.querySelectorAll('.wp-posts-content.limit-height, .limit-height[data-nav]').forEach(function (content) {
if (content.dataset.aksrtExpandBound === '1') return;
content.dataset.aksrtExpandBound = '1';
// Only expand when server enabled maxheight (data-maxheight > 0).
var customMax = parseInt(content.getAttribute('data-maxheight') || content.dataset.maxheight || '0', 10);
if (!(customMax > 0)) return;
var limit = customMax;
if (content.scrollHeight <= limit) {
// data-maxheight may be maxheight-80 (Zibll) or absolute maxheight; prefer style max-height.
var styleMax = 0;
if (content.style && content.style.maxHeight) {
styleMax = parseInt(content.style.maxHeight, 10) || 0;
}
var limit = styleMax > 0 ? styleMax : (customMax > 0 ? customMax + 80 : 0);
if (!(limit > 0) && customMax > 0) {
limit = customMax;
}
if (!(limit > 0)) {
content.classList.remove('limit-height');
return;
}
if (content.scrollHeight <= limit + 40) {
content.classList.remove('limit-height');
content.style.maxHeight = '';
return;
@@ -207,37 +219,37 @@
content.classList.add('limit-height');
content.style.maxHeight = limit + 'px';
var existingBtn = content.nextElementSibling;
if (existingBtn && existingBtn.classList && existingBtn.classList.contains('content-expand-btn')) {
return;
}
if (content.querySelector('.read-more')) return;
var button = document.createElement('button');
button.type = 'button';
button.className = 'content-expand-btn';
button.innerHTML = '<i class="fas fa-chevron-down" aria-hidden="true"></i> <span>展开阅读全文</span>';
content.parentNode.insertBefore(button, content.nextSibling);
var wrap = document.createElement('div');
wrap.className = 'read-more';
var link = document.createElement('a');
link.href = 'javascript:;';
link.className = 'read-more-open';
link.innerHTML = '展开阅读全文<i class="fa ml10 fa-angle-down" aria-hidden="true"></i>';
wrap.appendChild(link);
content.appendChild(wrap);
button.addEventListener('click', function () {
var expanded = content.classList.contains('is-expanded');
if (expanded) {
content.classList.remove('is-expanded');
content.style.maxHeight = limit + 'px';
button.classList.remove('is-expanded');
button.querySelector('span').textContent = '展开阅读全文';
content.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
return;
}
content.classList.add('is-expanded');
content.style.maxHeight = content.scrollHeight + 'px';
button.classList.add('is-expanded');
button.querySelector('span').textContent = '收起';
link.addEventListener('click', function (event) {
event.preventDefault();
content.classList.remove('limit-height');
content.style.maxHeight = '';
wrap.remove();
});
});
// Compatibility: old external expand buttons.
document.addEventListener('click', function (event) {
var open = event.target.closest && event.target.closest('.read-more-open');
if (!open) return;
var limitBox = open.closest('.limit-height');
if (!limitBox) return;
event.preventDefault();
limitBox.classList.remove('limit-height');
limitBox.style.maxHeight = '';
var more = open.closest('.read-more');
if (more) more.remove();
});
}
function initFlashQueryCleanup() {