mirror of
https://github.com/NeteaseCloudMusicApiEnhanced/api-enhanced.git
synced 2026-03-21 11:03:15 +00:00
- Enhanced styling for better user experience on qrlogin-nocookie.html and qrlogin.html - Added loading indicators and improved status messages during QR code login process - Updated error handling for login status retrieval - Refactored unblock_test.html for better layout and user interaction - Improved voice upload page with a more intuitive design and better feedback for file uploads - Added loading state management for voice list retrieval - Enhanced accessibility and usability across all modified pages
417 lines
15 KiB
HTML
417 lines
15 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="zh-CN">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<title>歌单导入工具</title>
|
||
<style>
|
||
* {
|
||
margin: 0;
|
||
padding: 0;
|
||
box-sizing: border-box;
|
||
}
|
||
|
||
body {
|
||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
||
min-height: 100vh;
|
||
background: #f5f5f5;
|
||
padding: 20px;
|
||
}
|
||
|
||
.container {
|
||
max-width: 900px;
|
||
margin: 0 auto;
|
||
background: white;
|
||
border-radius: 12px;
|
||
padding: 32px;
|
||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||
}
|
||
|
||
h1 {
|
||
font-size: 24px;
|
||
font-weight: 600;
|
||
color: #333;
|
||
margin-bottom: 8px;
|
||
}
|
||
|
||
.subtitle {
|
||
font-size: 14px;
|
||
color: #666;
|
||
margin-bottom: 24px;
|
||
}
|
||
|
||
.tabs {
|
||
display: flex;
|
||
gap: 4px;
|
||
margin-bottom: 24px;
|
||
border-bottom: 1px solid #eee;
|
||
}
|
||
|
||
.tab-btn {
|
||
padding: 12px 24px;
|
||
background: transparent;
|
||
border: none;
|
||
border-bottom: 2px solid transparent;
|
||
font-size: 14px;
|
||
font-weight: 500;
|
||
color: #666;
|
||
cursor: pointer;
|
||
transition: all 0.2s ease;
|
||
}
|
||
|
||
.tab-btn:hover {
|
||
color: #333;
|
||
}
|
||
|
||
.tab-btn.active {
|
||
color: #333;
|
||
border-bottom-color: #333;
|
||
}
|
||
|
||
.tab-content {
|
||
display: none;
|
||
}
|
||
|
||
.tab-content.active {
|
||
display: block;
|
||
}
|
||
|
||
.form-group {
|
||
margin-bottom: 20px;
|
||
}
|
||
|
||
label {
|
||
display: block;
|
||
font-size: 14px;
|
||
font-weight: 500;
|
||
color: #555;
|
||
margin-bottom: 8px;
|
||
}
|
||
|
||
input[type="text"], textarea {
|
||
width: 100%;
|
||
padding: 10px 14px;
|
||
border: 1px solid #ddd;
|
||
border-radius: 6px;
|
||
font-size: 14px;
|
||
outline: none;
|
||
font-family: inherit;
|
||
}
|
||
|
||
input[type="text"]:focus, textarea:focus {
|
||
border-color: #333;
|
||
}
|
||
|
||
textarea {
|
||
min-height: 120px;
|
||
resize: vertical;
|
||
}
|
||
|
||
table {
|
||
width: 100%;
|
||
border-collapse: collapse;
|
||
margin-bottom: 16px;
|
||
}
|
||
|
||
table th, table td {
|
||
padding: 12px;
|
||
text-align: left;
|
||
border-bottom: 1px solid #eee;
|
||
}
|
||
|
||
table th {
|
||
font-size: 14px;
|
||
font-weight: 600;
|
||
color: #555;
|
||
background: #f9f9f9;
|
||
}
|
||
|
||
table td input {
|
||
width: 100%;
|
||
}
|
||
|
||
.btn {
|
||
padding: 10px 20px;
|
||
background: #333;
|
||
color: white;
|
||
font-size: 14px;
|
||
font-weight: 500;
|
||
border: none;
|
||
border-radius: 6px;
|
||
cursor: pointer;
|
||
transition: background 0.2s ease;
|
||
}
|
||
|
||
.btn:hover {
|
||
background: #555;
|
||
}
|
||
|
||
.btn-secondary {
|
||
background: #666;
|
||
}
|
||
|
||
.btn-secondary:hover {
|
||
background: #888;
|
||
}
|
||
|
||
.input-group {
|
||
display: flex;
|
||
gap: 8px;
|
||
margin-bottom: 12px;
|
||
}
|
||
|
||
.input-group input {
|
||
flex: 1;
|
||
}
|
||
|
||
.checkbox-group {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 8px;
|
||
margin-bottom: 24px;
|
||
}
|
||
|
||
.checkbox-group input[type="checkbox"] {
|
||
cursor: pointer;
|
||
}
|
||
|
||
.checkbox-group label {
|
||
margin: 0;
|
||
cursor: pointer;
|
||
}
|
||
|
||
input:disabled {
|
||
background: #f5f5f5;
|
||
cursor: not-allowed;
|
||
}
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<div class="container">
|
||
<h1>歌单导入工具</h1>
|
||
<p class="subtitle">请选择一种导入方式并填写相关信息</p>
|
||
|
||
<ul class="tabs" id="importTabs" role="tablist">
|
||
<li role="presentation">
|
||
<button class="tab-btn active" id="metadata-tab" data-bs-toggle="tab" data-bs-target="#metadata" type="button" role="tab" aria-controls="metadata" aria-selected="true">元数据导入</button>
|
||
</li>
|
||
<li role="presentation">
|
||
<button class="tab-btn" id="text-tab" data-bs-toggle="tab" data-bs-target="#text" type="button" role="tab" aria-controls="text" aria-selected="false">文字导入</button>
|
||
</li>
|
||
<li role="presentation">
|
||
<button class="tab-btn" id="link-tab" data-bs-toggle="tab" data-bs-target="#link" type="button" role="tab" aria-controls="link" aria-selected="false">链接导入</button>
|
||
</li>
|
||
</ul>
|
||
|
||
<div class="tab-content active" id="importTabContent">
|
||
<!-- 元数据导入 -->
|
||
<div class="tab-content active" id="metadata" role="tabpanel" aria-labelledby="metadata-tab">
|
||
<table>
|
||
<thead>
|
||
<tr>
|
||
<th style="width: 33%">歌曲名称</th>
|
||
<th style="width: 33%">艺术家</th>
|
||
<th style="width: 33%">专辑</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody id="metadataTableBody">
|
||
<tr>
|
||
<td><input type="text" name="name[]" placeholder="歌曲名称"></td>
|
||
<td><input type="text" name="artist[]" placeholder="艺术家"></td>
|
||
<td><input type="text" name="album[]" placeholder="专辑"></td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<button type="button" class="btn btn-secondary" id="addMetadataRow">增加歌曲</button>
|
||
</div>
|
||
<!-- 文字导入 -->
|
||
<div class="tab-content" id="text" role="tabpanel" aria-labelledby="text-tab">
|
||
<div class="form-group">
|
||
<label for="textInput">文字内容</label>
|
||
<textarea id="textInput" name="text" rows="5" placeholder="请输入歌曲信息,每行一首歌曲"></textarea>
|
||
</div>
|
||
<div class="form-group">
|
||
<label for="playlistNameInput">歌单名称</label>
|
||
<input type="text" id="playlistNameInput" name="playlistName" placeholder="请输入歌单名">
|
||
</div>
|
||
</div>
|
||
<!-- 链接导入 -->
|
||
<div class="tab-content" id="link" role="tabpanel" aria-labelledby="link-tab">
|
||
<div class="form-group">
|
||
<label>链接列表</label>
|
||
<div id="linkInputsContainer">
|
||
<div class="input-group">
|
||
<input type="text" id="linkInput0" name="linkInput0" placeholder="请输入链接">
|
||
<button type="button" class="btn btn-secondary removeLinkButton" data-index="0">×</button>
|
||
</div>
|
||
</div>
|
||
<button type="button" class="btn btn-secondary" id="addLinkButton" style="margin-top: 8px;">增加链接</button>
|
||
</div>
|
||
<div class="form-group" style="margin-top: 20px;">
|
||
<label for="playlistNameLinkInput">歌单名称</label>
|
||
<input type="text" id="playlistNameLinkInput" name="playlistName" placeholder="请输入歌单名">
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="checkbox-group">
|
||
<input type="checkbox" value="" id="importStarCheckbox">
|
||
<label for="importStarCheckbox">
|
||
导入"我喜欢的音乐"
|
||
</label>
|
||
</div>
|
||
|
||
<button type="submit" class="btn" id="submitBtn">导入歌曲</button>
|
||
</div>
|
||
|
||
<script src="https://fastly.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
|
||
<script>
|
||
// 选项卡切换
|
||
const tabBtns = document.querySelectorAll('.tab-btn');
|
||
const tabContents = document.querySelectorAll('.tab-content[id]');
|
||
|
||
tabBtns.forEach(btn => {
|
||
btn.addEventListener('click', () => {
|
||
tabBtns.forEach(b => b.classList.remove('active'));
|
||
tabContents.forEach(c => c.classList.remove('active'));
|
||
|
||
btn.classList.add('active');
|
||
const targetId = btn.getAttribute('data-bs-target');
|
||
document.getElementById(targetId).classList.add('active');
|
||
});
|
||
});
|
||
|
||
// 动态增加链接输入框
|
||
document.getElementById('addLinkButton').addEventListener('click', function() {
|
||
var container = document.getElementById('linkInputsContainer');
|
||
var newIndex = container.children.length;
|
||
var newInput = document.createElement('input');
|
||
newInput.type = 'text';
|
||
newInput.className = '';
|
||
newInput.id = `linkInput${newIndex}`;
|
||
newInput.name = `linkInput${newIndex}`;
|
||
newInput.placeholder = '请输入链接';
|
||
newInput.style.cssText = 'flex: 1; padding: 10px 14px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; outline: none;';
|
||
|
||
var removeButton = document.createElement('button');
|
||
removeButton.type = 'button';
|
||
removeButton.className = 'btn btn-secondary';
|
||
removeButton.textContent = '×';
|
||
removeButton.dataset.index = newIndex.toString();
|
||
removeButton.addEventListener('click', function() {
|
||
var group = this.closest('.input-group');
|
||
container.removeChild(group);
|
||
});
|
||
|
||
var inputGroup = document.createElement('div');
|
||
inputGroup.className = 'input-group';
|
||
inputGroup.appendChild(newInput);
|
||
inputGroup.appendChild(removeButton);
|
||
|
||
container.appendChild(inputGroup);
|
||
});
|
||
|
||
// 动态增加元数据行
|
||
document.getElementById('addMetadataRow').addEventListener('click', function() {
|
||
var container = document.getElementById('metadataTableBody');
|
||
var newRow = document.createElement('tr');
|
||
|
||
newRow.innerHTML = `
|
||
<td><input type="text" name="name[]" placeholder="歌曲名称" style="width: 100%; padding: 10px 14px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; outline: none;"></td>
|
||
<td><input type="text" name="artist[]" placeholder="艺术家" style="width: 100%; padding: 10px 14px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; outline: none;"></td>
|
||
<td><input type="text" name="album[]" placeholder="专辑" style="width: 100%; padding: 10px 14px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; outline: none;"></td>
|
||
`;
|
||
|
||
container.appendChild(newRow);
|
||
});
|
||
|
||
document.getElementById('submitBtn').addEventListener('click', async function() {
|
||
// 获取表单值
|
||
let text = document.getElementById('textInput').value;
|
||
let links = [];
|
||
let local = [];
|
||
let playlistName = '';
|
||
|
||
// 获取所有链接输入框的值
|
||
let linkInputs = document.querySelectorAll('#linkInputsContainer .input-group input[type="text"]');
|
||
linkInputs.forEach(function(input) {
|
||
if (input.value.trim() !== '') {
|
||
links.push(input.value);
|
||
}
|
||
});
|
||
|
||
// 获取元数据
|
||
let metadataRows = document.querySelectorAll('#metadataTableBody tr');
|
||
metadataRows.forEach(function(row) {
|
||
let name = row.querySelector('input[name="name[]"]').value;
|
||
let artist = row.querySelector('input[name="artist[]"]').value;
|
||
let album = row.querySelector('input[name="album[]"]').value;
|
||
if (name && artist && album) {
|
||
local.push({ name, artist, album });
|
||
}
|
||
});
|
||
|
||
// 检查是否有且只有一个输入字段被填写
|
||
let filledCount = (text ? 1 : 0) + (links.length > 0 ? 1 : 0) + (local.length > 0 ? 1 : 0);
|
||
if (filledCount !== 1) {
|
||
alert("请确保仅填写了一个输入字段!");
|
||
return;
|
||
}
|
||
|
||
// 获取歌单名
|
||
if (document.getElementById('importStarCheckbox').checked) {
|
||
playlistName = '我喜欢的音乐';
|
||
} else {
|
||
playlistName = document.getElementById('playlistNameInput').value ||
|
||
document.getElementById('playlistNameLinkInput').value ||
|
||
'导入音乐 ' + new Date().toLocaleString();
|
||
}
|
||
|
||
// 创建请求参数
|
||
let data = {};
|
||
if (text) {
|
||
data.text = text;
|
||
data.playlistName = playlistName;
|
||
} else if (links.length > 0) {
|
||
data.link = JSON.stringify(links);
|
||
data.playlistName = playlistName;
|
||
} else if (local.length > 0) {
|
||
data.local = JSON.stringify(local);
|
||
}
|
||
|
||
// 添加额外参数
|
||
if (document.getElementById('importStarCheckbox').checked) {
|
||
data.importStarPlaylist = true;
|
||
}
|
||
|
||
try {
|
||
const res = await axios({
|
||
url: `/playlist/import/name/task/create?timestamp=${Date.now()}`,
|
||
method: 'post',
|
||
data: data,
|
||
});
|
||
|
||
let taskId = res.data?.data?.taskId
|
||
if (taskId) {
|
||
alert(`任务创建成功!正在导入,请稍等;任务id:${taskId}`)
|
||
}
|
||
} catch (error) {
|
||
console.error('Error:', error);
|
||
alert('导入失败,请检查您的输入或稍后再试。');
|
||
}
|
||
});
|
||
|
||
// 监听复选框状态变化
|
||
document.getElementById('importStarCheckbox').addEventListener('change', function() {
|
||
let isChecked = this.checked;
|
||
let playlistNameInputs = document.querySelectorAll('[name="playlistName"]');
|
||
playlistNameInputs.forEach(function(input) {
|
||
input.disabled = isChecked;
|
||
});
|
||
});
|
||
|
||
// 初始化时设置歌单名输入框的状态
|
||
document.getElementById('importStarCheckbox').dispatchEvent(new Event('change'));
|
||
</script>
|
||
</body>
|
||
</html> |