fix
This commit is contained in:
1 parent
25bb0213d4
commit
31e185664a
19 files changed
+12
-672
No files matched your search
@@ -2,11 +2,8 @@ export const pageSchema = {
|
||||
key: 'post_list.page',
|
||||
title: '文章页面',
|
||||
icon: 'fa fas fa-file-alt',
|
||||
description: '配置单篇文章页面的布局、目录树、图片灯箱、版权区和互动功能。',
|
||||
description: '配置单篇文章页面的布局、图片灯箱、版权区和互动功能。',
|
||||
defaults: {
|
||||
post_toc_enabled: true,
|
||||
post_toc_depth: 3,
|
||||
article_nav_mobile_nav_s: true,
|
||||
post_reading_progress: true,
|
||||
breadcrumbs_single_s: true,
|
||||
breadcrumbs_home_text: '首页',
|
||||
@@ -60,9 +57,6 @@ export const pageSchema = {
|
||||
title: '文章导航',
|
||||
icon: 'fa fas fa-compass',
|
||||
fields: [
|
||||
{ key: 'post_toc_enabled', label: '目录树导航', type: 'switch', default: true, help: '自动生成文章目录树' },
|
||||
{ key: 'post_toc_depth', label: '目录深度', type: 'number', default: 3, min: 1, max: 6, dependsOn: { key: 'post_toc_enabled', value: true } },
|
||||
{ key: 'article_nav_mobile_nav_s', label: '移动端弹出菜单', type: 'switch', default: true, dependsOn: { key: 'post_toc_enabled', value: true }, help: '在移动端弹出菜单中显示目录导航' },
|
||||
{ key: 'post_reading_progress', label: '阅读进度条', type: 'switch', default: true },
|
||||
{ key: 'breadcrumbs_single_s', label: '面包屑导航', type: 'switch', default: true },
|
||||
{ key: 'breadcrumbs_home_text', label: '面包屑首页文字', type: 'input', default: '首页', dependsOn: { key: 'breadcrumbs_single_s', value: true } },
|
||||
|
||||
@@ -165,7 +165,7 @@ a, button, input, select, textarea {
|
||||
/* --- 卡片 hover 统一 --- */
|
||||
.post-card, .widget, .aksrt-theme-box, .theme-box,
|
||||
.comment-body, .friend-card, .special-card,
|
||||
.resource-download-box, .resource-meta-box {
|
||||
.resource-download-box {
|
||||
transition: box-shadow var(--dur) var(--ease),
|
||||
border-color var(--dur) var(--ease),
|
||||
transform var(--dur) var(--ease);
|
||||
|
||||
@@ -191,17 +191,12 @@ body.site-layout-3 .sidebar,
|
||||
|
||||
/* Sticky widgets inside sidebar */
|
||||
@media (min-width: 992px) {
|
||||
body.site-layout-2 .sidebar .posts-nav-box,
|
||||
body.site-layout-3 .sidebar .posts-nav-box,
|
||||
body.site-layout-2 .aksrt-article-sidebar .posts-nav-box,
|
||||
body.site-layout-3 .aksrt-article-sidebar .posts-nav-box,
|
||||
.sidebar .content-layout__aside,
|
||||
.content-layout__aside {
|
||||
position: sticky;
|
||||
top: calc(var(--nav-height, 60px) + 16px);
|
||||
}
|
||||
|
||||
.has-static-nav .sidebar .posts-nav-box,
|
||||
.has-static-nav .content-layout__aside {
|
||||
top: 16px;
|
||||
}
|
||||
|
||||
@@ -86,7 +86,6 @@
|
||||
}
|
||||
|
||||
/* 资源元信息 */
|
||||
.resource-meta-box,
|
||||
.resource-download-box {
|
||||
border: 1px solid #ccc;
|
||||
padding: 12px;
|
||||
|
||||
@@ -184,23 +184,6 @@
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
/* ============================================================
|
||||
* 元信息卡片图标增强
|
||||
* ============================================================ */
|
||||
.resource-meta-box__key {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.resource-meta-box__key i {
|
||||
width: 16px;
|
||||
text-align: center;
|
||||
color: var(--color-ink-4, #8A8F98);
|
||||
font-size: 13px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* ============================================================
|
||||
* 渐变价格标签(模仿 legacy 渐变 pay-tag)
|
||||
* ============================================================ */
|
||||
|
||||
@@ -323,152 +323,6 @@ html.dark .article-end-separator span {
|
||||
background: var(--surface-2);
|
||||
}
|
||||
|
||||
.toc-widget {
|
||||
position: sticky;
|
||||
top: 88px;
|
||||
padding: 18px 18px 14px;
|
||||
margin-bottom: 16px;
|
||||
border: none;
|
||||
border-radius: var(--radius-2xl, 16px);
|
||||
box-shadow: var(--shadow-sm);
|
||||
background: var(--surface-1);
|
||||
}
|
||||
|
||||
.toc-widget .widget-title {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.toc-list {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.toc-list li {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.toc-list a {
|
||||
display: block;
|
||||
color: var(--color-ink-3);
|
||||
font-size: 13px;
|
||||
line-height: 1.55;
|
||||
text-decoration: none;
|
||||
transition: color 0.2s ease, transform 0.2s ease;
|
||||
}
|
||||
|
||||
.toc-list a:hover,
|
||||
.toc-list a.is-active {
|
||||
color: var(--color-primary);
|
||||
}
|
||||
|
||||
.toc-list .toc-h1 a {
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.toc-list .toc-h3 a {
|
||||
padding-left: 12px;
|
||||
}
|
||||
|
||||
.toc-list .toc-h4 a {
|
||||
padding-left: 24px;
|
||||
}
|
||||
|
||||
/* Built-in article TOC shell. */
|
||||
.sidebar .posts-nav-box.toc-widget {
|
||||
margin: 0;
|
||||
box-shadow: none;
|
||||
background: transparent;
|
||||
padding: 0;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.sidebar .posts-nav-box.toc-widget > h3,
|
||||
.sidebar .posts-nav-box.toc-widget .toc-widget__title {
|
||||
margin: 0 0 10px;
|
||||
font-size: 15px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
body.single .sidebar .posts-nav-box.toc-widget.is-affix,
|
||||
body.single .sidebar .posts-nav-box.toc-widget[data-affix="true"] {
|
||||
position: sticky;
|
||||
top: calc(var(--nav-height, 60px) + 16px);
|
||||
}
|
||||
|
||||
.toc-float-btn {
|
||||
position: fixed;
|
||||
right: 18px;
|
||||
bottom: 86px;
|
||||
z-index: 41;
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border: none;
|
||||
border-radius: 999px;
|
||||
display: none;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: var(--color-primary);
|
||||
color: #fff;
|
||||
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
|
||||
}
|
||||
|
||||
.toc-drawer-overlay {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 79;
|
||||
display: none;
|
||||
background: rgba(15, 23, 42, 0.36);
|
||||
}
|
||||
|
||||
.toc-drawer-overlay.is-open {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.toc-drawer {
|
||||
position: fixed;
|
||||
right: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
z-index: 80;
|
||||
width: min(86vw, 340px);
|
||||
padding: 18px 18px 28px;
|
||||
background: var(--surface-1);
|
||||
border-left: 1px solid rgba(255, 255, 255, 0.55);
|
||||
box-shadow: var(--shadow-drawer);
|
||||
transform: translateX(100%);
|
||||
transition: transform 0.25s ease;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.toc-drawer.is-open {
|
||||
transform: translateX(0);
|
||||
}
|
||||
|
||||
.toc-drawer__head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
|
||||
.toc-drawer__head h3 {
|
||||
margin: 0;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.toc-drawer__close {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
border: none;
|
||||
border-radius: 999px;
|
||||
background: var(--surface-2);
|
||||
color: var(--color-ink-3);
|
||||
}
|
||||
|
||||
.resource-mobile-fab {
|
||||
position: fixed;
|
||||
right: 18px;
|
||||
@@ -509,14 +363,6 @@ body.single .sidebar .posts-nav-box.toc-widget[data-affix="true"] {
|
||||
}
|
||||
|
||||
@media (max-width: 991px) {
|
||||
.toc-widget {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.toc-float-btn {
|
||||
display: inline-flex;
|
||||
}
|
||||
|
||||
.resource-mobile-download-bar {
|
||||
display: block;
|
||||
}
|
||||
|
||||
@@ -25,12 +25,6 @@ body.single main.container .content-layout > .breadcrumbs-wrap {
|
||||
padding-top: 2px;
|
||||
}
|
||||
|
||||
/* Sticky TOC widget in sidebar — parent .sidebar is position:unset like legacy */
|
||||
body.single .sidebar .posts-nav-box.toc-widget {
|
||||
position: sticky;
|
||||
top: calc(var(--nav-height, 60px) + 16px);
|
||||
}
|
||||
|
||||
body.single .sidebar .aksrt-panel,
|
||||
body.single .sidebar .widget {
|
||||
margin-bottom: 15px;
|
||||
@@ -56,56 +50,3 @@ body.single main.container {
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
}
|
||||
|
||||
/* Useful fallback for sites that enable the column before adding widgets. */
|
||||
.single-overview-widget {
|
||||
padding: 18px;
|
||||
border-radius: var(--main-radius, 8px);
|
||||
background: var(--main-bg-color, #fff);
|
||||
box-shadow: 0 0 10px var(--main-shadow, rgba(116, 116, 116, 0.08));
|
||||
}
|
||||
|
||||
.single-overview-widget__title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin: 0 0 12px;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.single-overview-widget__title i {
|
||||
color: var(--focus-color, #f04494);
|
||||
}
|
||||
|
||||
.single-overview-widget__list {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.single-overview-widget__list > div {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
padding: 8px 0;
|
||||
border-bottom: 1px dashed var(--main-border-color, rgba(50, 50, 50, 0.08));
|
||||
}
|
||||
|
||||
.single-overview-widget__list > div:last-child {
|
||||
padding-bottom: 0;
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
.single-overview-widget__list dt,
|
||||
.single-overview-widget__list dd {
|
||||
margin: 0;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.single-overview-widget__list dt {
|
||||
color: var(--muted-color, #777);
|
||||
}
|
||||
|
||||
.single-overview-widget__list dd {
|
||||
color: var(--key-color, #333);
|
||||
text-align: right;
|
||||
}
|
||||
+1
-168
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* AKSRT Page Template
|
||||
*
|
||||
* Handles template-scoped content interactions: TOC, lightbox,
|
||||
* Handles template-scoped content interactions: lightbox,
|
||||
* expandable article bodies, and one-shot query cleanup banners.
|
||||
*
|
||||
* @package AKSRT
|
||||
@@ -10,172 +10,6 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
function slugifyHeading(text) {
|
||||
return 'heading-' + String(text || '')
|
||||
.trim()
|
||||
.toLowerCase()
|
||||
.replace(/\s+/g, '-')
|
||||
.replace(/[^\w\u4e00-\u9fff-]/g, '');
|
||||
}
|
||||
|
||||
function initPostToc() {
|
||||
// Accept either explicit data-aksrt-toc="1" or any [data-nav] article body.
|
||||
var content =
|
||||
document.querySelector('.wp-posts-content[data-nav="posts"][data-aksrt-toc="1"]') ||
|
||||
document.querySelector('.wp-posts-content[data-nav]') ||
|
||||
document.querySelector('[data-nav="posts"]') ||
|
||||
document.querySelector('[data-nav]');
|
||||
|
||||
// The article sidebar and mobile drawer share one built-in TOC source.
|
||||
var tocWidgets = Array.prototype.slice.call(
|
||||
document.querySelectorAll('.posts-nav-box.toc-widget')
|
||||
);
|
||||
var tocLists = [];
|
||||
tocWidgets.forEach(function (box) {
|
||||
if (!box.classList.contains('toc-widget')) {
|
||||
box.classList.add('toc-widget');
|
||||
}
|
||||
var list = box.querySelector('.toc-list');
|
||||
if (!list) {
|
||||
list = document.createElement('ol');
|
||||
list.className = 'toc-list';
|
||||
box.appendChild(list);
|
||||
}
|
||||
tocLists.push(list);
|
||||
});
|
||||
|
||||
var mobileToggle = document.querySelector('.toc-float-btn');
|
||||
var drawer = document.querySelector('.toc-drawer');
|
||||
var overlay = document.querySelector('.toc-drawer-overlay');
|
||||
var drawerList = drawer ? drawer.querySelector('.toc-list') : null;
|
||||
var closeBtn = drawer ? drawer.querySelector('.toc-drawer__close') : null;
|
||||
|
||||
if (!content || content.dataset.aksrtTocBound === '1') return;
|
||||
if (!tocLists.length && !drawerList && !mobileToggle) return;
|
||||
|
||||
content.dataset.aksrtTocBound = '1';
|
||||
|
||||
var maxDepth = parseInt(content.dataset.aksrtTocDepth || '3', 10) || 3;
|
||||
// legacy section-navs: only fill when heading count > 2 (≥3).
|
||||
var MIN_HEADINGS = 3;
|
||||
|
||||
function getHeadings() {
|
||||
// legacy scans h1–h4 inside [data-nav]; depth setting still caps lower levels.
|
||||
return Array.prototype.slice.call(content.querySelectorAll('h1, h2, h3, h4')).filter(function (heading) {
|
||||
if (heading.closest('.no-nav') || heading.classList.contains('item-heading')) {
|
||||
return false;
|
||||
}
|
||||
var level = parseInt((heading.tagName || 'H2').replace('H', ''), 10) || 2;
|
||||
// toc_depth is typically 2–4 meaning deepest heading level from h2 baseline;
|
||||
// allow h1 always, then h2..h(1+maxDepth) capped at h4.
|
||||
if (level === 1) return true;
|
||||
return level <= Math.min(4, maxDepth + 1);
|
||||
});
|
||||
}
|
||||
|
||||
function buildToc(container) {
|
||||
if (!container) return false;
|
||||
|
||||
var headings = getHeadings();
|
||||
if (headings.length < MIN_HEADINGS) return false;
|
||||
|
||||
var html = '';
|
||||
headings.forEach(function (heading) {
|
||||
if (!heading.id) {
|
||||
heading.id = slugifyHeading(heading.textContent);
|
||||
}
|
||||
|
||||
var levelClass = '';
|
||||
if (heading.tagName === 'H1') {
|
||||
levelClass = 'toc-h1';
|
||||
} else if (heading.tagName === 'H3') {
|
||||
levelClass = 'toc-h3';
|
||||
} else if (heading.tagName === 'H4') {
|
||||
levelClass = 'toc-h4';
|
||||
}
|
||||
|
||||
html += '<li' + (levelClass ? ' class="' + levelClass + '"' : '') + '><a href="#' + heading.id + '">' + heading.textContent.trim() + '</a></li>';
|
||||
});
|
||||
|
||||
container.innerHTML = html;
|
||||
return true;
|
||||
}
|
||||
|
||||
var hasToc = false;
|
||||
tocLists.forEach(function (list) {
|
||||
if (buildToc(list)) hasToc = true;
|
||||
});
|
||||
if (drawerList && tocLists.indexOf(drawerList) === -1) {
|
||||
if (buildToc(drawerList)) hasToc = true;
|
||||
}
|
||||
|
||||
if (!hasToc) {
|
||||
tocWidgets.forEach(function (box) {
|
||||
var widget = box.closest('.widget');
|
||||
// A built-in TOC is a direct child of the article sidebar. Its parent
|
||||
// is therefore not widget chrome and must never be removed here.
|
||||
if (widget && widget !== document.body && widget.querySelectorAll('.posts-nav-box').length <= 1) {
|
||||
widget.remove();
|
||||
} else {
|
||||
box.remove();
|
||||
}
|
||||
});
|
||||
if (mobileToggle) mobileToggle.remove();
|
||||
if (drawer) drawer.remove();
|
||||
if (overlay) overlay.remove();
|
||||
return;
|
||||
}
|
||||
|
||||
function closeDrawer() {
|
||||
if (drawer) drawer.classList.remove('is-open');
|
||||
if (overlay) overlay.classList.remove('is-open');
|
||||
document.body.style.overflow = '';
|
||||
}
|
||||
|
||||
function openDrawer() {
|
||||
if (drawer) drawer.classList.add('is-open');
|
||||
if (overlay) overlay.classList.add('is-open');
|
||||
document.body.style.overflow = 'hidden';
|
||||
}
|
||||
|
||||
function trackActiveHeading() {
|
||||
var headings = content.querySelectorAll('h1[id], h2[id], h3[id], h4[id]');
|
||||
if (!headings.length) return;
|
||||
|
||||
var activeId = '';
|
||||
var fromTop = window.scrollY + 120;
|
||||
for (var i = headings.length - 1; i >= 0; i -= 1) {
|
||||
if (headings[i].offsetTop <= fromTop) {
|
||||
activeId = headings[i].id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
document.querySelectorAll('.toc-list a').forEach(function (link) {
|
||||
link.classList.toggle('is-active', link.getAttribute('href') === '#' + activeId);
|
||||
});
|
||||
}
|
||||
|
||||
document.querySelectorAll('.toc-list a').forEach(function (link) {
|
||||
link.addEventListener('click', function (event) {
|
||||
var target = document.querySelector(link.getAttribute('href'));
|
||||
if (!target) return;
|
||||
|
||||
event.preventDefault();
|
||||
var top = target.getBoundingClientRect().top + window.pageYOffset - 105;
|
||||
window.scrollTo({ top: Math.max(0, top), behavior: 'smooth' });
|
||||
closeDrawer();
|
||||
});
|
||||
});
|
||||
|
||||
if (mobileToggle) mobileToggle.addEventListener('click', openDrawer);
|
||||
if (overlay) overlay.addEventListener('click', closeDrawer);
|
||||
if (closeBtn) closeBtn.addEventListener('click', closeDrawer);
|
||||
|
||||
window.addEventListener('scroll', trackActiveHeading, { passive: true });
|
||||
trackActiveHeading();
|
||||
}
|
||||
|
||||
function initLightbox() {
|
||||
var overlay = document.getElementById('lightbox-overlay');
|
||||
var content = document.querySelector(".wp-posts-content[data-aksrt-lightbox='1'], .entry-content[data-aksrt-lightbox='1']");
|
||||
@@ -316,7 +150,6 @@
|
||||
}
|
||||
|
||||
function init() {
|
||||
initPostToc();
|
||||
initLightbox();
|
||||
initContentExpand();
|
||||
initFlashQueryCleanup();
|
||||
|
||||
Reference in new issue
Block a user