热门推荐

热门推荐
This commit is contained in:
yangyaoxiang666
2025-09-04 14:07:42 +08:00
parent 3333f6c485
commit 6829a16f96
28 changed files with 3665 additions and 3118 deletions

View File

@@ -1,9 +1,10 @@
/* 背景样式文件 */
/* 网易云音乐特色背景样式 */
body {
background: linear-gradient(135deg, #E8F5E8 0%, #F1F8E9 25%, #E0F2F1 50%, #E8F5E8 75%, #F3E5F5 100%);
background: linear-gradient(135deg, #2b2b2b 0%, #1e1e1e 50%, #2b2b2b 100%);
background-size: 400% 400%;
animation: gradientShift 15s ease infinite;
position: relative;
color: #fff;
}
/* 背景渐变动画 */
@@ -19,7 +20,7 @@ body {
}
}
/* 背景装饰元素 */
/* 网易云红色装饰元素 */
body::before {
content: '';
position: fixed;
@@ -28,14 +29,14 @@ body::before {
width: 100%;
height: 100%;
background-image:
radial-gradient(circle at 20% 80%, rgba(76, 175, 80, 0.1) 0%, transparent 50%),
radial-gradient(circle at 80% 20%, rgba(129, 199, 132, 0.1) 0%, transparent 50%),
radial-gradient(circle at 40% 40%, rgba(165, 214, 167, 0.08) 0%, transparent 50%);
radial-gradient(circle at 20% 80%, rgba(236, 65, 65, 0.15) 0%, transparent 50%),
radial-gradient(circle at 80% 20%, rgba(236, 65, 65, 0.1) 0%, transparent 50%),
radial-gradient(circle at 40% 40%, rgba(236, 65, 65, 0.08) 0%, transparent 50%);
pointer-events: none;
z-index: -2;
}
/* 背景粒子效果 */
/* 音符装饰效果 */
body::after {
content: '';
position: fixed;
@@ -44,11 +45,11 @@ body::after {
width: 100%;
height: 100%;
background-image:
radial-gradient(2px 2px at 20px 30px, rgba(76, 175, 80, 0.3), transparent),
radial-gradient(2px 2px at 40px 70px, rgba(129, 199, 132, 0.2), transparent),
radial-gradient(1px 1px at 90px 40px, rgba(165, 214, 167, 0.3), transparent),
radial-gradient(1px 1px at 130px 80px, rgba(76, 175, 80, 0.2), transparent),
radial-gradient(2px 2px at 160px 30px, rgba(129, 199, 132, 0.3), transparent);
radial-gradient(2px 2px at 20px 30px, rgba(236, 65, 65, 0.4), transparent),
radial-gradient(2px 2px at 40px 70px, rgba(236, 65, 65, 0.3), transparent),
radial-gradient(1px 1px at 90px 40px, rgba(236, 65, 65, 0.4), transparent),
radial-gradient(1px 1px at 130px 80px, rgba(236, 65, 65, 0.3), transparent),
radial-gradient(2px 2px at 160px 30px, rgba(236, 65, 65, 0.4), transparent);
background-repeat: repeat;
background-size: 200px 100px;
animation: particleFloat 20s linear infinite;
@@ -82,17 +83,48 @@ body::after {
}
}
/* 音符装饰 */
.music-note {
position: absolute;
font-size: 24px;
color: rgba(236, 65, 65, 0.3);
animation: floatNote 15s linear infinite;
z-index: -1;
}
@keyframes floatNote {
0% {
transform: translateY(0) rotate(0deg);
opacity: 0;
}
10% {
opacity: 0.8;
}
90% {
opacity: 0.8;
}
100% {
transform: translateY(-100vh) rotate(360deg);
opacity: 0;
}
}
/* 高性能模式 - 减少动画 */
@media (prefers-reduced-motion: reduce) {
body {
animation: none;
background: linear-gradient(135deg, #E8F5E8 0%, #F1F8E9 50%, #E0F2F1 100%);
background: linear-gradient(135deg, #2b2b2b 0%, #1e1e1e 50%, #2b2b2b 100%);
}
body::after {
animation: none;
}
.music-note {
animation: none;
display: none;
}
.title {
animation: none;
}

View File

@@ -1,4 +1,103 @@
/* 基础样式重置 */
/* 背景样式 */
.background-container {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -1;
overflow: hidden;
background-color: #f8f9fa;
}
/* 返回链接样式 */
.back-link {
display: inline-block;
margin-top: 10px;
color: #1DB954;
text-decoration: none;
font-weight: 500;
transition: color 0.3s ease;
}
.back-link:hover {
color: #1ed760;
text-decoration: underline;
}
.modern-gradient {
position: absolute;
top: -50%;
left: -50%;
width: 200%;
height: 200%;
background: linear-gradient(
135deg,
rgba(64, 169, 255, 0.4) 0%,
rgba(120, 192, 255, 0.3) 25%,
rgba(255, 175, 64, 0.2) 50%,
rgba(255, 140, 50, 0.3) 75%,
rgba(255, 122, 69, 0.4) 100%
);
animation: gradient-flow 20s ease-in-out infinite;
border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%;
}
.modern-gradient::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: radial-gradient(
circle at 30% 70%,
rgba(64, 169, 255, 0.5) 0%,
transparent 50%
), radial-gradient(
circle at 70% 30%,
rgba(255, 140, 50, 0.4) 0%,
transparent 50%
);
animation: pulse-effect 15s ease-in-out infinite alternate;
border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%;
}
@keyframes gradient-flow {
0%, 100% {
transform: rotate(0deg) scale(1);
opacity: 0.8;
}
25% {
transform: rotate(90deg) scale(1.1);
opacity: 0.6;
}
50% {
transform: rotate(180deg) scale(0.9);
opacity: 0.9;
}
75% {
transform: rotate(270deg) scale(1.05);
opacity: 0.7;
}
}
@keyframes pulse-effect {
0% {
transform: scale(1) rotate(0deg);
opacity: 0.5;
}
50% {
transform: scale(1.2) rotate(180deg);
opacity: 0.8;
}
100% {
transform: scale(1) rotate(360deg);
opacity: 0.6;
}
}
/* 主样式 */
* {
margin: 0;
padding: 0;
@@ -6,9 +105,10 @@
}
body {
font-family: 'Microsoft YaHei', 'PingFang SC', 'Helvetica Neue', Arial, sans-serif;
line-height: 1.6;
color: #2c3e50;
font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
color: #333;
background-color: #f8f9fa;
position: relative;
min-height: 100vh;
overflow-x: hidden;
}
@@ -16,468 +116,280 @@ body {
.container {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
padding: 24px;
position: relative;
z-index: 1;
}
/* 头部样式 */
.header {
text-align: center;
margin-bottom: 40px;
padding: 40px 20px;
background: rgba(255, 255, 255, 0.9);
border-radius: 20px;
background-color: rgba(255, 255, 255, 0.9);
border-radius: 16px;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
backdrop-filter: blur(10px);
box-shadow: 0 8px 32px rgba(76, 175, 80, 0.1);
}
.title {
font-size: 2.5rem;
font-weight: 700;
background: linear-gradient(135deg, #4CAF50, #81C784);
header {
text-align: center;
margin-bottom: 28px;
padding-bottom: 20px;
border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}
header h1 {
background: linear-gradient(135deg, #4096ff, #ff7a45);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
margin-bottom: 10px;
animation: titleGlow 3s ease-in-out infinite alternate;
color: transparent;
margin-bottom: 14px;
font-size: 2.4rem;
font-weight: 700;
letter-spacing: -0.5px;
}
@keyframes titleGlow {
from { filter: drop-shadow(0 0 5px rgba(76, 175, 80, 0.3)); }
to { filter: drop-shadow(0 0 15px rgba(76, 175, 80, 0.6)); }
}
.subtitle {
font-size: 1.1rem;
.update-time {
color: #666;
opacity: 0.8;
}
/* 榜单信息样式 */
.rank-info {
background: rgba(255, 255, 255, 0.95);
border-radius: 15px;
padding: 25px;
margin-bottom: 30px;
box-shadow: 0 6px 25px rgba(76, 175, 80, 0.1);
border: 1px solid rgba(76, 175, 80, 0.2);
}
.rank-header {
display: flex;
gap: 20px;
align-items: flex-start;
}
.rank-cover {
width: 120px;
height: 120px;
border-radius: 12px;
object-fit: cover;
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
flex-shrink: 0;
}
.rank-details {
flex: 1;
}
.rank-name {
font-size: 1.8rem;
color: #2c3e50;
margin-bottom: 10px;
font-weight: 600;
}
.rank-description {
color: #666;
margin-bottom: 15px;
line-height: 1.6;
}
.rank-meta {
display: flex;
gap: 20px;
flex-wrap: wrap;
}
.update-time, .update-frequency {
background: linear-gradient(135deg, #E8F5E8, #C8E6C9);
padding: 6px 12px;
border-radius: 20px;
font-size: 0.9rem;
color: #2E7D32;
border: 1px solid rgba(76, 175, 80, 0.3);
background-color: rgba(0, 0, 0, 0.03);
padding: 8px 16px;
border-radius: 24px;
display: inline-block;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
/* 控制区域样式 */
.controls {
background: rgba(255, 255, 255, 0.9);
border-radius: 15px;
padding: 25px;
margin-bottom: 30px;
box-shadow: 0 6px 25px rgba(76, 175, 80, 0.1);
.hot-list {
list-style: none;
}
.input-group {
.hot-item {
padding: 20px;
margin-bottom: 16px;
border-radius: 12px;
background-color: white;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
transition: all 0.3s ease;
display: flex;
gap: 15px;
align-items: center;
flex-wrap: wrap;
border: 1px solid rgba(0, 0, 0, 0.03);
}
.input-group label {
font-weight: 600;
color: #2c3e50;
min-width: 80px;
.hot-item:hover {
transform: translateY(-3px);
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
border-color: rgba(64, 169, 255, 0.3);
}
#rankId {
flex: 1;
min-width: 200px;
padding: 12px 16px;
border: 2px solid #E0E0E0;
border-radius: 10px;
font-size: 1rem;
transition: all 0.3s ease;
background: rgba(255, 255, 255, 0.9);
.hot-rank {
font-size: 1.2rem;
font-weight: bold;
color: #4096ff;
margin-right: 18px;
min-width: 38px;
text-align: center;
background-color: rgba(64, 169, 255, 0.1);
border-radius: 50%;
width: 38px;
height: 38px;
display: flex;
align-items: center;
justify-content: center;
}
#rankId:focus {
outline: none;
border-color: #4CAF50;
box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
}
.load-btn {
padding: 12px 24px;
background: linear-gradient(135deg, #4CAF50, #66BB6A);
.hot-rank.top-1 {
background: linear-gradient(135deg, #ff4d4f, #ff7a45);
color: white;
border: none;
border-radius: 10px;
font-size: 1rem;
font-weight: 600;
cursor: pointer;
transition: all 0.3s ease;
box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
}
.load-btn:hover {
transform: translateY(-2px);
box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4);
.hot-rank.top-2 {
background: linear-gradient(135deg, #ff7a45, #ffa940);
color: white;
}
.load-btn:active {
transform: translateY(0);
.hot-rank.top-3 {
background: linear-gradient(135deg, #ffa940, #ffec3d);
color: white;
}
.load-btn:disabled {
opacity: 0.6;
cursor: not-allowed;
transform: none;
.hot-content {
flex: 1;
}
.hot-title {
font-size: 1.15rem;
margin-bottom: 8px;
color: #333;
text-decoration: none;
display: block;
line-height: 1.5;
font-weight: 500;
transition: color 0.2s ease;
}
.hot-title:hover {
color: #4096ff;
text-decoration: none;
}
/* 加载动画 */
.loading {
text-align: center;
padding: 40px;
background: rgba(255, 255, 255, 0.9);
border-radius: 15px;
margin-bottom: 30px;
}
.spinner {
width: 40px;
height: 40px;
border: 4px solid #E0E0E0;
border-top: 4px solid #4CAF50;
border-radius: 50%;
animation: spin 1s linear infinite;
margin: 0 auto 15px;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
/* 错误提示 */
.error {
text-align: center;
padding: 30px;
background: rgba(255, 245, 245, 0.95);
border: 2px solid #ffcdd2;
border-radius: 15px;
margin-bottom: 30px;
}
.error-icon {
font-size: 3rem;
margin-bottom: 15px;
}
.error-message {
color: #c62828;
margin-bottom: 20px;
color: #666;
font-size: 1.1rem;
}
.retry-btn {
padding: 10px 20px;
background: #f44336;
color: white;
border: none;
border-radius: 8px;
cursor: pointer;
transition: all 0.3s ease;
}
.retry-btn:hover {
background: #d32f2f;
transform: translateY(-1px);
}
/* 歌曲列表样式 */
.song-list {
background: rgba(255, 255, 255, 0.95);
border-radius: 15px;
padding: 25px;
margin-bottom: 30px;
box-shadow: 0 6px 25px rgba(76, 175, 80, 0.1);
}
.list-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 25px;
padding-bottom: 15px;
border-bottom: 2px solid #E8F5E8;
}
.list-header h3 {
font-size: 1.5rem;
color: #2c3e50;
font-weight: 600;
}
.song-count {
background: linear-gradient(135deg, #4CAF50, #66BB6A);
color: white;
padding: 6px 12px;
border-radius: 20px;
font-size: 0.9rem;
font-weight: 600;
}
/* 歌曲项样式 */
.song-item {
display: flex;
align-items: center;
padding: 15px;
margin-bottom: 12px;
background: rgba(248, 255, 248, 0.8);
border-radius: 12px;
transition: all 0.3s ease;
border: 1px solid rgba(76, 175, 80, 0.1);
cursor: pointer;
}
.song-item:hover {
transform: translateY(-2px);
box-shadow: 0 6px 20px rgba(76, 175, 80, 0.15);
background: rgba(232, 245, 232, 0.9);
}
.song-rank {
font-size: 1.2rem;
font-weight: 700;
color: #4CAF50;
min-width: 40px;
footer {
text-align: center;
}
.song-rank.top3 {
background: linear-gradient(135deg, #FFD700, #FFA000);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
.song-info {
flex: 1;
margin-left: 15px;
}
.song-title {
font-size: 1.1rem;
font-weight: 600;
color: #2c3e50;
margin-bottom: 5px;
display: -webkit-box;
-webkit-line-clamp: 1;
-webkit-box-orient: vertical;
overflow: hidden;
}
.song-artist {
color: #666;
font-size: 0.9rem;
margin-bottom: 3px;
}
.song-album {
color: #888;
font-size: 0.85rem;
}
.song-meta {
display: flex;
flex-direction: column;
align-items: flex-end;
gap: 5px;
}
.song-duration {
margin-top: 30px;
padding-top: 20px;
border-top: 1px solid rgba(0, 0, 0, 0.06);
color: #666;
font-size: 0.9rem;
}
.song-popularity {
background: linear-gradient(135deg, #4CAF50, #66BB6A);
color: white;
padding: 3px 8px;
border-radius: 12px;
font-size: 0.8rem;
font-weight: 600;
/* 音符装饰样式 */
.music-note {
position: fixed;
font-size: 24px;
color: rgba(236, 65, 65, 0.6);
z-index: 0;
pointer-events: none;
animation: floatNote 20s linear infinite;
text-shadow: 0 0 5px rgba(255, 255, 255, 0.7);
}
/* 返回按钮 */
.back-to-list {
text-align: center;
margin: 30px 0;
}
.back-btn {
display: inline-flex;
align-items: center;
gap: 8px;
padding: 12px 24px;
background: linear-gradient(135deg, #81C784, #A5D6A7);
color: white;
text-decoration: none;
border-radius: 10px;
font-weight: 600;
transition: all 0.3s ease;
box-shadow: 0 4px 15px rgba(129, 199, 132, 0.3);
}
.back-btn:hover {
transform: translateY(-2px);
box-shadow: 0 6px 20px rgba(129, 199, 132, 0.4);
}
/* 页脚 */
.footer {
text-align: center;
padding: 30px 20px;
background: rgba(255, 255, 255, 0.9);
border-radius: 15px;
margin-top: 40px;
color: #666;
backdrop-filter: blur(10px);
@keyframes floatNote {
0% {
transform: translateY(0) rotate(0deg);
opacity: 0.7;
}
50% {
transform: translateY(-100px) rotate(180deg);
opacity: 0.9;
}
100% {
transform: translateY(-200px) rotate(360deg);
opacity: 0;
}
}
/* 响应式设计 */
@media (max-width: 768px) {
@media (max-width: 1024px) and (min-width: 768px) {
.container {
padding: 15px;
max-width: 90%;
padding: 20px;
}
.title {
font-size: 2rem;
header h1 {
font-size: 2.2rem;
}
.rank-header {
flex-direction: column;
text-align: center;
.hot-item {
padding: 18px;
}
.rank-cover {
width: 100px;
height: 100px;
margin: 0 auto 15px;
.hot-title {
font-size: 1.1rem;
}
.input-group {
flex-direction: column;
align-items: stretch;
.music-note {
font-size: 22px;
}
}
@media (max-width: 768px) {
body {
background-color: #f8f9fa;
}
.input-group label {
min-width: auto;
margin-bottom: 5px;
.container {
max-width: 95%;
margin: 12px auto;
padding: 16px;
border-radius: 12px;
}
#rankId {
min-width: auto;
header {
margin-bottom: 20px;
padding-bottom: 16px;
}
header h1 {
font-size: 1.8rem;
margin-bottom: 10px;
}
.song-item {
flex-direction: column;
text-align: center;
gap: 10px;
.update-time {
font-size: 0.85rem;
padding: 6px 12px;
}
.song-info {
margin-left: 0;
}
.song-meta {
align-items: center;
.hot-item {
padding: 16px;
margin-bottom: 12px;
border-radius: 10px;
flex-direction: row;
justify-content: center;
align-items: flex-start;
}
.list-header {
flex-direction: column;
gap: 10px;
text-align: center;
.hot-rank {
font-size: 1.1rem;
margin-right: 14px;
min-width: 32px;
width: 32px;
height: 32px;
margin-top: 2px;
}
.hot-title {
font-size: 1rem;
line-height: 1.5;
margin-bottom: 6px;
}
footer {
margin-top: 24px;
padding-top: 16px;
font-size: 0.85rem;
}
}
@media (max-width: 480px) {
.title {
font-size: 1.8rem;
.container {
margin: 8px auto;
padding: 14px;
}
.header {
padding: 30px 15px;
header h1 {
font-size: 1.6rem;
}
.rank-info, .controls, .song-list {
padding: 20px;
.hot-item {
padding: 14px;
margin-bottom: 10px;
}
.song-item {
padding: 12px;
.hot-rank {
font-size: 1rem;
margin-right: 12px;
min-width: 30px;
width: 30px;
height: 30px;
}
.hot-title {
font-size: 0.95rem;
}
}
/* 平板端适配 */
@media (min-width: 769px) and (max-width: 1024px) {
.container {
padding: 25px;
/* 减少动画以节省电池 */
@media (prefers-reduced-motion: reduce) {
.modern-gradient,
.modern-gradient::before {
animation: none;
}
.song-item {
padding: 18px;
}
.rank-cover {
width: 110px;
height: 110px;
.modern-gradient {
background: linear-gradient(
135deg,
rgba(64, 169, 255, 0.3) 0%,
rgba(255, 175, 64, 0.2) 50%,
rgba(255, 122, 69, 0.25) 100%
);
}
}

View File

@@ -3,15 +3,20 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>网易云榜单详情</title>
<title>网易云音乐榜单详情</title>
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/loading.css">
<link rel="stylesheet" href="css/background.css">
</head>
<body>
<!-- 音符装饰 -->
<div id="musicNotes"></div>
<div class="container">
<header class="header">
<h1 class="title">🎵 网易云榜单详情</h1>
<p class="subtitle">发现音乐的魅力</p>
<a href="../网易云榜单列表/index.html" class="back-link" id="backLink">← 返回榜单列表</a>
</header>
<div class="rank-info" id="rankInfo" style="display: none;">
@@ -56,7 +61,7 @@
</div>
<div class="back-to-list">
<a href="../网易云榜单列表/index.html" class="back-btn">← 返回榜单列表</a>
<a href="../网易云榜单列表/index.html" class="back-btn" id="backBtnBottom">← 返回榜单列表</a>
</div>
</div>
@@ -64,6 +69,42 @@
<p>&copy; 2025 网易云榜单详情 - 数据来源于官方API</p>
</footer>
<script>
// 创建音符装饰
function createMusicNotes() {
const musicNotes = document.getElementById('musicNotes');
const noteSymbols = ['♪', '♫', '♬', '♩', '♭', '♮', '♯'];
const containerWidth = window.innerWidth;
const containerHeight = window.innerHeight;
// 创建20个音符
for (let i = 0; i < 20; i++) {
const note = document.createElement('div');
note.className = 'music-note';
note.textContent = noteSymbols[Math.floor(Math.random() * noteSymbols.length)];
// 随机位置
const left = Math.random() * containerWidth;
const top = Math.random() * containerHeight;
// 随机动画延迟
const delay = Math.random() * 15;
const duration = 10 + Math.random() * 20;
note.style.left = `${left}px`;
note.style.top = `${top}px`;
note.style.animationDelay = `${delay}s`;
note.style.animationDuration = `${duration}s`;
musicNotes.appendChild(note);
}
}
// 页面加载完成后创建音符
document.addEventListener('DOMContentLoaded', () => {
createMusicNotes();
});
</script>
<script src="js/script.js"></script>
</body>
</html>

View File

@@ -31,11 +31,28 @@ class NeteaseMusicRankDetail {
console.error('加载API接口失败:', error);
// 使用默认接口
this.apiUrls = [
'https://60s-cf.viki.moe',
'https://60s.viki.moe',
'https://60s-cf.viki.moe',
'https://60s.b23.run',
'https://60s.114128.xyz',
'https://60s-cf.114128.xyz'
'https://60s-cf.114128.xyz',
'https://60s.api.shumengya.top',
'https://api.03c3.cn/api/zb',
'https://api.vvhan.com/api/60s'
];
}
// 确保至少有一个API接口
if (!this.apiUrls || this.apiUrls.length === 0) {
this.apiUrls = [
'https://60s.viki.moe',
'https://60s-cf.viki.moe',
'https://60s.b23.run',
'https://60s.114128.xyz',
'https://60s-cf.114128.xyz',
'https://60s.api.shumengya.top',
'https://api.03c3.cn/api/zb',
'https://api.vvhan.com/api/60s'
];
}
}
@@ -45,6 +62,8 @@ class NeteaseMusicRankDetail {
const loadBtn = document.getElementById('loadBtn');
const rankIdInput = document.getElementById('rankId');
const retryBtn = document.getElementById('retryBtn');
const backLink = document.getElementById('backLink');
const backBtnBottom = document.getElementById('backBtnBottom');
loadBtn.addEventListener('click', () => this.loadRankDetail());
retryBtn.addEventListener('click', () => this.loadRankDetail());
@@ -61,6 +80,19 @@ class NeteaseMusicRankDetail {
const value = e.target.value.trim();
loadBtn.disabled = !value || !/^\d+$/.test(value);
});
// 处理返回链接
if (backLink) {
backLink.addEventListener('click', (e) => {
console.log('返回榜单列表');
});
}
if (backBtnBottom) {
backBtnBottom.addEventListener('click', (e) => {
console.log('返回榜单列表');
});
}
}
// 检查URL参数
@@ -102,12 +134,17 @@ class NeteaseMusicRankDetail {
try {
const data = await this.fetchRankDetail(rankId);
this.rankData = data;
this.displayRankDetail(data);
this.hideLoading();
// 更新URL
const newUrl = new URL(window.location);
newUrl.searchParams.set('id', rankId);
if (data.playlist && data.playlist.name) {
newUrl.searchParams.set('name', encodeURIComponent(data.playlist.name));
document.title = `${data.playlist.name} - 网易云榜单详情`;
}
window.history.replaceState({}, '', newUrl);
} catch (error) {
@@ -120,22 +157,43 @@ class NeteaseMusicRankDetail {
// 获取榜单详情数据
async fetchRankDetail(rankId) {
let lastError = null;
let attemptedApis = 0;
for (let i = 0; i < this.apiUrls.length; i++) {
// 尝试所有API接口
while (attemptedApis < this.apiUrls.length) {
try {
const apiUrl = this.apiUrls[this.currentApiIndex];
const url = `${apiUrl}/v2/ncm-rank/${rankId}`;
let url = `${apiUrl}/v2/ncm-rank/${rankId}`;
console.log(`尝试API ${this.currentApiIndex + 1}:`, url);
// 处理本地JSON文件
if (apiUrl.includes('返回接口.json')) {
url = apiUrl;
console.log('使用本地测试数据:', url);
}
// 针对不同API接口格式进行适配
else if (apiUrl.includes('03c3.cn') || apiUrl.includes('vvhan.com')) {
// 这些API可能有不同的路径格式需要特殊处理
if (apiUrl.includes('03c3.cn')) {
url = `${apiUrl}/ncm/playlist?id=${rankId}`;
} else if (apiUrl.includes('vvhan.com')) {
url = `${apiUrl}/music/netease/playlist?id=${rankId}`;
}
}
console.log(`尝试API ${this.currentApiIndex + 1}/${this.apiUrls.length}:`, url);
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), 10000);
const timeoutId = setTimeout(() => controller.abort(), 8000); // 缩短超时时间
const response = await fetch(url, {
signal: controller.signal,
headers: {
'Accept': 'application/json',
}
},
// 添加缓存控制
cache: 'no-cache',
// 添加模式
mode: apiUrl.includes('返回接口.json') ? 'same-origin' : 'cors'
});
clearTimeout(timeoutId);
@@ -146,8 +204,25 @@ class NeteaseMusicRankDetail {
const data = await response.json();
if (data.code !== 200) {
throw new Error(data.message || '获取数据失败');
// 如果是本地测试数据,直接使用
if (apiUrl.includes('返回接口.json')) {
// 查找对应ID的榜单
if (data.data && Array.isArray(data.data)) {
const rank = data.data.find(item => item.id == rankId);
if (rank) {
// 构造一个符合详情页面期望的数据结构
return {
code: 200,
playlist: rank,
data: [] // 模拟空歌曲列表
};
}
}
}
// 不同API可能有不同的成功状态码
if (data.code !== undefined && data.code !== 200 && data.code !== 0) {
throw new Error(data.message || data.msg || '获取数据失败');
}
console.log('API调用成功:', data);
@@ -157,23 +232,68 @@ class NeteaseMusicRankDetail {
console.warn(`API ${this.currentApiIndex + 1} 失败:`, error.message);
lastError = error;
this.currentApiIndex = (this.currentApiIndex + 1) % this.apiUrls.length;
attemptedApis++;
if (error.name === 'AbortError') {
lastError = new Error('请求超时,请重试');
}
// 添加短暂延迟避免过快请求下一个API
await new Promise(resolve => setTimeout(resolve, 300));
}
}
throw lastError || new Error('所有API接口都无法访问');
throw lastError || new Error('所有API接口都无法访问,请稍后再试');
}
// 显示榜单详情
displayRankDetail(data) {
this.rankData = data;
const songs = data.data || [];
// 适配不同API返回的数据格式
let songs = [];
let rankInfo = null;
// 标准格式data.data 是数组
if (data.data && Array.isArray(data.data)) {
songs = data.data;
rankInfo = data.playlist || {};
}
// 03c3.cn API格式data.result 或 data.playlist
else if (data.result) {
if (data.result.tracks && Array.isArray(data.result.tracks)) {
songs = data.result.tracks;
rankInfo = data.result;
} else if (Array.isArray(data.result)) {
songs = data.result;
}
}
// vvhan.com API格式data.playlist 和 data.playlist.tracks
else if (data.playlist && data.playlist.tracks) {
songs = data.playlist.tracks;
rankInfo = data.playlist;
}
// 其他可能的格式
else {
// 尝试查找数据中的任何数组
for (const key in data) {
if (Array.isArray(data[key]) && data[key].length > 0) {
songs = data[key];
break;
} else if (data[key] && data[key].tracks && Array.isArray(data[key].tracks)) {
songs = data[key].tracks;
rankInfo = data[key];
break;
}
}
}
if (songs.length === 0) {
throw new Error('未找到歌曲数据或数据格式不兼容');
}
// 显示榜单信息(如果有的话)
this.displayRankInfo(songs[0]);
this.displayRankInfo(songs[0], rankInfo);
// 显示歌曲列表
this.displaySongList(songs);
@@ -184,25 +304,63 @@ class NeteaseMusicRankDetail {
}
// 显示榜单信息
displayRankInfo(firstSong) {
const rankInfo = document.getElementById('rankInfo');
displayRankInfo(firstSong, rankInfoData) {
const rankInfoElement = document.getElementById('rankInfo');
if (firstSong && firstSong.rank_name) {
document.getElementById('rankName').textContent = firstSong.rank_name;
document.getElementById('rankDescription').textContent = `${firstSong.rank_name} - 网易云音乐官方榜单`;
// 获取URL参数中的榜单名称
const urlParams = new URLSearchParams(window.location.search);
const rankNameFromUrl = urlParams.get('name');
// 尝试从多个来源获取榜单名称
let rankName = rankNameFromUrl || '';
if (!rankName) {
if (rankInfoData && rankInfoData.name) {
rankName = rankInfoData.name;
} else if (firstSong) {
rankName = firstSong.rank_name || firstSong.rankName || firstSong.playlist_name || '';
}
}
if (rankName) {
document.getElementById('rankName').textContent = rankName;
document.getElementById('rankDescription').textContent = `${rankName} - 网易云音乐官方榜单`;
document.title = `${rankName} - 网易云音乐榜单详情`;
// 如果有专辑封面,使用第一首歌的专辑封面作为榜单封面
if (firstSong.album && firstSong.album.cover) {
document.getElementById('rankCover').src = firstSong.album.cover;
document.getElementById('rankCover').alt = firstSong.rank_name;
// 尝试获取榜单封面
let coverUrl = '';
if (rankInfoData && rankInfoData.coverImgUrl) {
coverUrl = rankInfoData.coverImgUrl;
} else if (rankInfoData && rankInfoData.picUrl) {
coverUrl = rankInfoData.picUrl;
} else if (firstSong && firstSong.album && firstSong.album.cover) {
coverUrl = firstSong.album.cover;
} else if (firstSong && firstSong.album && firstSong.album.picUrl) {
coverUrl = firstSong.album.picUrl;
} else if (firstSong && firstSong.al && firstSong.al.picUrl) {
coverUrl = firstSong.al.picUrl;
}
document.getElementById('updateTime').textContent = `更新时间: ${this.formatDate(new Date())}`;
document.getElementById('updateFrequency').textContent = '实时更新';
if (coverUrl) {
document.getElementById('rankCover').src = coverUrl;
document.getElementById('rankCover').alt = rankName;
}
rankInfo.style.display = 'block';
// 尝试获取更新时间
let updateTime = '';
if (rankInfoData && rankInfoData.updateTime) {
updateTime = this.formatDate(new Date(rankInfoData.updateTime));
} else if (rankInfoData && rankInfoData.updateFrequency) {
updateTime = rankInfoData.updateFrequency;
} else {
updateTime = this.formatDate(new Date());
}
document.getElementById('updateTime').textContent = `更新时间: ${updateTime}`;
document.getElementById('updateFrequency').textContent = rankInfoData?.updateFrequency || '定期更新';
rankInfoElement.style.display = 'block';
} else {
rankInfo.style.display = 'none';
rankInfoElement.style.display = 'none';
}
}

View File

@@ -1,3 +1,4 @@
[
"https://60s.api.shumengya.top"
"https://60s.api.shumengya.top",
"../返回接口.json"
]