新增嵌入式代码块;优化通知书推送时机
This commit is contained in:
@@ -0,0 +1,277 @@
|
||||
<div id="anian-update-wrapper-2026" class="anian-feed-root-container">
|
||||
<div class="anian-feed-grid">
|
||||
<div class="anian-feed-card" data-rss-url="https://git.anian.cc/anian/halo-plugin-photos/releases.rss">
|
||||
<h3 class="anian-feed-caption">图库插件更新</h3>
|
||||
<div class="anian-feed-list-box">
|
||||
<div class="anian-loading">加载中...</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="anian-feed-card" data-rss-url="https://git.anian.cc/anian/halo-plugin-friends/releases.rss">
|
||||
<h3 class="anian-feed-caption">朋友圈插件更新</h3>
|
||||
<div class="anian-feed-list-box">
|
||||
<div class="anian-loading">加载中...</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="anian-feed-card" data-rss-url="https://git.anian.cc/anian/halo-theme-pix/releases.rss">
|
||||
<h3 class="anian-feed-caption">主题更新</h3>
|
||||
<div class="anian-feed-list-box">
|
||||
<div class="anian-loading">加载中...</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
/* 样式作用域锁定 */
|
||||
.anian-feed-root-container {
|
||||
padding: 20px;
|
||||
background-color: #f9fdf8;
|
||||
border-radius: 16px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.anian-feed-grid {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 24px;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.anian-feed-card {
|
||||
flex: 1;
|
||||
min-width: 320px;
|
||||
/* 优化最小宽度 */
|
||||
background: #ffffff;
|
||||
border: 1px solid #e1f3d8;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 4px 12px rgba(103, 194, 58, 0.06);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
/* 防止内容溢出圆角 */
|
||||
transition: transform 0.3s ease, box-shadow 0.3s ease;
|
||||
}
|
||||
|
||||
|
||||
.anian-feed-caption {
|
||||
margin: 0;
|
||||
padding: 12px 20px;
|
||||
background-color: #f0f9eb;
|
||||
color: #52c41a;
|
||||
/* 更清新的绿色 */
|
||||
font-size: 17px;
|
||||
font-weight: 600;
|
||||
border-bottom: 1px solid #e1f3d8;
|
||||
letter-spacing: 0.2px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.anian-feed-list-box {
|
||||
max-height: 380px;
|
||||
/* 优化高度 */
|
||||
overflow-y: auto;
|
||||
padding: 0;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
/* 自定义滚动条 - 更精致 */
|
||||
.anian-feed-list-box::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
margin-right: 2px;
|
||||
}
|
||||
|
||||
.anian-feed-list-box::-webkit-scrollbar-track {
|
||||
background: #f8fff5;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.anian-feed-list-box::-webkit-scrollbar-thumb {
|
||||
background: #b7eb8f;
|
||||
border-radius: 10px;
|
||||
transition: background 0.2s;
|
||||
}
|
||||
|
||||
.anian-feed-list-box::-webkit-scrollbar-thumb:hover {
|
||||
background: #95de64;
|
||||
}
|
||||
|
||||
/* 加载状态美化 */
|
||||
.anian-loading {
|
||||
padding: 20px;
|
||||
color: #8c8c8c;
|
||||
font-size: 14px;
|
||||
text-align: center;
|
||||
animation: fade 1.2s infinite alternate;
|
||||
}
|
||||
|
||||
@keyframes fade {
|
||||
from {
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
to {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* 列表项核心样式 - 无下划线 + 精致hover */
|
||||
.anian-feed-item {
|
||||
display: block;
|
||||
padding: 16px 20px;
|
||||
text-decoration: none !important;
|
||||
/* 强制移除下划线 */
|
||||
border-bottom: 1px dashed #f0f9eb;
|
||||
transition: all 0.3s ease;
|
||||
/* 统一过渡效果 */
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* 移除所有状态下的下划线 */
|
||||
.anian-feed-item:link,
|
||||
.anian-feed-item:visited,
|
||||
.anian-feed-item:active {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
/* 增强hover效果 */
|
||||
.anian-feed-item:hover {
|
||||
background-color: #f5fff0;
|
||||
border-color: #d1f0b5;
|
||||
}
|
||||
|
||||
/* 右侧小装饰 - 提升精致感 */
|
||||
.anian-feed-item::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 0;
|
||||
width: 3px;
|
||||
height: 100%;
|
||||
background: #67c23a;
|
||||
opacity: 0;
|
||||
transition: opacity 0.3s ease;
|
||||
}
|
||||
|
||||
.anian-feed-item:hover::after {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.anian-feed-item-time {
|
||||
display: block;
|
||||
font-size: 13px;
|
||||
color: #8c8c8c;
|
||||
margin-bottom: 6px;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.anian-feed-item-title {
|
||||
display: block;
|
||||
font-size: 15px;
|
||||
color: #303133;
|
||||
line-height: 1.5;
|
||||
font-weight: 500;
|
||||
transition: color 0.2s ease;
|
||||
}
|
||||
|
||||
.anian-feed-item:hover .anian-feed-item-title {
|
||||
color: #52c41a;
|
||||
/* hover时标题变色 */
|
||||
}
|
||||
|
||||
/* 空数据/错误状态样式统一 */
|
||||
.anian-feed-list-box>div {
|
||||
padding: 20px;
|
||||
font-size: 14px;
|
||||
text-align: center;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
/* 响应式优化 */
|
||||
@media (max-width: 768px) {
|
||||
.anian-feed-root-container {
|
||||
padding: 15px;
|
||||
}
|
||||
|
||||
.anian-feed-card {
|
||||
min-width: 100%;
|
||||
}
|
||||
|
||||
.anian-feed-caption {
|
||||
padding: 14px 16px;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.anian-feed-item {
|
||||
padding: 14px 16px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
(function () {
|
||||
async function fetchRssContent(cardElement) {
|
||||
const url = cardElement.getAttribute('data-rss-url');
|
||||
const listBox = cardElement.querySelector('.anian-feed-list-box');
|
||||
|
||||
// 1. 如果你已经开启了服务器跨域,可以尝试直接请求 url
|
||||
// 2. 如果依然报错,请恢复使用代理:const targetUrl = `https://api.allorigins.win/raw?url=${encodeURIComponent(url)}`;
|
||||
const targetUrl = url;
|
||||
|
||||
try {
|
||||
const response = await fetch(targetUrl);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP 错误! 状态码: ${response.status}`);
|
||||
}
|
||||
|
||||
const xmlText = await response.text();
|
||||
|
||||
const parser = new DOMParser();
|
||||
const xmlDoc = parser.parseFromString(xmlText, "text/xml");
|
||||
|
||||
// 检查是否有解析错误
|
||||
const parseError = xmlDoc.getElementsByTagName("parsererror");
|
||||
if (parseError.length > 0) {
|
||||
console.error("[RSS Debug] XML 解析失败", parseError[0].textContent);
|
||||
listBox.innerHTML = '<div style="color:#f56c6c;">XML 解析错误</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
const items = xmlDoc.querySelectorAll("item");
|
||||
|
||||
let htmlContent = "";
|
||||
|
||||
items.forEach((item, index) => {
|
||||
const title = item.querySelector("title")?.textContent || "无标题";
|
||||
const link = item.querySelector("link")?.textContent || "#";
|
||||
const pubDateStr = item.querySelector("pubDate")?.textContent || "";
|
||||
|
||||
// 简单处理日期
|
||||
const dateObj = new Date(pubDateStr);
|
||||
const formattedTime = isNaN(dateObj) ? pubDateStr.split(' ').slice(0, 4).join(' ') :
|
||||
`${dateObj.getFullYear()}-${(dateObj.getMonth() + 1).toString().padStart(2, '0')}-${dateObj.getDate().toString().padStart(2, '0')}`;
|
||||
|
||||
htmlContent += `
|
||||
<a href="${link}" class="anian-feed-item" target="_blank" rel="noopener">
|
||||
<span class="anian-feed-item-time">${formattedTime}</span>
|
||||
<span class="anian-feed-item-title">${title}</span>
|
||||
</a>
|
||||
`;
|
||||
});
|
||||
|
||||
listBox.innerHTML = htmlContent || '<div style="color:#999;">暂无更新内容</div>';
|
||||
} catch (error) {
|
||||
console.error('[RSS Debug] 请求发生异常:', error);
|
||||
listBox.innerHTML = `<div style="color:#f56c6c;font-size:14px;">请求失败: ${error.message}</div>`;
|
||||
}
|
||||
}
|
||||
|
||||
document.querySelectorAll('.anian-feed-card').forEach(card => {
|
||||
fetchRssContent(card);
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
Reference in New Issue
Block a user