fix(ajax): show the reference skeleton on every load-more surface

Clicking 加载更多 in the 多栏目文章 widget showed no skeleton at all — the
list simply stayed still until the response arrived, then the new cards
appeared. The homepage stream, archives and comments already had a working
skeleton; the widget's AJAX load goes through a different client and never
found its loader.

Root cause was DOM placement, not visibility: ContentRenderer emitted
.post_ajax_loader as a *sibling* of .widget-ajaxpager, while the widget REST
client resolves it with container.querySelector('.post_ajax_loader'). The
node existed but could never match, so .is-loading was never added and the
skeleton stayed display:none. Inactive tab panes had the same shape, and the
direct-load branch of ajaxpager() emitted no loader at all.

Changes, all following the reference theme's post_ajax() contract in
zibll/js/main.js (beforeSend anchors the loader to the end of the list;
success only hides it, never removes it):

- ContentRenderer: nest the loader inside .widget-ajaxpager for both the
  direct-load and inactive-tab branches, and drop the sibling append.
- widgets/frontend.js: anchorLoader() moves the loader to the end of the
  list before .ajax-pag on every request; appended cards are inserted before
  it; a replace preserves the node instead of wiping it with innerHTML; a
  fallback loader is created when the DOM has none; loadItems() now returns
  its promise; drop the unreachable is-loading auto-load branch.
- Message centre, user-home panels and the search page switch from spinner /
  opacity feedback to the same .posts-item-shaped skeleton, so all AJAX
  surfaces share one loading contract.
- Remove the second, never-wired skeleton system (.aksrt-skeleton-* in
  core-ui.css) and the dead spinner stylesheets/rules (skeleton.css,
  ajax-spinner.css, .load-more__*, --skeleton-base/--skeleton-shine) plus the
  unregistered assets/js/waterfall.js.
- Extend the widget, message-centre, user-home and asset-ledger contract
  tests to pin the loader inside the container, the class-only visibility
  switch, and the absence of the deleted dead code.

Verified: 470 node tests, 136 PHP widget assertions, admin-contract and
widget-system audits all green; rebuilt public assets after the CSS/JS
removals.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-10-03 22:22:15 +08:00
co-authored by Claude Fable 5
parent 271e7f0518
commit cf4554e7c8
25 changed files with 330 additions and 981 deletions
+5 -384
View File
@@ -166,10 +166,6 @@ Full admin panel preserved (settings, OAuth, content tools, etc).
--card-gap: 16px;
--card-gap-lg: 20px;
/* ===== Skeleton loader ===== */
--skeleton-base: var(--surface-2);
--skeleton-shine: var(--surface-1);
/* ===== Extended tokens (used by components) ===== */
--color-primary-light: var(--color-primary-soft);
--color-surface: var(--surface-1);
@@ -397,9 +393,6 @@ body.dark-theme {
--footer-color: var(--color-ink-4);
--shadow-md: var(--shadow);
--skeleton-base: #3a3b3e;
--skeleton-shine: #444548;
/* Multi-color palette — dark mode: same hue, softer tint backgrounds */
--aksrt-rose-soft: rgba(244, 63, 94, 0.18);
--aksrt-blue-soft: rgba(59, 130, 246, 0.18);
@@ -5105,8 +5098,11 @@ body:has(.modal.in) .float-right.position-center,
/**
* AKSRT Enhancements — 全局 UI 增强
*
* 包含:骨架屏、悬停动效、暗色过渡、滚动感知
* 包含:悬停动效、暗色过渡、滚动感知
* 所有选择器使用 aksrt- 前缀避免冲突
*
* 骨架屏不在此文件:唯一契约是 .placeholder 块 + .post_ajax_loader 容器
* (inc/helpers/posts-renderer/markup.php 的 aksrt_render_placeholder)。
*/
@keyframes aksrt-spin {
@@ -5115,79 +5111,7 @@ body:has(.modal.in) .float-right.position-center,
}
/* ============================================================
* 1. 骨架屏加载动画
* ============================================================ */
.aksrt-skeleton {
background: linear-gradient(
90deg,
rgba(121, 121, 121, 0.08) 25%,
rgba(121, 121, 121, 0.15) 37%,
rgba(121, 121, 121, 0.08) 63%
);
background-size: 400% 100%;
animation: aksrt-skeleton-shimmer 1.5s ease infinite;
border-radius: 4px;
}
.aksrt-skeleton--image {
height: 0;
padding-bottom: 66.67%; /* 3:2 aspect ratio */
}
.aksrt-skeleton--avatar {
width: 40px;
height: 40px;
border-radius: 50%;
}
.aksrt-skeleton--title {
height: 22px;
width: 80%;
}
.aksrt-skeleton--text {
height: 16px;
width: 100%;
}
.aksrt-skeleton--text-short {
height: 16px;
width: 60%;
}
.aksrt-skeleton--button {
height: 36px;
width: 100px;
border-radius: 8px;
}
@keyframes aksrt-skeleton-shimmer {
0% { background-position: 100% 50%; }
100% { background-position: 0 50%; }
}
/* 骨架屏组合:文章卡片骨架 */
.aksrt-skeleton-card {
background: var(--surface-1, #fff);
border: 1px solid var(--color-line);
border-radius: 12px;
overflow: hidden;
padding: 0;
}
.aksrt-skeleton-card .aksrt-skeleton--image {
border-radius: 0;
}
.aksrt-skeleton-card__body {
padding: 16px;
display: flex;
flex-direction: column;
gap: 10px;
}
/* ============================================================
* 2. 悬停交互动效
* 1. 悬停交互动效
* ============================================================ */
/* 卡片放大 */
@@ -5916,149 +5840,6 @@ body.aksrt-body-scroll .aksrt-show-on-scroll {
color: var(--color-ink-4, #8A8F98);
}
/* source: assets/css/frontend/skeleton.css */
/* ========== 骨架屏加载 — 对齐 legacy skeleton loading ========== */
.skeleton {
position: relative;
overflow: hidden;
background: var(--surface-2, #eee);
border-radius: var(--radius, 8px);
}
.skeleton::after {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: linear-gradient(
90deg,
transparent 0%,
rgba(255, 255, 255, 0.4) 50%,
transparent 100%
);
animation: skeleton-shimmer 1.5s infinite;
}
@keyframes skeleton-shimmer {
0% { transform: translateX(-100%); }
100% { transform: translateX(100%); }
}
/* 骨架屏变体 */
.skeleton-text {
height: 14px;
border-radius: 4px;
margin-bottom: 8px;
}
.skeleton-text--title {
height: 20px;
width: 60%;
margin-bottom: 12px;
}
.skeleton-text--short {
width: 40%;
}
.skeleton-text--medium {
width: 70%;
}
.skeleton-avatar {
width: 48px;
height: 48px;
border-radius: 50%;
flex-shrink: 0;
}
.skeleton-avatar--sm {
width: 32px;
height: 32px;
}
.skeleton-avatar--lg {
width: 64px;
height: 64px;
}
.skeleton-thumb {
width: 100%;
aspect-ratio: 16 / 9;
border-radius: var(--radius, 8px);
}
.skeleton-thumb--square {
aspect-ratio: 1;
}
.skeleton-thumb--card {
aspect-ratio: 16 / 10;
border-radius: var(--radius, 8px) var(--radius, 8px) 0 0;
}
/* 卡片骨架屏 */
.skeleton-card {
background: var(--surface-1, #fff);
border-radius: var(--radius, 8px);
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
overflow: hidden;
}
.skeleton-card__thumb {
width: 100%;
aspect-ratio: 16 / 10;
}
.skeleton-card__body {
padding: 14px 16px;
}
.skeleton-card__meta {
display: flex;
align-items: center;
gap: 8px;
margin-top: 10px;
}
/* 评论骨架屏 */
.skeleton-comment {
display: flex;
gap: 12px;
padding: 16px 0;
border-bottom: 1px solid var(--color-line-soft, rgba(0, 0, 0, 0.03));
}
.skeleton-comment__body {
flex: 1;
}
.skeleton-comment__header {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 10px;
}
/* 通用骨架屏容器 */
.skeleton-list .skeleton-item {
padding: 12px 0;
border-bottom: 1px solid var(--color-line-soft, rgba(0, 0, 0, 0.03));
}
.skeleton-list .skeleton-item:last-child {
border-bottom: none;
}
/* 减弱动画偏好 */
@media (prefers-reduced-motion: reduce) {
.skeleton::after {
animation: none;
}
}
/* source: assets/css/frontend/empty-state.css */
/* ========== 空状态 — 对齐 legacy empty state ========== */
.empty-state {
@@ -6320,50 +6101,6 @@ body.aksrt-body-scroll .aksrt-show-on-scroll {
border-color: var(--color-primary, #f04494);
}
/* AJAX 加载更多 */
.load-more {
text-align: center;
padding: 20px 0;
}
.load-more__btn {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 10px 24px;
font-size: 13px;
color: var(--color-ink-2, #4e5358);
background: var(--surface-1, #fff);
border: 1px solid var(--color-line, rgba(50, 50, 50, 0.06));
border-radius: 20px;
cursor: pointer;
transition: all 0.2s;
}
.load-more__btn:hover {
color: var(--color-primary, #f04494);
border-color: var(--color-primary, #f04494);
}
.load-more__btn:disabled {
opacity: 0.5;
cursor: not-allowed;
}
.load-more__spinner {
display: inline-block;
width: 16px;
height: 16px;
border: 2px solid var(--surface-3, #e8e8e8);
border-top-color: var(--color-primary, #f04494);
border-radius: 50%;
animation: spin 0.6s linear infinite;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
/* 移动端 */
@media (max-width: 767px) {
.pagination a,
@@ -6397,122 +6134,6 @@ body.aksrt-body-scroll .aksrt-show-on-scroll {
}
}
/* source: assets/css/frontend/ajax-spinner.css */
/* ========== AJAX 加载指示器 — 对齐 legacy loading spinner ========== */
.aksrt-loading {
display: flex;
align-items: center;
justify-content: center;
padding: 40px 20px;
color: var(--color-ink-4, #999);
font-size: 13px;
gap: 8px;
}
.aksrt-loading__spinner {
display: inline-block;
width: 20px;
height: 20px;
border: 2px solid var(--surface-3, #e8e8e8);
border-top-color: var(--color-primary, #f04494);
border-radius: 50%;
animation: aksrt-spin 0.6s linear infinite;
}
@keyframes aksrt-spin {
to { transform: rotate(360deg); }
}
/* 全屏加载遮罩 */
.aksrt-loading-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(255, 255, 255, 0.8);
display: flex;
align-items: center;
justify-content: center;
z-index: 9999;
backdrop-filter: blur(2px);
}
.aksrt-loading-overlay__content {
text-align: center;
}
.aksrt-loading-overlay__spinner {
width: 36px;
height: 36px;
border: 3px solid var(--surface-3, #e8e8e8);
border-top-color: var(--color-primary, #f04494);
border-radius: 50%;
animation: aksrt-spin 0.6s linear infinite;
margin: 0 auto 12px;
}
.aksrt-loading-overlay__text {
font-size: 13px;
color: var(--color-ink-3, #777);
}
/* 行内加载(替换内容时) */
.aksrt-loading-inline {
display: flex;
align-items: center;
justify-content: center;
padding: 20px;
color: var(--color-ink-4, #999);
font-size: 12px;
gap: 6px;
}
.aksrt-loading-inline__dot {
width: 6px;
height: 6px;
background: var(--color-primary, #f04494);
border-radius: 50%;
animation: aksrt-dot-pulse 1.2s ease-in-out infinite;
}
.aksrt-loading-inline__dot:nth-child(2) {
animation-delay: 0.2s;
}
.aksrt-loading-inline__dot:nth-child(3) {
animation-delay: 0.4s;
}
@keyframes aksrt-dot-pulse {
0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
40% { opacity: 1; transform: scale(1); }
}
/* 页面加载进度条 */
.aksrt-progress-bar {
position: fixed;
top: 0;
left: 0;
height: 2px;
background: var(--color-primary, #f04494);
z-index: 10000;
transition: width 0.3s ease;
}
/* 减弱动画偏好 */
@media (prefers-reduced-motion: reduce) {
.aksrt-loading__spinner,
.aksrt-loading-overlay__spinner {
animation-duration: 1.5s;
}
.aksrt-loading-inline__dot {
animation: none;
opacity: 0.6;
}
}
/* source: assets/css/frontend/modal-runtime.css */
/**
* Modal runtime + ajax list primitives (shared).
+1 -1
View File
File diff suppressed because one or more lines are too long
-7
View File
@@ -141,10 +141,6 @@
--card-gap: 16px;
--card-gap-lg: 20px;
/* ===== Skeleton loader ===== */
--skeleton-base: var(--surface-2);
--skeleton-shine: var(--surface-1);
/* ===== Extended tokens (used by components) ===== */
--color-primary-light: var(--color-primary-soft);
--color-surface: var(--surface-1);
@@ -372,9 +368,6 @@ body.dark-theme {
--footer-color: var(--color-ink-4);
--shadow-md: var(--shadow);
--skeleton-base: #3a3b3e;
--skeleton-shine: #444548;
/* Multi-color palette — dark mode: same hue, softer tint backgrounds */
--aksrt-rose-soft: rgba(244, 63, 94, 0.18);
--aksrt-blue-soft: rgba(59, 130, 246, 0.18);
-114
View File
@@ -1,114 +0,0 @@
/* ========== AJAX 加载指示器 — 对齐 legacy loading spinner ========== */
.aksrt-loading {
display: flex;
align-items: center;
justify-content: center;
padding: 40px 20px;
color: var(--color-ink-4, #999);
font-size: 13px;
gap: 8px;
}
.aksrt-loading__spinner {
display: inline-block;
width: 20px;
height: 20px;
border: 2px solid var(--surface-3, #e8e8e8);
border-top-color: var(--color-primary, #f04494);
border-radius: 50%;
animation: aksrt-spin 0.6s linear infinite;
}
@keyframes aksrt-spin {
to { transform: rotate(360deg); }
}
/* 全屏加载遮罩 */
.aksrt-loading-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(255, 255, 255, 0.8);
display: flex;
align-items: center;
justify-content: center;
z-index: 9999;
backdrop-filter: blur(2px);
}
.aksrt-loading-overlay__content {
text-align: center;
}
.aksrt-loading-overlay__spinner {
width: 36px;
height: 36px;
border: 3px solid var(--surface-3, #e8e8e8);
border-top-color: var(--color-primary, #f04494);
border-radius: 50%;
animation: aksrt-spin 0.6s linear infinite;
margin: 0 auto 12px;
}
.aksrt-loading-overlay__text {
font-size: 13px;
color: var(--color-ink-3, #777);
}
/* 行内加载(替换内容时) */
.aksrt-loading-inline {
display: flex;
align-items: center;
justify-content: center;
padding: 20px;
color: var(--color-ink-4, #999);
font-size: 12px;
gap: 6px;
}
.aksrt-loading-inline__dot {
width: 6px;
height: 6px;
background: var(--color-primary, #f04494);
border-radius: 50%;
animation: aksrt-dot-pulse 1.2s ease-in-out infinite;
}
.aksrt-loading-inline__dot:nth-child(2) {
animation-delay: 0.2s;
}
.aksrt-loading-inline__dot:nth-child(3) {
animation-delay: 0.4s;
}
@keyframes aksrt-dot-pulse {
0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
40% { opacity: 1; transform: scale(1); }
}
/* 页面加载进度条 */
.aksrt-progress-bar {
position: fixed;
top: 0;
left: 0;
height: 2px;
background: var(--color-primary, #f04494);
z-index: 10000;
transition: width 0.3s ease;
}
/* 减弱动画偏好 */
@media (prefers-reduced-motion: reduce) {
.aksrt-loading__spinner,
.aksrt-loading-overlay__spinner {
animation-duration: 1.5s;
}
.aksrt-loading-inline__dot {
animation: none;
opacity: 0.6;
}
}
+5 -74
View File
@@ -1,8 +1,11 @@
/**
* AKSRT Enhancements — 全局 UI 增强
*
* 包含:骨架屏、悬停动效、暗色过渡、滚动感知
* 包含:悬停动效、暗色过渡、滚动感知
* 所有选择器使用 aksrt- 前缀避免冲突
*
* 骨架屏不在此文件:唯一契约是 .placeholder 块 + .post_ajax_loader 容器
* (inc/helpers/posts-renderer/markup.php 的 aksrt_render_placeholder)。
*/
@keyframes aksrt-spin {
@@ -11,79 +14,7 @@
}
/* ============================================================
* 1. 骨架屏加载动画
* ============================================================ */
.aksrt-skeleton {
background: linear-gradient(
90deg,
rgba(121, 121, 121, 0.08) 25%,
rgba(121, 121, 121, 0.15) 37%,
rgba(121, 121, 121, 0.08) 63%
);
background-size: 400% 100%;
animation: aksrt-skeleton-shimmer 1.5s ease infinite;
border-radius: 4px;
}
.aksrt-skeleton--image {
height: 0;
padding-bottom: 66.67%; /* 3:2 aspect ratio */
}
.aksrt-skeleton--avatar {
width: 40px;
height: 40px;
border-radius: 50%;
}
.aksrt-skeleton--title {
height: 22px;
width: 80%;
}
.aksrt-skeleton--text {
height: 16px;
width: 100%;
}
.aksrt-skeleton--text-short {
height: 16px;
width: 60%;
}
.aksrt-skeleton--button {
height: 36px;
width: 100px;
border-radius: 8px;
}
@keyframes aksrt-skeleton-shimmer {
0% { background-position: 100% 50%; }
100% { background-position: 0 50%; }
}
/* 骨架屏组合:文章卡片骨架 */
.aksrt-skeleton-card {
background: var(--surface-1, #fff);
border: 1px solid var(--color-line);
border-radius: 12px;
overflow: hidden;
padding: 0;
}
.aksrt-skeleton-card .aksrt-skeleton--image {
border-radius: 0;
}
.aksrt-skeleton-card__body {
padding: 16px;
display: flex;
flex-direction: column;
gap: 10px;
}
/* ============================================================
* 2. 悬停交互动效
* 1. 悬停交互动效
* ============================================================ */
/* 卡片放大 */
+39 -19
View File
@@ -106,10 +106,20 @@
}
.messages-center.is-loading .messages-center__content {
opacity: 0.55;
pointer-events: none;
}
/* 加载态由消息骨架承担(与文章列表 .post_ajax_loader 同一契约),
不再让按钮 spinner 与内容透明度抢反馈。 */
.messages-list > .post_ajax_loader {
display: none;
}
.messages-list > .post_ajax_loader.is-loading {
display: block;
animation: aksrtFadeIn 0.2s ease both;
}
.messages-list {
display: flex;
flex-direction: column;
@@ -455,22 +465,36 @@ html.dark .message-detail {
transform: translateY(-1px);
}
.messages-center.is-loading .messages-pagination__more span::before {
display: inline-block;
width: 12px;
height: 12px;
margin-right: 7px;
border: 2px solid currentColor;
border-right-color: transparent;
border-radius: 50%;
content: "";
vertical-align: -2px;
animation: messages-pagination-spin 0.7s linear infinite;
/* 消息骨架:复用真实 .message-item 结构与 .placeholder 动画契约,
只把内容换成灰块(参考主题 post_ajax loader 的同构思路)。 */
.messages-list > .post_ajax_loader .message-item--placeholder {
cursor: default;
}
@keyframes messages-pagination-spin {
to {
transform: rotate(360deg);
.messages-list > .post_ajax_loader .message-item--placeholder .message-item__icon {
color: transparent;
}
.messages-list > .post_ajax_loader .message-item--placeholder .message-item__body {
display: flex;
flex-direction: column;
}
.messages-list > .post_ajax_loader .message-item--placeholder .placeholder {
display: block;
}
.messages-list > .post_ajax_loader .message-item--placeholder .placeholder.s1 {
height: 12px;
}
.messages-list > .post_ajax_loader .message-item--placeholder .message-item__actions {
align-self: center;
}
@media (prefers-reduced-motion: reduce) {
.messages-list > .post_ajax_loader .placeholder {
animation: none;
}
}
@@ -479,10 +503,6 @@ html.dark .message-detail {
.messages-pagination__more {
transition: none;
}
.messages-center.is-loading .messages-pagination__more span::before {
animation: none;
}
}
/* ---- 响应式 ---- */
-44
View File
@@ -155,50 +155,6 @@
border-color: var(--color-primary, #f04494);
}
/* AJAX 加载更多 */
.load-more {
text-align: center;
padding: 20px 0;
}
.load-more__btn {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 10px 24px;
font-size: 13px;
color: var(--color-ink-2, #4e5358);
background: var(--surface-1, #fff);
border: 1px solid var(--color-line, rgba(50, 50, 50, 0.06));
border-radius: 20px;
cursor: pointer;
transition: all 0.2s;
}
.load-more__btn:hover {
color: var(--color-primary, #f04494);
border-color: var(--color-primary, #f04494);
}
.load-more__btn:disabled {
opacity: 0.5;
cursor: not-allowed;
}
.load-more__spinner {
display: inline-block;
width: 16px;
height: 16px;
border: 2px solid var(--surface-3, #e8e8e8);
border-top-color: var(--color-primary, #f04494);
border-radius: 50%;
animation: spin 0.6s linear infinite;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
/* 移动端 */
@media (max-width: 767px) {
.pagination a,
-141
View File
@@ -1,141 +0,0 @@
/* ========== 骨架屏加载 — 对齐 legacy skeleton loading ========== */
.skeleton {
position: relative;
overflow: hidden;
background: var(--surface-2, #eee);
border-radius: var(--radius, 8px);
}
.skeleton::after {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: linear-gradient(
90deg,
transparent 0%,
rgba(255, 255, 255, 0.4) 50%,
transparent 100%
);
animation: skeleton-shimmer 1.5s infinite;
}
@keyframes skeleton-shimmer {
0% { transform: translateX(-100%); }
100% { transform: translateX(100%); }
}
/* 骨架屏变体 */
.skeleton-text {
height: 14px;
border-radius: 4px;
margin-bottom: 8px;
}
.skeleton-text--title {
height: 20px;
width: 60%;
margin-bottom: 12px;
}
.skeleton-text--short {
width: 40%;
}
.skeleton-text--medium {
width: 70%;
}
.skeleton-avatar {
width: 48px;
height: 48px;
border-radius: 50%;
flex-shrink: 0;
}
.skeleton-avatar--sm {
width: 32px;
height: 32px;
}
.skeleton-avatar--lg {
width: 64px;
height: 64px;
}
.skeleton-thumb {
width: 100%;
aspect-ratio: 16 / 9;
border-radius: var(--radius, 8px);
}
.skeleton-thumb--square {
aspect-ratio: 1;
}
.skeleton-thumb--card {
aspect-ratio: 16 / 10;
border-radius: var(--radius, 8px) var(--radius, 8px) 0 0;
}
/* 卡片骨架屏 */
.skeleton-card {
background: var(--surface-1, #fff);
border-radius: var(--radius, 8px);
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
overflow: hidden;
}
.skeleton-card__thumb {
width: 100%;
aspect-ratio: 16 / 10;
}
.skeleton-card__body {
padding: 14px 16px;
}
.skeleton-card__meta {
display: flex;
align-items: center;
gap: 8px;
margin-top: 10px;
}
/* 评论骨架屏 */
.skeleton-comment {
display: flex;
gap: 12px;
padding: 16px 0;
border-bottom: 1px solid var(--color-line-soft, rgba(0, 0, 0, 0.03));
}
.skeleton-comment__body {
flex: 1;
}
.skeleton-comment__header {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 10px;
}
/* 通用骨架屏容器 */
.skeleton-list .skeleton-item {
padding: 12px 0;
border-bottom: 1px solid var(--color-line-soft, rgba(0, 0, 0, 0.03));
}
.skeleton-list .skeleton-item:last-child {
border-bottom: none;
}
/* 减弱动画偏好 */
@media (prefers-reduced-motion: reduce) {
.skeleton::after {
animation: none;
}
}
+16 -2
View File
@@ -548,7 +548,21 @@
}
.aksrt-user-home .dashboard-panel.is-loading {
opacity: .6;
transition: opacity var(--dur-fast, .15s) var(--ease, ease);
pointer-events: none;
}
/* 面板翻页的加载态由列表骨架承担(与文章列表 .post_ajax_loader 同一契约)。 */
.aksrt-user-home .dashboard-panel .post_ajax_loader {
display: none;
}
.aksrt-user-home .dashboard-panel.is-loading .post_ajax_loader {
display: block;
animation: aksrtFadeIn 0.2s ease both;
}
@media (prefers-reduced-motion: reduce) {
.aksrt-user-home .dashboard-panel .post_ajax_loader .placeholder {
animation: none;
}
}
+25 -1
View File
@@ -70,11 +70,18 @@
currentList.querySelectorAll('[data-notification-id]').forEach(function (item) {
existingIds.add(item.dataset.notificationId);
});
// 骨架常驻列表末尾:新条目一律插到它之前,形状与参考主题一致
// (post_ajax 的 beforeSend 把 loader 挪到最后一张卡片之后)。
var skeleton = currentList.querySelector(':scope > .post_ajax_loader');
var firstAdded = null;
incomingList.querySelectorAll('.message-item').forEach(function (item) {
if (existingIds.has(item.dataset.notificationId)) return;
if (!firstAdded) firstAdded = item;
currentList.appendChild(item);
if (skeleton) {
currentList.insertBefore(item, skeleton);
} else {
currentList.appendChild(item);
}
});
var currentPagination = content.querySelector('.messages-pagination');
@@ -93,6 +100,9 @@
var settings = options || {};
root.classList.add('is-loading');
content.setAttribute('aria-busy', 'true');
// 骨架只在 AJAX 请求期间展开(.is-loading),与文章列表翻页同一契约。
var skeleton = content.querySelector('.messages-list > .post_ajax_loader');
if (skeleton) skeleton.classList.add('is-loading');
return post('aksrt_load_message_center', {
view: requested.view,
@@ -111,7 +121,19 @@
if (settings.append && state.paginateType === 'ajax_lists') {
firstAdded = appendMessagePage(result.data.content);
} else {
// 替换时保留骨架容器(参考主题 success 后只 hide() 不删除),
// 让后续翻页复用同一节点而不是回到无骨架状态。
var keep = content.querySelector('.post_ajax_loader');
content.innerHTML = result.data.content;
var nextSkeleton = content.querySelector('.post_ajax_loader');
if (keep && !nextSkeleton) {
var list = content.querySelector('.messages-list');
if (list) {
list.appendChild(keep);
} else {
content.appendChild(keep);
}
}
}
updateHeaderBadge(result.data.unread);
@@ -131,6 +153,8 @@
}).finally(function () {
root.classList.remove('is-loading');
content.removeAttribute('aria-busy');
var loader = content.querySelector('.messages-list > .post_ajax_loader');
if (loader) loader.classList.remove('is-loading');
});
}
-173
View File
@@ -1,173 +0,0 @@
/**
* AKSRT Waterfall — 瀑布流/异步列表
*
* 提供纯 CSS column-based 瀑布流布局和无限滚动加载能力。
* 无外部依赖。
*
* @package AKSRT
*/
(function () {
'use strict';
/**
* Initialize waterfall layout on a container.
*
* @param {HTMLElement} container - The container element
* @param {Object} options
* @param {number} options.columns - Number of columns (default: auto from CSS)
* @param {string} options.itemSelector - Child item selector (default: '.waterfall-item')
* @param {number} options.gap - Gap between items in px (default: 16)
*/
function Waterfall(container, options) {
if (!container) return;
this.container = container;
this.options = Object.assign({
columns: 0,
itemSelector: '.waterfall-item',
gap: 16,
}, options || {});
this._resizeHandler = this.layout.bind(this);
window.addEventListener('resize', this._resizeHandler);
this.layout();
}
Waterfall.prototype.layout = function () {
var items = this.container.querySelectorAll(this.options.itemSelector);
if (items.length === 0) return;
var cols = this.options.columns;
if (cols <= 0) {
var containerWidth = this.container.offsetWidth;
cols = Math.max(1, Math.floor(containerWidth / 280));
}
var gap = this.options.gap;
var colWidth = (this.container.offsetWidth - gap * (cols - 1)) / cols;
var colHeights = new Array(cols).fill(0);
for (var i = 0; i < items.length; i++) {
var item = items[i];
item.style.width = colWidth + 'px';
item.style.position = 'absolute';
// Find shortest column
var minHeight = Infinity;
var minCol = 0;
for (var c = 0; c < cols; c++) {
if (colHeights[c] < minHeight) {
minHeight = colHeights[c];
minCol = c;
}
}
item.style.left = (minCol * (colWidth + gap)) + 'px';
item.style.top = colHeights[minCol] + 'px';
colHeights[minCol] += item.offsetHeight + gap;
}
// Set container height to tallest column
var maxHeight = Math.max.apply(null, colHeights);
this.container.style.height = maxHeight + 'px';
this.container.style.position = 'relative';
};
Waterfall.prototype.relayout = function () {
this.layout();
};
Waterfall.prototype.destroy = function () {
window.removeEventListener('resize', this._resizeHandler);
};
/**
* Infinite scroll loader.
*
* @param {Object} options
* @param {string} options.containerSelector - List container selector
* @param {string} options.loadMoreSelector - Load-more button selector
* @param {Function} options.loadMore - Async function that loads more items
* @param {number} options.threshold - Distance from bottom to trigger (default: 200)
*/
function InfiniteScroll(options) {
this.options = Object.assign({
containerSelector: '.aksrt-infinite-list',
loadMoreSelector: '.aksrt-load-more',
loadMore: null,
threshold: 200,
}, options || {});
this.loading = false;
this.hasMore = true;
this._scrollHandler = this._check.bind(this);
window.addEventListener('scroll', this._scrollHandler);
this._check();
}
InfiniteScroll.prototype._check = function () {
if (this.loading || !this.hasMore) return;
var loadMoreBtn = document.querySelector(this.options.loadMoreSelector);
if (!loadMoreBtn) {
this.hasMore = false;
return;
}
var rect = loadMoreBtn.getBoundingClientRect();
if (rect.top < window.innerHeight + this.options.threshold) {
this._load();
}
};
InfiniteScroll.prototype._load = function () {
if (!this.options.loadMore) return;
this.loading = true;
var self = this;
this.options.loadMore().then(function (hasMore) {
self.hasMore = hasMore !== false;
self.loading = false;
if (self.hasMore) {
self._check();
}
}).catch(function () {
self.loading = false;
});
};
InfiniteScroll.prototype.destroy = function () {
window.removeEventListener('scroll', this._scrollHandler);
};
// Auto-init
var waterfallInstances = [];
function relayoutAll() {
waterfallInstances.forEach(function (instance) {
if (instance && typeof instance.relayout === 'function') {
instance.relayout();
}
});
}
function autoInit() {
document.querySelectorAll('[data-aksrt-waterfall]:not([data-aksrt-waterfall-bound])').forEach(function (el) {
el.dataset.aksrtWaterfallBound = '1';
var cols = parseInt(el.dataset.aksrtWaterfallColumns) || 0;
var gap = parseInt(el.dataset.aksrtWaterfallGap) || 16;
waterfallInstances.push(new Waterfall(el, { columns: cols, gap: gap }));
});
relayoutAll();
}
jQuery(document).off('auto_fun.aksrt-waterfall').on('auto_fun.aksrt-waterfall', autoInit);
jQuery(document).off('lazyloaded.aksrt-waterfall').on('lazyloaded.aksrt-waterfall', relayoutAll);
// Export to global
window.AksrtWaterfall = Waterfall;
window.AksrtInfiniteScroll = InfiniteScroll;
})();
+55 -8
View File
@@ -109,16 +109,27 @@
}
function loaderOf(container) {
if (!container) return null;
return container.querySelector('.post_ajax_loader');
}
function fallbackLoader() {
var text = (window.aksrtData && aksrtData.ajaxLoading) || '加载中...';
var node = document.createElement('div');
node.className = 'post_ajax_loader';
node.setAttribute('role', 'status');
node.innerHTML = '<div class="mb20"><div class="text-center muted-2-color mt20"><i class="loading mr10"></i>' + text + '</div></div>';
return node;
}
function setBusy(container, busy) {
if (!container) return;
if (busy) {
container.dataset.loading = '1';
container.setAttribute('aria-busy', 'true');
var loader = loaderOf(container);
// 骨架开关走 .is-loading 类(modal-runtime.css),不写 inline display。
if (loader) loader.classList.add('is-loading');
var loader = loaderOf(container) || container.appendChild(fallbackLoader());
loader.classList.add('is-loading');
} else {
delete container.dataset.loading;
container.setAttribute('aria-busy', 'false');
@@ -127,6 +138,21 @@
}
}
// 参考主题 post_ajax 的 beforeSend 语义:骨架每次请求都挪到列表末尾
// (最后一个条目之后、分页控件之前),请求成功后只隐藏而不删除,
// 下一轮翻页复用同一个节点。
function anchorLoader(container) {
var pag = container.querySelector(':scope > .ajax-pag');
var loader = loaderOf(container);
if (!loader) return null;
if (pag) {
pag.parentNode.insertBefore(loader, pag);
} else {
container.appendChild(loader);
}
return loader;
}
function loadItems(container, page, append) {
var owner = container.closest('[data-widget]') || container;
var widget = owner.dataset.widget || container.dataset.widget;
@@ -134,28 +160,49 @@
var segment = container.dataset.segment || owner.dataset.segment || '';
if (!widget || !instance || !config.restUrl || container.dataset.loading === '1') return;
setBusy(container, true);
fetch(itemsUrl(widget, instance, page, segment), { credentials: 'same-origin', headers: { Accept: 'application/json' } })
anchorLoader(container);
return fetch(itemsUrl(widget, instance, page, segment), { credentials: 'same-origin', headers: { Accept: 'application/json' } })
.then(function (response) { if (!response.ok) throw new Error('items'); return response.json(); })
.then(function (data) {
var fragment = document.createElement('div');
fragment.innerHTML = String(data.html || '');
Array.prototype.slice.call(container.querySelectorAll(':scope > .ajax-pag')).forEach(function (node) { node.remove(); });
if (append) {
Array.prototype.slice.call(fragment.children).forEach(function (node) { container.appendChild(node); });
// 追加方向为底部:新条目插到骨架之前,骨架始终贴住最后一张卡片。
var anchor = loaderOf(container) || container.querySelector(':scope > .ajax-pag');
Array.prototype.slice.call(fragment.children).forEach(function (node) {
if (anchor && anchor.parentNode === container) {
container.insertBefore(node, anchor);
} else {
container.appendChild(node);
}
});
} else {
container.innerHTML = fragment.innerHTML;
// 替换时保留骨架节点本身(参考主题 success 后只 hide() 不删除)。
var loader = loaderOf(container);
Array.prototype.slice.call(container.children).forEach(function (child) {
if (child !== loader && !child.classList.contains('ajax-pag')) child.remove();
});
Array.prototype.slice.call(fragment.children).forEach(function (node) { container.appendChild(node); });
}
Array.prototype.slice.call(container.querySelectorAll(':scope > .ajax-pag')).forEach(function (node) { node.remove(); });
if (data.paginate_html) container.insertAdjacentHTML('beforeend', data.paginate_html);
container.dataset.page = String(data.page || page);
anchorLoader(container);
scan(container);
})
.catch(function () { container.innerHTML = errorMarkup(); })
.catch(function () {
var loader = loaderOf(container);
if (loader && loader.parentNode === container) {
loader.insertAdjacentHTML('beforebegin', errorMarkup());
} else {
container.insertAdjacentHTML('afterbegin', errorMarkup());
}
})
.finally(function () { setBusy(container, false); });
}
function initItems(container) {
if (!once(container, 'Items')) return;
if (container.classList.contains('is-loading')) loadItems(container, 1, false);
container.addEventListener('click', function (event) {
var retry = event.target.closest('[data-widget-retry]');
var trigger = event.target.closest('[data-next-page]');
+1
View File
@@ -55,6 +55,7 @@ require_once AKSRT_DIR . '/inc/helpers/aksrt-null.php';
require_once AKSRT_DIR . '/inc/helpers/user-ban.php';
require_once AKSRT_DIR . '/inc/helpers/aksrt-ajax-list.php';
require_once AKSRT_DIR . '/inc/helpers/aksrt-links.php';
require_once AKSRT_DIR . '/inc/helpers/message-placeholder.php';
require_once AKSRT_DIR . '/inc/helpers/search/aksrt-search-posts.php';
require_once AKSRT_DIR . '/inc/helpers/search/aksrt-search-box.php';
require_once AKSRT_DIR . '/inc/helpers/aksrt-header-userbox.php';
+37
View File
@@ -0,0 +1,37 @@
<?php
/**
* Message centre skeleton placeholder.
*
* The message list is not an article stream, so it reuses the shared
* `.placeholder` block contract (`inc/helpers/posts-renderer/markup.php`)
* while mirroring the real `.message-item` geometry — circular icon dot,
* title bar, description bar and a time bar. Rendered inside the standard
* `.post_ajax_loader` shell so `messages.js` can toggle `.is-loading` the
* same way `pagination.js` does for post lists.
*
* @package AKSRT
*/
defined('ABSPATH') || exit;
if (!function_exists('aksrt_get_message_placeholder')) {
/**
* Build the message-centre skeleton for the AJAX load-more cycle.
*
* @param int $count Repeated message rows, 1–12.
* @return string
*/
function aksrt_get_message_placeholder(int $count = 4): string {
$count = max(1, min(12, $count));
$item = '<article class="message-item message-item--placeholder" aria-hidden="true">'
. '<span class="message-item__icon placeholder"></span>'
. '<div class="message-item__body">'
. '<div class="placeholder t1" style="width: 62%;"></div>'
. '<div class="placeholder k2 mt6" style="width: 88%;"></div>'
. '<div class="placeholder s1 mt10"></div>'
. '</div>'
. '<div class="message-item__actions"><span class="placeholder s1" style="width: 46px;"></span></div>'
. '</article>';
return '<div class="post_ajax_loader">' . str_repeat($item, $count) . '</div>';
}
}
+5
View File
@@ -226,6 +226,11 @@ function aksrt_render_message_center_list(int $user_id, string $view, int $page
?>
<div class="messages-list">
<?php foreach ($items as $item) { aksrt_render_message_item($item, $view); } ?>
<?php
if (function_exists('aksrt_get_message_placeholder')) {
echo aksrt_get_message_placeholder(4); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- 固定骨架结构。
}
?>
</div>
<?php if ($total_pages > 1) : ?>
<?php if ($paginate_type === 'ajax_lists' && $page < $total_pages) : ?>
+1 -1
View File
@@ -118,7 +118,7 @@ if (is_active_sidebar('search_top_fluid')) {
<?php else : ?>
<div class="aksrt-panel search-content"><div class="text-center muted-2-color padding-20"><?php esc_html_e('未找到相关内容', 'aksrt'); ?></div></div>
<?php endif; ?>
<div class="post_ajax_loader search-loader"><div class="mb20"><div class="text-center muted-2-color mt20"><i class="loading mr10"></i><?php esc_html_e('加载中...', 'aksrt'); ?></div></div></div>
<div class="post_ajax_loader search-loader"><?php echo function_exists('aksrt_render_placeholder') ? aksrt_render_placeholder('list', 6) : ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- 固定骨架结构。 ?></div>
</div>
<?php if (is_active_sidebar('search_bottom_content')) dynamic_sidebar('search_bottom_content'); ?>
</div>
+10 -6
View File
@@ -44,15 +44,19 @@ final class ContentRenderer {
if ($segment !== '') {
$attrs .= ' data-segment="' . esc_attr($segment) . '"';
}
$loader = '<div class="post_ajax_loader" role="status" aria-label="' . esc_attr__('正在加载', 'aksrt') . '">' . self::placeholder($instance) . '</div>';
if (($instance['load_mode'] ?? '') === 'ajax') {
// The runtime (lazysizes + lazyload-action) reveals this container
// and clicks the single .ias-btn trigger; frontend.js then loads
// the first page through the REST client.
$trigger = '<span class="hide aksrt-ias-trigger"><a class="ias-btn" no-scroll="true" href="javascript:void(0)" data-widget-ias="1" data-next-page="1" aria-hidden="true" tabindex="-1"></a></span>';
return '<div class="widget-ajaxpager lazyload" lazyload-action="ias"' . $attrs . ' aria-live="polite" aria-busy="true">' . $trigger . '<div class="post_ajax_loader" role="status" aria-label="' . esc_attr__('正在加载', 'aksrt') . '">' . self::placeholder($instance) . '</div></div>';
return '<div class="widget-ajaxpager lazyload" lazyload-action="ias"' . $attrs . ' aria-live="polite" aria-busy="true">' . $trigger . $loader . '</div>';
}
$payload = PostRenderer::payload($instance, $slug, $page, $segment);
return '<div class="widget-ajaxpager"' . $attrs . ' aria-live="polite" aria-busy="false">' . $payload['html'] . $payload['paginate_html'] . '</div>';
// The loader must live inside the pager: the REST client in frontend.js
// resolves it with container.querySelector('.post_ajax_loader'), so a
// sibling node would never be found and the skeleton would stay shut.
return '<div class="widget-ajaxpager"' . $attrs . ' aria-live="polite" aria-busy="false">' . $payload['html'] . $payload['paginate_html'] . $loader . '</div>';
}
private static function placeholder(array $instance): string {
@@ -88,11 +92,11 @@ final class ContentRenderer {
if ($selected) {
$body = self::ajaxpager($instance, 'tab_posts', $widget_id, 1, (string) $index);
} else {
// Inactive panes load lazily through the REST client on switch.
$body = '<div class="widget-ajaxpager" data-widget-items data-widget="tab_posts" data-instance="' . esc_attr($widget_id) . '" data-page="1" data-segment="' . (int) $index . '" aria-live="polite" aria-busy="false"></div>';
// Inactive panes load lazily through the REST client on switch,
// so the pane ships pre-filled with the skeleton. 显隐交给
// .is-loading,内联 display:none 会让 REST 客户端无法展开骨架。
$body = '<div class="widget-ajaxpager" data-widget-items data-widget="tab_posts" data-instance="' . esc_attr($widget_id) . '" data-page="1" data-segment="' . (int) $index . '" aria-live="polite" aria-busy="false"><div class="post_ajax_loader" role="status" aria-label="' . esc_attr__('正在加载', 'aksrt') . '">' . self::placeholder($instance) . '</div></div>';
}
// 显隐交给 .is-loading,内联 display:none 会让 REST 客户端无法展开骨架。
$body .= '<div class="post_ajax_loader">' . self::placeholder($instance) . '</div>';
$panels .= '<div class="tab-pane fade' . ($selected ? ' active in' : '') . '" id="' . esc_attr($panel_id . '-' . $visible_index) . '" role="tabpanel" aria-labelledby="' . esc_attr($tab_id) . '">' . $body . '</div>';
$visible_index++;
}
@@ -34,7 +34,12 @@ if (!empty($favorite_post_ids)) :
'no_found_rows' => false,
'update_post_meta_cache' => false,
]);
aksrt_render_post_list(array_merge($user_home_render_config, ['wrapper_class' => 'aksrt-user-home__post-list']), $favorites_query);
// 面板 AJAX 翻页期间由 author.js 切 .is-loading,骨架沿用文章列表的
// .post_ajax_loader 契约。
$user_home_panel_loader = function_exists('aksrt_render_placeholder')
? '<div class="post_ajax_loader" role="status" aria-label="' . esc_attr__('正在加载', 'aksrt') . '">' . aksrt_render_placeholder('list', max(4, (int) $per_page)) . '</div>'
: '';
aksrt_render_post_list(array_merge($user_home_render_config, ['wrapper_class' => 'aksrt-user-home__post-list', 'append_inner_html' => $user_home_panel_loader]), $favorites_query);
aksrt_render_user_home_pagination((int) $favorites_query->max_num_pages, (int) $favorites_page);
wp_reset_postdata();
else :
+6 -1
View File
@@ -29,6 +29,11 @@ $author_posts = new WP_Query([
'paged' => $posts_page,
'no_found_rows' => false,
]);
aksrt_render_post_list(array_merge($user_home_render_config, ['wrapper_class' => 'aksrt-user-home__post-list']), $author_posts);
// 面板 AJAX 翻页期间由 author.js 切 .is-loading,骨架沿用文章列表的
// .post_ajax_loader 契约。
$user_home_panel_loader = function_exists('aksrt_render_placeholder')
? '<div class="post_ajax_loader" role="status" aria-label="' . esc_attr__('正在加载', 'aksrt') . '">' . aksrt_render_placeholder('list', max(4, (int) $per_page)) . '</div>'
: '';
aksrt_render_post_list(array_merge($user_home_render_config, ['wrapper_class' => 'aksrt-user-home__post-list', 'append_inner_html' => $user_home_panel_loader]), $author_posts);
aksrt_render_user_home_pagination((int) $author_posts->max_num_pages, (int) $posts_page);
wp_reset_postdata();
@@ -60,6 +60,38 @@ test('old asset implementations and compatibility aliases are absent', () => {
assert.deepEqual(violations, [])
})
test('skeleton loading ships one contract and no dead spinner stylesheets', () => {
// The skeleton contract is the shared .placeholder block inside a
// .post_ajax_loader wrapper. The standalone helpers below were never wired
// to any producer and were removed; they must not come back as a second path.
for (const removed of [
'assets/css/frontend/skeleton.css',
'assets/css/frontend/ajax-spinner.css',
'assets/js/waterfall.js',
]) {
assert.equal(fs.existsSync(path.join(root, removed)), false, `${removed} must stay deleted`)
}
const build = fs.readFileSync(path.join(root, 'tools', 'build-public-assets.mjs'), 'utf8')
for (const dropped of ['skeleton.css', 'ajax-spinner.css']) {
assert.doesNotMatch(build, new RegExp(dropped.replace('.', '\\.')))
}
// Dead rule families with no producer in PHP or JS.
const css = sourceFiles(path.join(root, 'assets', 'css'))
.filter((f) => !f.includes('build') && !f.endsWith('.min.css'))
for (const file of css) {
const text = fs.readFileSync(file, 'utf8')
assert.doesNotMatch(text, /\.load-more__(?:btn|spinner)/, `${path.relative(root, file)} must not reintroduce .load-more__*`)
assert.doesNotMatch(text, /\.aksrt-loading__(?:spinner|overlay|inline|text|dot)/, `${path.relative(root, file)} must not reintroduce .aksrt-loading__*`)
assert.doesNotMatch(text, /aksrt-progress-bar/, `${path.relative(root, file)} must not reintroduce .aksrt-progress-bar`)
// A second parallel skeleton system (never wired to any producer).
assert.doesNotMatch(text, /\.aksrt-skeleton/, `${path.relative(root, file)} must not reintroduce .aksrt-skeleton-*`)
assert.doesNotMatch(text, /aksrt-skeleton-shimmer/, `${path.relative(root, file)} must not reintroduce the parallel shimmer keyframes`)
assert.doesNotMatch(text, /--skeleton-(?:base|shine)/, `${path.relative(root, file)} must not reintroduce the unused skeleton tokens`)
}
})
test('asset tables are InnoDB and operation keys are unique', () => {
const schema = fs.readFileSync(path.join(root, 'src', 'Core', 'DBMigratorPart2.php'), 'utf8')
for (const table of ['asset_account', 'asset_transaction', 'asset_entry']) {
@@ -69,6 +69,36 @@ test('message pagination setting switches between cumulative loading and numeric
assert.match(styles, /\.messages-pagination__button\.is-current/);
});
test('message centre shows a skeleton during the AJAX load-more cycle', () => {
const list = read('inc/modules/message-center.php');
const placeholder = read('inc/helpers/message-placeholder.php');
const script = read('assets/js/messages.js');
const styles = read('assets/css/frontend/messages.css');
// The skeleton ships inside .messages-list so the loader is anchored to the
// end of the list, mirroring the reference post_ajax beforeSend hook.
assert.match(list, /aksrt_get_message_placeholder\(4\)/);
assert.match(placeholder, /message-item--placeholder/);
assert.match(placeholder, /class="post_ajax_loader"/);
// The message skeleton reuses the shared .placeholder shimmer contract.
assert.match(placeholder, /placeholder t1/);
assert.match(placeholder, /placeholder k2/);
assert.match(placeholder, /placeholder s1/);
// Load cycle: show on start, hide on finish, and never remove the node.
assert.match(script, /content\.querySelector\('\.messages-list > \.post_ajax_loader'\)/);
assert.match(script, /skeleton\.classList\.add\('is-loading'\)/);
assert.match(script, /loader\.classList\.remove\('is-loading'\)/);
// Appended rows land before the skeleton so it stays flush under the list.
assert.match(script, /currentList\.insertBefore\(item, skeleton\)/);
// Visibility is class-driven; the old button spinner / opacity dim are gone.
assert.match(styles, /\.messages-list > \.post_ajax_loader \{/);
assert.match(styles, /\.messages-list > \.post_ajax_loader\.is-loading \{/);
assert.doesNotMatch(styles, /messages-pagination-spin/);
assert.doesNotMatch(styles, /opacity: 0\.55/);
});
test('tabs, pagination, actions, and detail all replace DOM fragments', () => {
const center = read('inc/modules/message-center.php');
const script = read('assets/js/messages.js');
@@ -44,6 +44,11 @@ test('the article stream exposes only the new typed renderer contract', () => {
assert.doesNotMatch(consumers, /function_exists\(['"]aksrt_render_post_list/);
assert.doesNotMatch(consumers, /aksrt_render_post_list\(\s*\$query\s*,/);
assert.doesNotMatch(consumers, /content-post-card|aksrt_homepage_render_post_card/);
// 搜索页的加载态必须是文章同构骨架,而不是遗留的转圈 spinner,
// 这样 runtime main.js 的 list 型 loader 形状才与搜索结果一致。
assert.match(read('search.php'), /post_ajax_loader search-loader"><\?php echo function_exists\('aksrt_render_placeholder'\) \? aksrt_render_placeholder\('list', 6\)/);
assert.doesNotMatch(read('search.php'), /class="loading mr10"/);
});
test('settings use legacy list modes, grouped options, and destructive related keys', () => {
@@ -224,6 +229,8 @@ test('related posts, author page and widgets use their dedicated renderers', ()
const relatedCard = read('inc/helpers/aksrt-single-components.php');
const resourceRelated = read('templates/parts/resource-related.php');
const author = read('templates/parts/user-home/panel-posts.php');
const authorFavorites = read('templates/parts/user-home/panel-favorites.php');
const userHomeCss = read('assets/css/routes/user-home.css');
const widgets = read('src/WidgetSystem/PostRenderer.php');
assert.match(related, /\['img', 'list', 'text'\]/);
@@ -249,6 +256,14 @@ test('related posts, author page and widgets use their dedicated renderers', ()
assert.match(author, /'wrapper_class'\s*=>\s*'aksrt-user-home__post-list'/);
assert.match(author, /aksrt_render_user_home_pagination\(\(int\) \$author_posts->max_num_pages, \(int\) \$posts_page\)/);
assert.doesNotMatch(author, /aksrt_render_pagination|aksrt_render_profile_pagination|\$_GET|add_query_arg/);
// 面板 AJAX 翻页的骨架:与文章列表同一个 .post_ajax_loader 契约,
// 由 author.js 的 .is-loading 切换(不能再靠 opacity 变暗反馈)。
assert.match(author, /'append_inner_html' => \$user_home_panel_loader/);
assert.match(author, /aksrt_render_placeholder\('list', max\(4, \(int\) \$per_page\)\)/);
assert.match(authorFavorites, /'append_inner_html' => \$user_home_panel_loader/);
assert.match(userHomeCss, /\.aksrt-user-home \.dashboard-panel \.post_ajax_loader \{/);
assert.match(userHomeCss, /\.aksrt-user-home \.dashboard-panel\.is-loading \.post_ajax_loader \{/);
assert.doesNotMatch(userHomeCss, /\.dashboard-panel\.is-loading \{[\s\S]{0,80}opacity: \.6/);
assert.match(widgets, /aksrt_render_mini_list/);
assert.match(widgets, /swiper-container swiper-scroll/);
});
@@ -454,7 +469,9 @@ test('profile routes load versioned leaf styles and keep dialogs hidden initiall
assert.doesNotMatch(panelFavorites, /'type'\s*=>\s*'list'/);
assert.match(panelFavorites, /'context'\s*=>\s*'author'/);
assert.match(panelFavorites, /aksrt_render_user_home_pagination\(\(int\) \$favorites_query->max_num_pages, \(int\) \$favorites_page\)/);
assert.match(panelFavorites, /array_merge\(\$user_home_render_config, \['wrapper_class' => 'aksrt-user-home__post-list'\]\), \$favorites_query\)/);
assert.match(panelFavorites, /array_merge\(\$user_home_render_config, \['wrapper_class' => 'aksrt-user-home__post-list', 'append_inner_html' => \$user_home_panel_loader\]\), \$favorites_query\)/);
assert.match(panelFavorites, /aksrt_render_placeholder\('list', max\(4, \(int\) \$per_page\)\)/);
assert.match(read('templates/parts/user-home/panel-posts.php'), /array_merge\(\$user_home_render_config, \['wrapper_class' => 'aksrt-user-home__post-list', 'append_inner_html' => \$user_home_panel_loader\]\), \$author_posts\)/);
assert.doesNotMatch(panelFavorites, /profile-list-item|\$_GET|add_query_arg/);
// Only the two-column user center spans the viewport; the single-column public
// profile keeps following the admin content max width.
@@ -25,6 +25,43 @@ test('tab and slider renderers retain reference DOM contracts', () => {
for (const token of ['relative zib-slider', 'new-swiper slide-widget', 'swiper-wrapper', 'swiper-slide', 'slide-layer', 'data-swiper-parallax', 'swiper-button-prev', 'swiper-pagination', 'widget-slider-graphic', 'slider-col', 'cover-col', 'widget-graphic-cover']) assert.match(slider, new RegExp(token.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')));
});
test('widget skeleton lives inside the AJAX container so the REST client can find it', () => {
const content = read('src/WidgetSystem/Renderers/ContentRenderer.php');
// The loader must be emitted inside .widget-ajaxpager: frontend.js resolves
// it with container.querySelector('.post_ajax_loader'). A sibling node would
// never match and no skeleton could appear on 加载更多.
assert.match(content, /\. \$loader \. '<\/div>'/);
assert.match(content, /aria-busy="false"><div class="post_ajax_loader" role="status"/);
// No pane may append the loader as a sibling of the pager.
assert.doesNotMatch(content, /\$body \.= '<div class="post_ajax_loader">'/);
});
test('widget REST client keeps the skeleton across the load-more cycle', () => {
const frontend = read('assets/widgets/frontend.js');
// Reference-parity loader switch: a class, never an inline display that
// would outrank the stylesheet and freeze the skeleton shut.
assert.match(frontend, /var loader = loaderOf\(container\) \|\| container\.appendChild\(fallbackLoader\(\)\);/);
assert.match(frontend, /loader\.classList\.add\('is-loading'\)/);
assert.doesNotMatch(frontend, /loader\.style\.display/);
// The skeleton is anchored to the end of the list on every request, exactly
// like the reference post_ajax beforeSend hook.
assert.match(frontend, /function anchorLoader\(container\) \{/);
assert.match(frontend, /if \(!loader\) return null;/);
assert.match(frontend, /pag\.parentNode\.insertBefore\(loader, pag\)/);
// Appended cards must land before the skeleton, so the skeleton always sits
// flush under the last card.
assert.match(frontend, /var anchor = loaderOf\(container\) \|\| container\.querySelector\(':scope > \.ajax-pag'\);/);
// A replace must preserve the loader node (the reference success only hides it).
assert.match(frontend, /if \(child !== loader && !child\.classList\.contains\('ajax-pag'\)\) child\.remove\(\);/);
assert.match(frontend, /return fetch\(itemsUrl\(/);
});
test('reference slider CSS includes responsive height and combo selectors', () => {
const css = read('assets/widgets/frontend.css');
const mainCss = read('assets/css/main.css');
+1 -1
View File
@@ -1,5 +1,5 @@
{
"generated_at": "2026-10-03T08:41:20+00:00",
"generated_at": "2026-10-03T14:21:05+00:00",
"errors": [],
"warnings": [
"customPage tools-update section 'tools/update' not in PHP schema (ok if pure operational page)",
-2
View File
@@ -30,10 +30,8 @@ const cssBundles = {
'assets/css/frontend/footer.css',
'assets/css/frontend/floating-buttons.css',
'assets/css/frontend/enhancements.css',
'assets/css/frontend/skeleton.css',
'assets/css/frontend/empty-state.css',
'assets/css/frontend/pagination.css',
'assets/css/frontend/ajax-spinner.css',
'assets/css/frontend/modal-runtime.css',
'assets/css/frontend/notyf.css',
'assets/css/shared/captcha.css',