mirror of
https://github.com/NeteaseCloudMusicApiEnhanced/api-enhanced.git
synced 2026-10-23 16:11:24 +08:00
build(version): bump 4.30.0 (#102)
* chore(deps): bump actions/checkout from 4 to 6 Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 6. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v4...v6) --- updated-dependencies: - dependency-name: actions/checkout dependency-version: '6' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * Squashed commit of the following: commitf73cbbeec3Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun Feb 1 12:47:57 2026 +0000 chore(deps): bump actions/download-artifact from 4 to 7 Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 4 to 7. - [Release notes](https://github.com/actions/download-artifact/releases) - [Commits](https://github.com/actions/download-artifact/compare/v4...v7) --- updated-dependencies: - dependency-name: actions/download-artifact dependency-version: '7' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * Squashed commit of the following: commit4da2d5f360Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun Feb 1 12:48:00 2026 +0000 chore(deps): bump actions/github-script from 7 to 8 Bumps [actions/github-script](https://github.com/actions/github-script) from 7 to 8. - [Release notes](https://github.com/actions/github-script/releases) - [Commits](https://github.com/actions/github-script/compare/v7...v8) --- updated-dependencies: - dependency-name: actions/github-script dependency-version: '8' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * Squashed commit of the following: commit9e65b17625Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun Feb 1 12:47:49 2026 +0000 chore(deps): bump actions/setup-node from 4 to 6 Bumps [actions/setup-node](https://github.com/actions/setup-node) from 4 to 6. - [Release notes](https://github.com/actions/setup-node/releases) - [Commits](https://github.com/actions/setup-node/compare/v4...v6) --- updated-dependencies: - dependency-name: actions/setup-node dependency-version: '6' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * Squashed commit of the following: commita060f3c4ccAuthor: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun Feb 1 12:47:53 2026 +0000 chore(deps): bump actions/upload-artifact from 4 to 6 Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4 to 6. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](https://github.com/actions/upload-artifact/compare/v4...v6) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-version: '6' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * build(version): bump 4.30.0 * refactor: QR login and voice upload pages with improved UI and error handling - 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 * fix: Potential fix for code scanning alert no. 6: DOM text reinterpreted as HTML Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> * Potential fix for code scanning alert no. 15: DOM text reinterpreted as HTML Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> * build: update utils --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
Copilot Autofix powered by AI
dependabot[bot]
parent
27002d7665
commit
ce51da9150
+399
-244
@@ -2,261 +2,416 @@
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>歌单导入工具</title>
|
||||
<!-- 引入Bootstrap CSS -->
|
||||
<link href="https://fastly.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- 引入Bootstrap JS -->
|
||||
<script src="https://fastly.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<!-- 引入axios用于发送异步请求 -->
|
||||
<script src="https://fastly.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
|
||||
<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 mt-5">
|
||||
<h1 class="mb-4">歌单导入工具</h1>
|
||||
<p>请选择一种导入方式并填写相关信息:</p>
|
||||
<div class="container">
|
||||
<h1>歌单导入工具</h1>
|
||||
<p class="subtitle">请选择一种导入方式并填写相关信息</p>
|
||||
|
||||
<!-- 表单开始 -->
|
||||
<form id="importForm" novalidate>
|
||||
<!-- 选项卡导航 -->
|
||||
<ul class="nav nav-tabs mb-3" id="importTabs" role="tablist">
|
||||
<li class="nav-item" role="presentation">
|
||||
<button class="nav-link 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 class="nav-item" role="presentation">
|
||||
<button class="nav-link" id="text-tab" data-bs-toggle="tab" data-bs-target="#text" type="button" role="tab" aria-controls="text" aria-selected="false">文字导入</button>
|
||||
</li>
|
||||
<li class="nav-item" role="presentation">
|
||||
<button class="nav-link" id="link-tab" data-bs-toggle="tab" data-bs-target="#link" type="button" role="tab" aria-controls="link" aria-selected="false">链接导入</button>
|
||||
</li>
|
||||
</ul>
|
||||
<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" id="importTabContent">
|
||||
<!-- 元数据导入 -->
|
||||
<div class="tab-pane fade show active" id="metadata" role="tabpanel" aria-labelledby="metadata-tab">
|
||||
<table class="table table-bordered mb-3">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">歌曲名称</th>
|
||||
<th scope="col">艺术家</th>
|
||||
<th scope="col">专辑</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="metadataTableBody">
|
||||
<!-- 默认添加一行 -->
|
||||
<tr>
|
||||
<td><input type="text" class="form-control" name="name[]" placeholder="歌曲名称"></td>
|
||||
<td><input type="text" class="form-control" name="artist[]" placeholder="艺术家"></td>
|
||||
<td><input type="text" class="form-control" name="album[]" placeholder="专辑"></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<button type="button" class="btn btn-secondary mb-3" id="addMetadataRow">增加歌曲</button>
|
||||
<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="tab-pane fade" id="text" role="tabpanel" aria-labelledby="text-tab">
|
||||
<div class="mb-3">
|
||||
<label for="textInput" class="form-label">文字:</label>
|
||||
<textarea class="form-control" id="textInput" name="text" rows="5"></textarea>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="playlistNameInput" class="form-label">歌单名:</label>
|
||||
<input type="text" class="form-control" id="playlistNameInput" name="playlistName" placeholder="请输入歌单名">
|
||||
</div>
|
||||
</div>
|
||||
<!-- 链接导入 -->
|
||||
<div class="tab-pane fade" id="link" role="tabpanel" aria-labelledby="link-tab">
|
||||
<div class="mb-3">
|
||||
<label for="linkInputs" class="form-label">链接:</label>
|
||||
<div id="linkInputsContainer">
|
||||
<div class="input-group mb-3">
|
||||
<input type="text" class="form-control" 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 mb-3" id="addLinkButton">增加链接</button>
|
||||
<div class="mb-3">
|
||||
<label for="playlistNameLinkInput" class="form-label">歌单名:</label>
|
||||
<input type="text" class="form-control" id="playlistNameLinkInput" name="playlistName" placeholder="请输入歌单名">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="playlistNameInput">歌单名称</label>
|
||||
<input type="text" id="playlistNameInput" name="playlistName" placeholder="请输入歌单名">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 是否导入我喜欢的音乐 -->
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" value="" id="importStarCheckbox">
|
||||
<label class="form-check-label" for="importStarCheckbox">
|
||||
导入“我喜欢的音乐”
|
||||
</label>
|
||||
<!-- 链接导入 -->
|
||||
<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>
|
||||
|
||||
<!-- 提交按钮 -->
|
||||
<button type="submit" class="btn btn-primary mt-3">导入歌曲</button>
|
||||
</form>
|
||||
<!-- 表单结束 -->
|
||||
<div class="checkbox-group">
|
||||
<input type="checkbox" value="" id="importStarCheckbox">
|
||||
<label for="importStarCheckbox">
|
||||
导入"我喜欢的音乐"
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// 动态增加链接输入框
|
||||
document.getElementById('addLinkButton').addEventListener('click', function() {
|
||||
var container = document.getElementById('linkInputsContainer');
|
||||
var newIndex = container.childElementCount - 1; // 减去非输入框元素的数量
|
||||
var newInput = document.createElement('input');
|
||||
newInput.type = 'text';
|
||||
newInput.className = 'form-control';
|
||||
newInput.id = `linkInput${newIndex}`;
|
||||
newInput.name = `linkInput${newIndex}`;
|
||||
newInput.placeholder = '请输入链接';
|
||||
|
||||
var removeButton = document.createElement('button');
|
||||
removeButton.type = 'button';
|
||||
removeButton.className = 'btn btn-secondary removeLinkButton';
|
||||
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 mb-3';
|
||||
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');
|
||||
|
||||
var nameInput = document.createElement('input');
|
||||
nameInput.type = 'text';
|
||||
nameInput.className = 'form-control';
|
||||
nameInput.name = 'name[]';
|
||||
nameInput.placeholder = '歌曲名称';
|
||||
|
||||
var artistInput = document.createElement('input');
|
||||
artistInput.type = 'text';
|
||||
artistInput.className = 'form-control';
|
||||
artistInput.name = 'artist[]';
|
||||
artistInput.placeholder = '艺术家';
|
||||
|
||||
var albumInput = document.createElement('input');
|
||||
albumInput.type = 'text';
|
||||
albumInput.className = 'form-control';
|
||||
albumInput.name = 'album[]';
|
||||
albumInput.placeholder = '专辑';
|
||||
|
||||
newRow.innerHTML = `
|
||||
<td>${nameInput.outerHTML}</td>
|
||||
<td>${artistInput.outerHTML}</td>
|
||||
<td>${albumInput.outerHTML}</td>
|
||||
`;
|
||||
|
||||
container.appendChild(newRow);
|
||||
});
|
||||
|
||||
document.getElementById('importForm').addEventListener('submit', async function(event) {
|
||||
// 阻止默认行为
|
||||
event.preventDefault();
|
||||
|
||||
// 获取表单值
|
||||
let text = document.getElementById('textInput').value;
|
||||
let links = [];
|
||||
let local = [];
|
||||
let playlistName = '';
|
||||
|
||||
// 获取所有链接输入框的值
|
||||
let linkInputs = document.querySelectorAll('#linkInputsContainer .input-group .form-control');
|
||||
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}`)
|
||||
// const res2 = await axios({
|
||||
// url: `/playlist/import/task/status?timestamp=${Date.now()}`,
|
||||
// method: 'post',
|
||||
// data: {
|
||||
// id: taskId
|
||||
// },
|
||||
// });
|
||||
// alert(JSON.stringify(res2.data, null, 2));
|
||||
}
|
||||
} 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>
|
||||
<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>
|
||||
Reference in New Issue
Block a user