2026-05-10 13:12:44 +08:00

49 lines
1.5 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 频道标签过滤
document.querySelectorAll('.channel-tag').forEach(tag => {
tag.addEventListener('click', () => {
const channel = tag.dataset.channel;
document.querySelectorAll('.announcement').forEach(ann => {
ann.style.display = channel === 'all' || ann.dataset.channel === channel ? 'block' : 'none';
});
});
});
// 置顶悬浮动画
document.querySelectorAll('.pin-icon').forEach(pin => {
pin.addEventListener('click', () => {
const announcement = pin.closest('.announcement');
announcement.classList.toggle('pinned');
});
});
// ✨ 动态数据加载M24 核心!)
fetch('data.json')
.then(response => response.json())
.then(data => {
const announcements = document.querySelector('.announcements-container');
announcements.innerHTML = '';
data.forEach(item => {
const announcement = document.createElement('div');
announcement.className = nnouncement ;
announcement.dataset.channel = item.channel;
announcement.innerHTML =
<div class="announcement-content">
<h3></h3>
<p></p>
</div>
<i class="pin-icon"></i>
;
announcements.appendChild(announcement);
});
// 重新绑定事件
document.querySelectorAll('.pin-icon').forEach(pin => {
pin.addEventListener('click', () => {
const announcement = pin.closest('.announcement');
announcement.classList.toggle('pinned');
pin.textContent = announcement.classList.contains('pinned') ? '⭐' : '✨';
});
});
});