1.0
This commit is contained in:
895
Plugin.php
Normal file
895
Plugin.php
Normal file
File diff suppressed because it is too large
Load Diff
282
assets/who-read-this.css
Normal file
282
assets/who-read-this.css
Normal file
@@ -0,0 +1,282 @@
|
||||
/* WhoReadThis 插件专用样式 - 独立文件避免冲突 */
|
||||
/* 版本: 1.0.6 */
|
||||
.whoreadthis-container {
|
||||
border-radius: 10px;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
z-index: 10;
|
||||
margin: 0 0 30px 0;
|
||||
clear: both;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
/* 标题区域 */
|
||||
.whoreadthis-container .whoreadthis-header-section {
|
||||
padding: 18px 24px;
|
||||
background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
|
||||
border: 1px solid #e1e8ed;
|
||||
position: relative;
|
||||
z-index: 20;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
/* 深色模式支持 */
|
||||
body.dark-mode .whoreadthis-container .whoreadthis-header-section,
|
||||
body.theme-dark .whoreadthis-container .whoreadthis-header-section,
|
||||
body.dark .whoreadthis-container .whoreadthis-header-section {
|
||||
background: rgb(10 12 25 / 1);
|
||||
border: 1px solid #2d3748;
|
||||
}
|
||||
|
||||
/* 标题文字 */
|
||||
.whoreadthis-container .whoreadthis-header {
|
||||
margin: 0;
|
||||
font-size: 18px;
|
||||
color: #fff;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
font-weight: 600;
|
||||
position: relative;
|
||||
z-index: 25;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
/* 深色模式标题 */
|
||||
body.dark-mode .whoreadthis-container .whoreadthis-header h3,
|
||||
body.theme-dark .whoreadthis-container .whoreadthis-header h3,
|
||||
body.dark .whoreadthis-container .whoreadthis-header h3 {
|
||||
color: #e2e8f0 !important;
|
||||
}
|
||||
|
||||
/* 计数徽章 */
|
||||
.whoreadthis-container .whoreadthis-count-badge {
|
||||
background-color: rgba(255, 255, 255, 0.2);
|
||||
color: white;
|
||||
padding: 4px 8px;
|
||||
border-radius: 12px;
|
||||
font-size: 13px;
|
||||
margin-left: 8px;
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
/* 深色模式徽章 */
|
||||
body.dark-mode .whoreadthis-container .whoreadthis-count-badge,
|
||||
body.theme-dark .whoreadthis-container .whoreadthis-count-badge,
|
||||
body.dark .whoreadthis-container .whoreadthis-count-badge {
|
||||
background-color: rgba(255, 255, 255, 0.1);
|
||||
color: #e2e8f0;
|
||||
}
|
||||
|
||||
/* 切换按钮 */
|
||||
.whoreadthis-container .whoreadthis-toggle-btn {
|
||||
font-size: 0.8em;
|
||||
color: #fff;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
padding: 4px 10px;
|
||||
border-radius: 4px;
|
||||
transition: all 0.3s ease;
|
||||
font-weight: normal;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
position: relative;
|
||||
z-index: 30;
|
||||
background: transparent;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.whoreadthis-container .whoreadthis-toggle-btn:hover {
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
}
|
||||
|
||||
.whoreadthis-container .whoreadthis-toggle-btn .toggle-arrow {
|
||||
font-size: 14px;
|
||||
line-height: 1;
|
||||
transition: transform 0.3s ease;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.whoreadthis-container .whoreadthis-toggle-btn.expanded .toggle-arrow {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
|
||||
/* 内容区域 */
|
||||
.whoreadthis-container .whoreadthis-content-section {
|
||||
padding: 0 24px;
|
||||
background: #f9fafb;
|
||||
border-top: none;
|
||||
border-radius: 0 0 10px 10px;
|
||||
position: relative;
|
||||
z-index: 15;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
/* 深色模式内容区域 */
|
||||
body.dark-mode .whoreadthis-container .whoreadthis-content-section,
|
||||
body.theme-dark .whoreadthis-container .whoreadthis-content-section,
|
||||
body.dark .whoreadthis-container .whoreadthis-content-section {
|
||||
background: rgb(15 23 42 / 1);
|
||||
}
|
||||
|
||||
/* 项目包装器 */
|
||||
.whoreadthis-container .whoreadthis-items-wrapper {
|
||||
transition: all 0.3s ease;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
z-index: 15;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.whoreadthis-container .whoreadthis-items-wrapper.collapsed {
|
||||
max-height: 0;
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.whoreadthis-container .whoreadthis-items-wrapper.expanded {
|
||||
max-height: 5000px;
|
||||
opacity: 1;
|
||||
visibility: visible;
|
||||
padding: 20px 0;
|
||||
}
|
||||
|
||||
/* 阅读者列表 */
|
||||
.whoreadthis-container .whoreadthis-users {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 12px;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
position: relative;
|
||||
z-index: 40;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.whoreadthis-container .whoreadthis-user {
|
||||
position: relative;
|
||||
z-index: 45;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
/* 头像包装器 */
|
||||
.whoreadthis-container .whoreadthis-avatar-wrapper {
|
||||
position: relative;
|
||||
display: block;
|
||||
z-index: 50;
|
||||
text-decoration: none;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
/* 头像样式 */
|
||||
.whoreadthis-container .whoreadthis-avatar {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border-radius: 50%;
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
display: block;
|
||||
position: relative;
|
||||
z-index: 55;
|
||||
transition: transform 0.3s ease;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.whoreadthis-container .whoreadthis-avatar:hover {
|
||||
transform: scale(1.05);
|
||||
}
|
||||
|
||||
.whoreadthis-container .whoreadthis-avatar img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
border-radius: 50%;
|
||||
padding: 2px;
|
||||
border: 2px solid #f15a22;
|
||||
display: block;
|
||||
transition: transform 0.4s ease-out;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.whoreadthis-container .whoreadthis-avatar img:hover {
|
||||
transform: rotateZ(360deg);
|
||||
}
|
||||
|
||||
/* 空状态 */
|
||||
.whoreadthis-container .whoreadthis-empty {
|
||||
text-align: center;
|
||||
color: #95a5a6;
|
||||
font-style: italic;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
/* 响应式设计 */
|
||||
@media (max-width: 768px) {
|
||||
.whoreadthis-container .whoreadthis-header-section,
|
||||
.whoreadthis-container .whoreadthis-content-section {
|
||||
padding: 14px 18px;
|
||||
}
|
||||
|
||||
.whoreadthis-container .whoreadthis-header {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.whoreadthis-container .whoreadthis-users {
|
||||
gap: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 480px) {
|
||||
.whoreadthis-container .whoreadthis-header-section,
|
||||
.whoreadthis-container .whoreadthis-content-section {
|
||||
padding: 12px 15px;
|
||||
}
|
||||
|
||||
.whoreadthis-container .whoreadthis-header {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.whoreadthis-container .whoreadthis-count-badge {
|
||||
font-size: 11px;
|
||||
padding: 3px 6px;
|
||||
}
|
||||
|
||||
.whoreadthis-container .whoreadthis-users {
|
||||
gap: 6px;
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
|
||||
/* 动画效果 */
|
||||
@keyframes whoreadthisFadeIn {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(10px);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
.whoreadthis-container .whoreadthis-items-wrapper.expanded .whoreadthis-user {
|
||||
animation: whoreadthisFadeIn 0.3s ease forwards;
|
||||
}
|
||||
|
||||
/* 为每个头像添加延迟动画 */
|
||||
.whoreadthis-container .whoreadthis-items-wrapper.expanded .whoreadthis-user:nth-child(1) { animation-delay: 0.05s; }
|
||||
.whoreadthis-container .whoreadthis-items-wrapper.expanded .whoreadthis-user:nth-child(2) { animation-delay: 0.1s; }
|
||||
.whoreadthis-container .whoreadthis-items-wrapper.expanded .whoreadthis-user:nth-child(3) { animation-delay: 0.15s; }
|
||||
.whoreadthis-container .whoreadthis-items-wrapper.expanded .whoreadthis-user:nth-child(4) { animation-delay: 0.2s; }
|
||||
.whoreadthis-container .whoreadthis-items-wrapper.expanded .whoreadthis-user:nth-child(5) { animation-delay: 0.25s; }
|
||||
.whoreadthis-container .whoreadthis-items-wrapper.expanded .whoreadthis-user:nth-child(6) { animation-delay: 0.3s; }
|
||||
.whoreadthis-container .whoreadthis-items-wrapper.expanded .whoreadthis-user:nth-child(7) { animation-delay: 0.35s; }
|
||||
.whoreadthis-container .whoreadthis-items-wrapper.expanded .whoreadthis-user:nth-child(8) { animation-delay: 0.4s; }
|
||||
.whoreadthis-container .whoreadthis-items-wrapper.expanded .whoreadthis-user:nth-child(9) { animation-delay: 0.45s; }
|
||||
.whoreadthis-container .whoreadthis-items-wrapper.expanded .whoreadthis-user:nth-child(10) { animation-delay: 0.5s; }
|
||||
150
assets/who-read-this.js
Normal file
150
assets/who-read-this.js
Normal file
@@ -0,0 +1,150 @@
|
||||
/**
|
||||
* WhoReadThis 插件专用脚本 - 独立文件避免冲突
|
||||
* 版本: 1.0.6
|
||||
*/
|
||||
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
// 等待DOM加载完成
|
||||
function initWhoReadThis() {
|
||||
const containers = document.querySelectorAll('.whoreadthis-container');
|
||||
|
||||
containers.forEach(container => {
|
||||
if (container.dataset.whoReadThisInitialized === 'true') {
|
||||
return;
|
||||
}
|
||||
|
||||
container.dataset.whoReadThisInitialized = 'true';
|
||||
|
||||
const header = container.querySelector('.whoreadthis-header');
|
||||
const itemsWrapper = container.querySelector('.whoreadthis-items-wrapper');
|
||||
const toggleBtn = container.querySelector('.whoreadthis-toggle-btn');
|
||||
|
||||
// 设置头像大小
|
||||
const avatarSize = container.getAttribute('data-avatar-size');
|
||||
if (avatarSize && avatarSize !== '40') {
|
||||
const avatars = container.querySelectorAll('.whoreadthis-avatar');
|
||||
const avatarImgs = container.querySelectorAll('.whoreadthis-avatar img');
|
||||
|
||||
avatars.forEach(avatar => {
|
||||
avatar.style.width = avatarSize + 'px';
|
||||
avatar.style.height = avatarSize + 'px';
|
||||
});
|
||||
|
||||
avatarImgs.forEach(img => {
|
||||
img.style.width = avatarSize + 'px';
|
||||
img.style.height = avatarSize + 'px';
|
||||
});
|
||||
}
|
||||
|
||||
if (!header || !itemsWrapper || !toggleBtn) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 绑定标题点击事件
|
||||
header.addEventListener('click', function(e) {
|
||||
if (e.target.closest('.whoreadthis-toggle-btn')) {
|
||||
return;
|
||||
}
|
||||
toggleWhoReadThis(container);
|
||||
});
|
||||
|
||||
// 绑定按钮点击事件
|
||||
toggleBtn.addEventListener('click', function(e) {
|
||||
e.stopPropagation();
|
||||
toggleWhoReadThis(container);
|
||||
});
|
||||
|
||||
// 处理头像链接点击
|
||||
const avatarWrappers = container.querySelectorAll('.whoreadthis-avatar-wrapper');
|
||||
avatarWrappers.forEach(wrapper => {
|
||||
const link = wrapper.getAttribute('href');
|
||||
if (link && link !== '#') {
|
||||
wrapper.addEventListener('click', function(e) {
|
||||
e.stopPropagation();
|
||||
window.open(link, '_blank');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// 锚点跳转支持
|
||||
if (window.location.hash === '#whoreadthis' || window.location.hash === '#whoreadthis-' + container.id.split('-')[1]) {
|
||||
setTimeout(function() {
|
||||
container.scrollIntoView({ behavior: 'smooth' });
|
||||
expandWhoReadThis(container);
|
||||
}, 300);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function toggleWhoReadThis(container) {
|
||||
const itemsWrapper = container.querySelector('.whoreadthis-items-wrapper');
|
||||
const toggleBtn = container.querySelector('.whoreadthis-toggle-btn');
|
||||
|
||||
if (!itemsWrapper || !toggleBtn) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (itemsWrapper.classList.contains('collapsed')) {
|
||||
expandWhoReadThis(container);
|
||||
} else {
|
||||
collapseWhoReadThis(container);
|
||||
}
|
||||
}
|
||||
|
||||
function expandWhoReadThis(container) {
|
||||
const itemsWrapper = container.querySelector('.whoreadthis-items-wrapper');
|
||||
const toggleBtn = container.querySelector('.whoreadthis-toggle-btn');
|
||||
|
||||
if (itemsWrapper && toggleBtn) {
|
||||
itemsWrapper.className = 'whoreadthis-items-wrapper expanded';
|
||||
toggleBtn.className = 'whoreadthis-toggle-btn expanded';
|
||||
toggleBtn.querySelector('.toggle-arrow').textContent = '↑';
|
||||
}
|
||||
}
|
||||
|
||||
function collapseWhoReadThis(container) {
|
||||
const itemsWrapper = container.querySelector('.whoreadthis-items-wrapper');
|
||||
const toggleBtn = container.querySelector('.whoreadthis-toggle-btn');
|
||||
|
||||
if (itemsWrapper && toggleBtn) {
|
||||
itemsWrapper.className = 'whoreadthis-items-wrapper collapsed';
|
||||
toggleBtn.className = 'whoreadthis-toggle-btn collapsed';
|
||||
toggleBtn.querySelector('.toggle-arrow').textContent = '↓';
|
||||
}
|
||||
}
|
||||
|
||||
// 页面加载完成后初始化
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
setTimeout(initWhoReadThis, 100);
|
||||
});
|
||||
} else {
|
||||
setTimeout(initWhoReadThis, 100);
|
||||
}
|
||||
|
||||
// 暴露公共API
|
||||
window.WhoReadThis = {
|
||||
init: initWhoReadThis,
|
||||
expand: function(containerId) {
|
||||
const container = document.getElementById(containerId);
|
||||
if (container) {
|
||||
expandWhoReadThis(container);
|
||||
}
|
||||
},
|
||||
collapse: function(containerId) {
|
||||
const container = document.getElementById(containerId);
|
||||
if (container) {
|
||||
collapseWhoReadThis(container);
|
||||
}
|
||||
},
|
||||
toggle: function(containerId) {
|
||||
const container = document.getElementById(containerId);
|
||||
if (container) {
|
||||
toggleWhoReadThis(container);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
})();
|
||||
Reference in New Issue
Block a user