一分钟搭建影视站,支持Docker等部署方式
修复通过历史记录打开视频无法返回上一页的问题
WLong0af75c5ffdf4
diff --git a/js/app.js b/js/app.jsindex 3eab011..bcd933e 100644--- a/js/app.js+++ b/js/app.js@@ -1002,17 +1002,18 @@ function playVideo(url, vod_name, sourceCode, episodeIndex = 0) {// 构建播放页面URL,传递必要参数const playerUrl = `player.html?url=${encodeURIComponent(url)}&title=${encodeURIComponent(videoTitle)}&index=${episodeIndex}&source=${encodeURIComponent(sourceName)}&source_code=${encodeURIComponent(sourceCode)}`;-- // 在当前标签页中打开播放页面- //window.location.href = playerUrl;+ showVideoPlayer(playerUrl);+}+// 弹出播放器页面+function showVideoPlayer(url) {// 临时隐藏搜索结果,防止高度超出播放器而出现滚动条document.getElementById('resultsArea').classList.add('hidden');// 在框架中打开播放页面videoPlayerFrame = document.createElement('iframe');videoPlayerFrame.id = 'VideoPlayerFrame';videoPlayerFrame.className = 'fixed w-full h-screen z-40';- videoPlayerFrame.src = playerUrl;+ videoPlayerFrame.src = url;document.body.appendChild(videoPlayerFrame);}diff --git a/js/ui.js b/js/ui.jsindex bc05f2e..dc3727f 100644--- a/js/ui.js+++ b/js/ui.js@@ -500,17 +500,17 @@ function playFromHistory(url, title, episodeIndex, playbackPosition = 0) {if (playbackPosition > 10) {playUrl.searchParams.set('position', Math.floor(playbackPosition).toString());}- window.location.href = playUrl.toString();+ showVideoPlayer(playUrl.toString());} else {// 原始URL,构造player页面链接const playerUrl = `player.html?url=${encodeURIComponent(url)}&title=${encodeURIComponent(title)}&index=${episodeIndex}${positionParam}`;- window.location.href = playerUrl;+ showVideoPlayer(playerUrl);}} catch (e) {console.error('从历史记录播放失败:', e);// 回退到原始简单URLconst simpleUrl = `player.html?url=${encodeURIComponent(url)}&title=${encodeURIComponent(title)}&index=${episodeIndex}`;- window.location.href = simpleUrl;+ showVideoPlayer(simpleUrl);}}diff --git a/player.html b/player.htmlindex 58e0d51..2e53346 100644--- a/player.html+++ b/player.html@@ -211,7 +211,7 @@</a></div><h2 id="videoTitle" class="text-xl font-semibold flex-1 text-center overflow-x-auto whitespace-nowrap truncate custom-title-scroll"></h2>- <a href="#" onclick="goBack()" class="px-4 py-2 bg-[#222] hover:bg-[#333] border border-[#333] rounded-lg transition-colors flex items-center min-w-0 home-btn">+ <a href="#" id="goBack" onclick="goBack()" class="px-4 py-2 bg-[#222] hover:bg-[#333] border border-[#333] rounded-lg transition-colors flex items-center min-w-0 home-btn"><svg class="w-5 h-5 mr-1" viewBox="0 0 24 24" fill="#ffffff" xmlns="http://www.w3.org/2000/svg"><path d="M5.25 11h15a1.5 1.5 0 1 1 0 3H5.25a1.5 1.5 0 0 1 0-3z"/><path d="M5.55 12 11.3 17.3a1.5 1.5 0 1 1-2.12 2.12L3 12l6.18-6.18a1.5 1.5 0 1 1 2.12 2.12L5.55 12z"/>@@ -422,7 +422,25 @@document.getElementById('loading').style.display = 'block';initializePageContent();- }); // 初始化页面内容+ });++ // 判断是否再框架中打开+ function inIframe() {+ try {+ // 如果当前窗口的顶层窗口不是自身,说明在框架中+ return window.self !== window.top;+ } catch (e) {+ // 跨域访问会抛出错误,此时也说明在框架中+ return true;+ }+ }+ // 如果播放器不是在框架中打开,则隐藏上一页按钮+ if (!inIframe()) {+ goBack = document.getElementById('goBack');+ goBack.style.display = 'none';+ }++ // 初始化页面内容function initializePageContent() {// 解析URL参数const urlParams = new URLSearchParams(window.location.search);