推送弹幕标签页和弹幕测试标签页中新增跳转到指定集数的功能 (#229)

* 推送弹幕标签页和弹幕测试标签页中新增跳转到指定集数的功能,解决比如像名侦探柯南这种集数很多的剧,要滑动很久才能定位到集的问题

* 修复两边都渲染后冲突的问题
This commit is contained in:
huangxd- authored and GitHub committed 2026-03-12 23:36:31 +08:00
1 parent 0304dd8b8b
commit 512b7f36ce
3 files changed
+78 -5

No files matched your search

+1 -1
View File
@@ -13,7 +13,7 @@ export const Globals = {
accessedEnvVars: {},
// 静态常量
VERSION: '1.16.1',
VERSION: '1.16.2',
MAX_LOGS: 1000, // 日志存储,最多保存 1000 行
MAX_ANIMES: 100,
MAX_RECORDS: 100, // 请求记录最大数量
+37 -1
View File
@@ -579,10 +579,21 @@ function displayManualEpisodeList(animeTitle, episodes) {
let html = backBtnHtml('返回搜索结果', 'backToManualSearch()');
html += '<h3 style="margin:15px 0 10px;">剧集列表</h3>';
html += '<h4 class="text-yellow-gold">' + escapeHtml(animeTitle) + '</h4>';
// 添加跳转到指定集数的功能
html += \`
<div class="jump-to-episode" style="margin-top: 15px; margin-bottom: 15px; padding: 10px; background: #f8f9fa; border-radius: 12px; display: flex; align-items: center; gap: 10px;">
<span>跳转到第</span>
<input type="number" id="jump-episode-input" placeholder="输入集数" min="1" style="padding: 8px; width: 90px; border: 1px solid #ccc; border-radius: 8px;">
<span>集</span>
<button class="btn btn-primary btn-sm" onclick="jumpToEpisode()" style="margin-left: 5px; border-radius: 8px;">跳转</button>
<span style="margin-left: 5px; color: #666; font-size: 14px;">共\${episodes.length}集</span>
</div>\`;
html += '<div class="episode-list-container">';
episodes.forEach(ep => {
const title = escapeHtml(animeTitle) + ' 第' + ep.episodeNumber + '集';
html += '<div class="episode-item">';
html += '<div class="episode-item" id="episode-item-' + ep.episodeNumber + '">';
html += '<div class="episode-item-content"><strong>第' + ep.episodeNumber + '集</strong> - ' + escapeHtml(ep.episodeTitle || '无标题') + '</div>';
html += '<button class="btn btn-success btn-sm" onclick="fetchDanmuForTest(' + ep.episodeId + ', \\'' + title + '\\', \\'manual\\')">获取弹幕</button>';
html += '</div>';
@@ -603,6 +614,31 @@ function backToEpisodeList() {
showDanmuView(['manual-episode-list'], ['danmu-result-area']);
}
// 跳转到指定集数
function jumpToEpisode() {
const episodeInput = document.getElementById('jump-episode-input');
const episodeNumber = parseInt(episodeInput.value);
if (!episodeNumber || episodeNumber <= 0) {
customAlert('请输入有效的集数(正整数)');
return;
}
// 查找对应集数的元素
const episodeElement = document.getElementById('episode-item-' + episodeNumber);
if (episodeElement) {
// 滚动到指定元素位置
episodeElement.scrollIntoView({ behavior: 'smooth', block: 'center' });
// 添加高亮效果以便识别
episodeElement.style.backgroundColor = '#fff3cd'; // 黄色背景高亮
setTimeout(() => {
episodeElement.style.backgroundColor = ''; // 恢复原色
}, 2000);
} else {
customAlert('找不到第' + episodeNumber + '集');
}
}
// =====================
// 获取弹幕并展示结果
// =====================
+40 -3
View File
@@ -138,13 +138,25 @@ function getBangumiForPush(animeId, pushUrl) {
// 展示剧集列表用于推送
function displayEpisodeListForPush(animeTitle, episodes, pushUrl) {
const container = document.getElementById('push-episode-list');
let html = \`<h3>剧集列表</h3><h4 class="text-yellow-gold">\${animeTitle}</h4><div class="episode-list-container">\`;
let html = \`<h3>剧集列表</h3><h4 class="text-yellow-gold">\${animeTitle}</h4>\`;
// 添加跳转到指定集数的功能
html += \`
<div class="jump-to-episode" style="margin-top: 15px; margin-bottom: 15px; padding: 10px; background: #f8f9fa; border-radius: 12px; display: flex; align-items: center; gap: 10px;">
<span>跳转到第</span>
<input type="number" id="jump-episode-input-push" placeholder="输入集数" min="1" style="padding: 8px; width: 90px; border: 1px solid #ccc; border-radius: 8px;">
<span>集</span>
<button class="btn btn-primary btn-sm" onclick="jumpToEpisodeForPushDanmu()" style="margin-left: 5px; border-radius: 8px;">跳转</button>
<span style="margin-left: 5px; color: #666; font-size: 14px;">共\${episodes.length}集</span>
</div>\`;
html += '<div class="episode-list-container">';
episodes.forEach(episode => {
// 生成弹幕URL
const commentUrl = window.location.origin + buildApiUrl('/api/v2/comment/' + episode.episodeId + '?format=xml');
html += \`
<div class="episode-item">
<div class="episode-item" id="episode-item-push-\${episode.episodeNumber}">
<div class="episode-item-content">
<strong>第\${episode.episodeNumber}集</strong> - \${episode.episodeTitle || '无标题'}
</div>
@@ -165,6 +177,31 @@ function displayEpisodeListForPush(animeTitle, episodes, pushUrl) {
}, 10);
}
// 跳转到指定集数(推送弹幕版)
function jumpToEpisodeForPushDanmu() {
const episodeInput = document.getElementById('jump-episode-input-push');
const episodeNumber = parseInt(episodeInput.value);
if (!episodeNumber || episodeNumber <= 0) {
customAlert('请输入有效的集数(正整数)');
return;
}
// 查找对应集数的元素
const episodeElement = document.getElementById('episode-item-push-' + episodeNumber);
if (episodeElement) {
// 滚动到指定元素位置
episodeElement.scrollIntoView({ behavior: 'smooth', block: 'center' });
// 添加高亮效果以便识别
episodeElement.style.backgroundColor = '#fff3cd'; // 黄色背景高亮
setTimeout(() => {
episodeElement.style.backgroundColor = ''; // 恢复原色
}, 2000);
} else {
customAlert('找不到第' + episodeNumber + '集');
}
}
// 推送弹幕
async function pushDanmu(pushUrl, commentUrl, episodeTitle) {
// 获取推送按钮元素