feat: 实现网易云音乐同步服务核心功能与UI改进
添加完整的网易云音乐同步到Navidrome的功能实现,包括: 1. 新增Docker支持与相关配置文件 2. 实现歌单同步逻辑与Navidrome API集成 3. 改进前端UI界面与交互体验 4. 添加状态监控与错误处理机制 5. 实现定时同步功能与进度显示
This commit is contained in:
@@ -1,229 +1,223 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<html lang="zh-CN" class="dark">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>网易云音乐同步到 Navidrome</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
||||
<meta name="theme-color" content="#000000">
|
||||
<title>网易云音乐同步</title>
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
||||
<script>
|
||||
tailwind.config = {
|
||||
darkMode: 'class',
|
||||
theme: {
|
||||
extend: {
|
||||
colors: {
|
||||
netease: '#E60026',
|
||||
glass: {
|
||||
100: 'rgba(255, 255, 255, 0.1)',
|
||||
200: 'rgba(255, 255, 255, 0.2)',
|
||||
300: 'rgba(255, 255, 255, 0.3)',
|
||||
}
|
||||
},
|
||||
animation: {
|
||||
'pulse-slow': 'pulse 3s cubic-bezier(0.4, 0, 0.6, 1) infinite',
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
|
||||
background: #121212;
|
||||
background-image:
|
||||
radial-gradient(at 0% 0%, hsla(253,16%,7%,1) 0, transparent 50%),
|
||||
radial-gradient(at 50% 0%, hsla(225,39%,30%,1) 0, transparent 50%),
|
||||
radial-gradient(at 100% 0%, hsla(339,49%,30%,1) 0, transparent 50%);
|
||||
min-height: 100vh;
|
||||
padding: 20px;
|
||||
}
|
||||
.container {
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
|
||||
.glass-panel {
|
||||
background: rgba(30, 30, 30, 0.6);
|
||||
backdrop-filter: blur(12px);
|
||||
-webkit-backdrop-filter: blur(12px);
|
||||
border: 1px solid rgba(255, 255, 255, 0.08);
|
||||
box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
h1 {
|
||||
|
||||
.glass-input {
|
||||
background: rgba(0, 0, 0, 0.3);
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
color: white;
|
||||
text-align: center;
|
||||
margin-bottom: 30px;
|
||||
font-size: 2.5em;
|
||||
text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
.card {
|
||||
background: white;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 10px 30px rgba(0,0,0,0.2);
|
||||
padding: 25px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.add-playlist {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.add-playlist input {
|
||||
flex: 1;
|
||||
padding: 12px 15px;
|
||||
border: 2px solid #e0e0e0;
|
||||
border-radius: 8px;
|
||||
font-size: 14px;
|
||||
transition: border-color 0.3s;
|
||||
}
|
||||
.add-playlist input:focus {
|
||||
|
||||
.glass-input:focus {
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
border-color: rgba(230, 0, 38, 0.5);
|
||||
outline: none;
|
||||
border-color: #667eea;
|
||||
box-shadow: 0 0 0 2px rgba(230, 0, 38, 0.2);
|
||||
}
|
||||
.add-playlist button {
|
||||
padding: 12px 25px;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
transition: transform 0.2s, box-shadow 0.2s;
|
||||
|
||||
.custom-scrollbar::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
.add-playlist button:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
|
||||
.custom-scrollbar::-webkit-scrollbar-track {
|
||||
background: rgba(255, 255, 255, 0.02);
|
||||
}
|
||||
.add-playlist button:active {
|
||||
transform: translateY(0);
|
||||
.custom-scrollbar::-webkit-scrollbar-thumb {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
border-radius: 3px;
|
||||
}
|
||||
.playlist-list {
|
||||
display: grid;
|
||||
gap: 15px;
|
||||
}
|
||||
.playlist-item {
|
||||
background: #f8f9fa;
|
||||
border-radius: 8px;
|
||||
padding: 20px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
.playlist-item:hover {
|
||||
background: #e9ecef;
|
||||
transform: translateX(5px);
|
||||
}
|
||||
.playlist-info {
|
||||
flex: 1;
|
||||
}
|
||||
.playlist-name {
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.playlist-meta {
|
||||
display: flex;
|
||||
gap: 20px;
|
||||
font-size: 13px;
|
||||
color: #666;
|
||||
}
|
||||
.playlist-meta span {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
}
|
||||
.status-badge {
|
||||
padding: 4px 12px;
|
||||
border-radius: 20px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
.status-idle {
|
||||
background: #e0e0e0;
|
||||
color: #666;
|
||||
}
|
||||
.status-syncing {
|
||||
background: #fff3cd;
|
||||
color: #856404;
|
||||
}
|
||||
.status-success {
|
||||
background: #d4edda;
|
||||
color: #155724;
|
||||
}
|
||||
.status-error {
|
||||
background: #f8d7da;
|
||||
color: #721c24;
|
||||
}
|
||||
.playlist-actions {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
.playlist-actions button {
|
||||
padding: 8px 16px;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
.btn-sync {
|
||||
background: #667eea;
|
||||
color: white;
|
||||
}
|
||||
.btn-sync:hover {
|
||||
background: #5568d3;
|
||||
}
|
||||
.btn-sync:disabled {
|
||||
background: #ccc;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
.btn-delete {
|
||||
background: #dc3545;
|
||||
color: white;
|
||||
}
|
||||
.btn-delete:hover {
|
||||
background: #c82333;
|
||||
}
|
||||
.empty-state {
|
||||
text-align: center;
|
||||
padding: 60px 20px;
|
||||
color: #999;
|
||||
}
|
||||
.empty-state svg {
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
margin-bottom: 20px;
|
||||
opacity: 0.5;
|
||||
}
|
||||
.loading {
|
||||
text-align: center;
|
||||
padding: 40px;
|
||||
color: #666;
|
||||
}
|
||||
.error-message {
|
||||
background: #f8d7da;
|
||||
color: #721c24;
|
||||
padding: 15px;
|
||||
border-radius: 8px;
|
||||
margin-bottom: 20px;
|
||||
display: none;
|
||||
}
|
||||
.success-message {
|
||||
background: #d4edda;
|
||||
color: #155724;
|
||||
padding: 15px;
|
||||
border-radius: 8px;
|
||||
margin-bottom: 20px;
|
||||
display: none;
|
||||
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
.spinner {
|
||||
display: inline-block;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
border: 3px solid rgba(255,255,255,0.3);
|
||||
border-radius: 50%;
|
||||
border-top-color: white;
|
||||
animation: spin 0.8s linear infinite;
|
||||
animation: spin 1s linear infinite;
|
||||
}
|
||||
|
||||
.line-clamp-2 {
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>🎵 网易云音乐同步到 Navidrome</h1>
|
||||
|
||||
<div class="error-message" id="errorMessage"></div>
|
||||
<div class="success-message" id="successMessage"></div>
|
||||
|
||||
<div class="card">
|
||||
<div class="add-playlist">
|
||||
<input type="text" id="playlistInput" placeholder="输入网易云音乐歌单ID或分享链接...">
|
||||
<button onclick="addPlaylist()">添加歌单</button>
|
||||
<body class="text-white custom-scrollbar selection:bg-netease selection:text-white">
|
||||
<div class="container mx-auto px-4 py-8 max-w-7xl">
|
||||
<!-- Header -->
|
||||
<header class="flex flex-col md:flex-row items-center justify-between mb-10 gap-6">
|
||||
<div class="flex items-center gap-4">
|
||||
<div class="w-12 h-12 rounded-full bg-gradient-to-br from-netease to-red-700 flex items-center justify-center shadow-lg shadow-netease/30">
|
||||
<i class="fa-solid fa-cloud text-xl"></i>
|
||||
</div>
|
||||
<div>
|
||||
<h1 class="text-2xl font-bold tracking-tight">网易云音乐同步</h1>
|
||||
<p class="text-gray-400 text-sm">Sync Netease Cloud Music to Navidrome</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="playlistList" class="playlist-list">
|
||||
<div class="loading">加载中...</div>
|
||||
<div class="glass-panel rounded-full p-1.5 flex w-full md:w-auto max-w-md">
|
||||
<input
|
||||
type="text"
|
||||
id="playlistInput"
|
||||
placeholder="输入歌单 ID 或链接..."
|
||||
class="bg-transparent border-none text-white px-4 py-2 w-full focus:outline-none placeholder-gray-500 text-sm"
|
||||
>
|
||||
<button
|
||||
onclick="addPlaylist()"
|
||||
class="bg-netease hover:bg-red-700 text-white px-6 py-2 rounded-full font-medium text-sm transition-all shadow-lg shadow-netease/20 flex items-center gap-2 whitespace-nowrap"
|
||||
>
|
||||
<i class="fa-solid fa-plus"></i>
|
||||
<span>添加</span>
|
||||
</button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- Notifications -->
|
||||
<div id="toast-container" class="fixed top-6 right-6 z-50 flex flex-col gap-3 pointer-events-none"></div>
|
||||
|
||||
<!-- Content -->
|
||||
<main>
|
||||
<!-- Stats Overview -->
|
||||
<div id="stats-container" class="grid grid-cols-2 md:grid-cols-4 gap-4 mb-8 hidden">
|
||||
<div class="glass-panel rounded-2xl p-4 flex flex-col items-center justify-center text-center">
|
||||
<span class="text-3xl font-bold text-white mb-1" id="stat-total">0</span>
|
||||
<span class="text-xs text-gray-400 uppercase tracking-wider">总歌单</span>
|
||||
</div>
|
||||
<div class="glass-panel rounded-2xl p-4 flex flex-col items-center justify-center text-center">
|
||||
<span class="text-3xl font-bold text-green-400 mb-1" id="stat-synced">0</span>
|
||||
<span class="text-xs text-gray-400 uppercase tracking-wider">已同步</span>
|
||||
</div>
|
||||
<div class="glass-panel rounded-2xl p-4 flex flex-col items-center justify-center text-center">
|
||||
<span class="text-3xl font-bold text-blue-400 mb-1" id="stat-songs">0</span>
|
||||
<span class="text-xs text-gray-400 uppercase tracking-wider">总歌曲</span>
|
||||
</div>
|
||||
<div class="glass-panel rounded-2xl p-4 flex flex-col items-center justify-center text-center">
|
||||
<span class="text-3xl font-bold text-yellow-400 mb-1" id="stat-syncing">0</span>
|
||||
<span class="text-xs text-gray-400 uppercase tracking-wider">同步中</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Empty State -->
|
||||
<div id="empty-state" class="hidden text-center py-20">
|
||||
<div class="w-24 h-24 bg-white/5 rounded-full flex items-center justify-center mx-auto mb-6">
|
||||
<i class="fa-solid fa-music text-4xl text-white/20"></i>
|
||||
</div>
|
||||
<h3 class="text-xl font-medium text-white mb-2">还没有歌单</h3>
|
||||
<p class="text-gray-500 max-w-sm mx-auto">在上方输入框粘贴网易云音乐歌单链接或 ID,开始构建你的私人音乐库。</p>
|
||||
</div>
|
||||
|
||||
<!-- Grid Layout -->
|
||||
<div id="playlist-grid" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6">
|
||||
<!-- Cards will be injected here -->
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<!-- Templates -->
|
||||
<template id="playlist-card-template">
|
||||
<div class="glass-panel rounded-2xl overflow-hidden group hover:bg-white/5 transition-all duration-300 relative">
|
||||
<!-- Cover Image & Gradient Overlay -->
|
||||
<div class="aspect-square relative overflow-hidden bg-gray-800">
|
||||
<img src="" alt="Cover" class="w-full h-full object-cover transition-transform duration-700 group-hover:scale-110 playlist-cover">
|
||||
<div class="absolute inset-0 bg-gradient-to-t from-black/90 via-black/40 to-transparent opacity-80 group-hover:opacity-60 transition-opacity"></div>
|
||||
|
||||
<!-- Status Badge -->
|
||||
<div class="absolute top-3 right-3">
|
||||
<span class="playlist-status px-2.5 py-1 rounded-full text-xs font-medium backdrop-blur-md bg-black/40 border border-white/10">
|
||||
待同步
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<!-- Action Buttons (Hover) -->
|
||||
<div class="absolute inset-0 flex items-center justify-center gap-3 opacity-0 group-hover:opacity-100 transition-opacity duration-300 bg-black/40 backdrop-blur-sm">
|
||||
<button class="action-sync w-12 h-12 rounded-full bg-white text-black hover:scale-110 transition-transform flex items-center justify-center shadow-xl">
|
||||
<i class="fa-solid fa-rotate"></i>
|
||||
</button>
|
||||
<button class="action-delete w-12 h-12 rounded-full bg-red-500/80 text-white hover:bg-red-500 hover:scale-110 transition-all flex items-center justify-center shadow-xl backdrop-blur-md">
|
||||
<i class="fa-solid fa-trash"></i>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Progress Bar Overlay (When Syncing) -->
|
||||
<div class="sync-overlay absolute inset-x-0 bottom-0 bg-black/80 backdrop-blur-md p-4 transform translate-y-full transition-transform duration-300">
|
||||
<div class="flex justify-between text-xs text-gray-300 mb-1.5">
|
||||
<span class="sync-message truncate pr-2">准备中...</span>
|
||||
<span class="sync-percent font-mono">0%</span>
|
||||
</div>
|
||||
<div class="w-full bg-gray-700 rounded-full h-1.5 overflow-hidden">
|
||||
<div class="sync-progress-bar bg-netease h-1.5 rounded-full transition-all duration-300" style="width: 0%"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Info Section -->
|
||||
<div class="p-5">
|
||||
<h3 class="playlist-name font-bold text-lg mb-1 truncate group-hover:text-netease transition-colors">歌单名称</h3>
|
||||
<div class="flex items-center gap-2 text-xs text-gray-400 mb-4">
|
||||
<span class="flex items-center gap-1 bg-white/5 px-2 py-0.5 rounded">
|
||||
<i class="fa-solid fa-music text-[10px]"></i>
|
||||
<span class="playlist-count">0</span>
|
||||
</span>
|
||||
<span class="playlist-date">刚刚</span>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center justify-between text-xs text-gray-500 border-t border-white/5 pt-3 mt-1">
|
||||
<span class="font-mono playlist-id opacity-50">ID: 000000</span>
|
||||
<a href="#" target="_blank" class="playlist-link hover:text-white transition-colors flex items-center gap-1">
|
||||
打开网易云 <i class="fa-solid fa-arrow-up-right-from-square text-[10px]"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script src="app.js"></script>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user