From 31e185664a152ff5fd557cc9201de0d6e96a8fa0 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 22 Aug 2026 18:54:12 +0800 Subject: [PATCH] fix --- .../src/schema/sections/post-list/page.js | 8 +- .../enhancements/modal-motion/dark-mode-2.css | 2 +- assets/css/frontend/layout.css | 5 - assets/css/frontend/print.css | 1 - assets/css/frontend/resource-meta/part-4.css | 17 -- .../css/frontend/single-post/related-toc.css | 154 ---------------- assets/css/frontend/single-post/shell.css | 59 ------ assets/js/page-template.js | 169 +----------------- inc/helpers/aksrt-frontend-tags.php | 6 - inc/helpers/aksrt-single-aside.php | 73 +------- inc/helpers/aksrt-single-render.php | 3 - inc/helpers/aksrt-single.php | 5 +- single.php | 12 -- src/Admin/Schema/SchemaPostList.php | 3 - src/Core/DomainModel.php | 1 - src/Core/PostMetaBox.php | 36 +--- src/Settings/FacadeBulk.php | 4 +- src/Settings/PostDisplay.php | 4 - templates/parts/resource-meta-box.php | 122 ------------- 19 files changed, 12 insertions(+), 672 deletions(-) delete mode 100644 templates/parts/resource-meta-box.php diff --git a/assets/admin/src/schema/sections/post-list/page.js b/assets/admin/src/schema/sections/post-list/page.js index a24813bc..31851c87 100644 --- a/assets/admin/src/schema/sections/post-list/page.js +++ b/assets/admin/src/schema/sections/post-list/page.js @@ -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 } }, diff --git a/assets/css/frontend/enhancements/modal-motion/dark-mode-2.css b/assets/css/frontend/enhancements/modal-motion/dark-mode-2.css index 19427bfe..a7a65ea8 100644 --- a/assets/css/frontend/enhancements/modal-motion/dark-mode-2.css +++ b/assets/css/frontend/enhancements/modal-motion/dark-mode-2.css @@ -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); diff --git a/assets/css/frontend/layout.css b/assets/css/frontend/layout.css index db766e72..c04e701b 100644 --- a/assets/css/frontend/layout.css +++ b/assets/css/frontend/layout.css @@ -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; } diff --git a/assets/css/frontend/print.css b/assets/css/frontend/print.css index 85279a09..e7ea4226 100644 --- a/assets/css/frontend/print.css +++ b/assets/css/frontend/print.css @@ -86,7 +86,6 @@ } /* 资源元信息 */ - .resource-meta-box, .resource-download-box { border: 1px solid #ccc; padding: 12px; diff --git a/assets/css/frontend/resource-meta/part-4.css b/assets/css/frontend/resource-meta/part-4.css index 976d24f9..8ad0805a 100644 --- a/assets/css/frontend/resource-meta/part-4.css +++ b/assets/css/frontend/resource-meta/part-4.css @@ -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) * ============================================================ */ diff --git a/assets/css/frontend/single-post/related-toc.css b/assets/css/frontend/single-post/related-toc.css index 89a8ab11..98f82922 100644 --- a/assets/css/frontend/single-post/related-toc.css +++ b/assets/css/frontend/single-post/related-toc.css @@ -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; } diff --git a/assets/css/frontend/single-post/shell.css b/assets/css/frontend/single-post/shell.css index 47d581aa..c2eee2b6 100644 --- a/assets/css/frontend/single-post/shell.css +++ b/assets/css/frontend/single-post/shell.css @@ -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; -} diff --git a/assets/js/page-template.js b/assets/js/page-template.js index c3ba6f8f..89ef9194 100644 --- a/assets/js/page-template.js +++ b/assets/js/page-template.js @@ -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 += '' + heading.textContent.trim() + ''; - }); - - 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(); diff --git a/inc/helpers/aksrt-frontend-tags.php b/inc/helpers/aksrt-frontend-tags.php index c65cd7a6..8a07b1e2 100644 --- a/inc/helpers/aksrt-frontend-tags.php +++ b/inc/helpers/aksrt-frontend-tags.php @@ -70,8 +70,6 @@ if (!function_exists('aksrt_resolve_single_post_display_settings')) : $settings = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_post_page_settings() : [ - 'toc_enabled' => true, - 'toc_depth' => 3, 'reading_progress' => true, 'lightbox' => true, 'related_enabled' => true, @@ -129,10 +127,6 @@ if (!function_exists('aksrt_resolve_single_post_display_settings')) : $settings['authordesc'] = !empty($settings['authordesc_s']); } $meta = class_exists('\AKSRT\Core\PostMetaBox') ? \AKSRT\Core\PostMetaBox::get_meta($post->ID) : []; - // show_toc new route: '' follow | '1' on | '0' off -if (array_key_exists('show_toc', $meta) && $meta['show_toc'] !== '' && $meta['show_toc'] !== null) { - $settings['toc_enabled'] = (string) $meta['show_toc'] === '1'; -} foreach ([ 'show_reading_progress' => 'reading_progress', 'enable_lightbox' => 'lightbox', diff --git a/inc/helpers/aksrt-single-aside.php b/inc/helpers/aksrt-single-aside.php index 2e331b29..1fc4379b 100644 --- a/inc/helpers/aksrt-single-aside.php +++ b/inc/helpers/aksrt-single-aside.php @@ -7,47 +7,9 @@ defined('ABSPATH') || exit; -if (!function_exists('aksrt_single_render_overview_widget')) : - /** - * Render a useful fallback when no article sidebar widgets are configured. - * - * @param array $ctx Single context. - */ - function aksrt_single_render_overview_widget(array $ctx): void { - $post_id = (int) ($ctx['post_id'] ?? get_the_ID()); - $categories = get_the_category($post_id); - $primary_category = !empty($categories) && $categories[0] instanceof WP_Term ? $categories[0] : null; - $modified = get_the_modified_date('', $post_id); - $overview_items = is_array($ctx['meta_items_secondary'] ?? null) ? $ctx['meta_items_secondary'] : []; - ?> -
-

- - -

-
- - - -
-
- - -
- - - -
- -
-
- $ctx Single context. */ @@ -61,36 +23,13 @@ if (!function_exists('aksrt_single_render_aside')) : // The body site-layout-* class owns visibility. Always render the post // sidebar so User-Agent or request-specific context cannot remove widgets // from an otherwise two-column article page. - - $has_article_widgets = is_active_sidebar('all_sidebar_top') - || is_active_sidebar('single_sidebar') - || is_active_sidebar('all_sidebar_bottom'); ?> 0 ? ' limit-height' : ''; ?>" 0 ? ' style="max-height:' . esc_attr((string) $maxheight) . 'px;"' : ''; ?> - data-maxheight=" 0 ? max(0, $maxheight - 80) : 0)); ?>" - data-aksrt-toc="" - data-aksrt-toc-depth="" > 'no']; $pay_type = (string) ($pay_meta['pay_type'] ?? 'no'); @@ -114,8 +113,7 @@ if (!function_exists('aksrt_single_build_context')) : 'post_id' => $post_id, 'settings' => $settings, 'show_cover' => $show_cover, - 'show_toc' => $show_toc, - 'cover_url' => (string) ($settings['cover_url'] ?? ''), + 'cover_url' => (string) ($settings['cover_url'] ?? ''), 'cover_type' => (string) ($settings['cover_type'] ?? 'none'), 'img_scale' => (int) ($settings['article_image_cover_scale'] ?? 35), 'video_scale' => (int) ($settings['article_video_cover_scale'] ?? 56), @@ -146,7 +144,6 @@ if (!function_exists('aksrt_single_build_context')) : 'breadcrumbs_html' => $breadcrumbs_html, 'status_badge' => $status_badge, 'show_aside' => $show_aside, - 'toc_title' => __('文章目录', 'aksrt'), ]; } endif; diff --git a/single.php b/single.php index d90da09d..352bb238 100644 --- a/single.php +++ b/single.php @@ -72,18 +72,6 @@ while (have_posts()) : ?> - - -
- - -