一分钟搭建影视站,支持Docker等部署方式
Enhance navigation by saving last page URL and improving return URL handling refactor: improve video playback and search URL handling
developere7230a2733f2
diff --git a/js/app.js b/js/app.jsindex 2ccf5ce..5afbb06 100644--- a/js/app.js+++ b/js/app.js@@ -1021,6 +1021,7 @@ function playVideo(url, vod_name, sourceCode, episodeIndex = 0) {localStorage.setItem('currentSourceCode', sourceCode || '');localStorage.setItem('lastPlayTime', Date.now());localStorage.setItem('lastSearchPage', currentPath);+ localStorage.setItem('lastPageUrl', currentPath); // 确保保存返回页面URL} catch (e) {console.error('保存播放状态失败:', e);}diff --git a/js/ui.js b/js/ui.jsindex 455bd8a..f9a0cfa 100644--- a/js/ui.js+++ b/js/ui.js@@ -488,6 +488,11 @@ function playFromHistory(url, title, episodeIndex, playbackPosition = 0) {localStorage.setItem('currentEpisodes', JSON.stringify(episodesList));console.log(`已将剧集列表保存到localStorage,共 ${episodesList.length} 集`);}++ // 保存当前页面URL作为返回地址+ const currentPath = window.location.href;+ localStorage.setItem('lastPageUrl', currentPath);+// 构造带播放进度参数的URLconst positionParam = `&position=${Math.floor(playbackPosition || 0)}`;@@ -498,10 +503,12 @@ function playFromHistory(url, title, episodeIndex, playbackPosition = 0) {playUrl.searchParams.set('index', episodeIndex);}playUrl.searchParams.set('position', Math.floor(playbackPosition || 0).toString());+ // 添加返回URL+ playUrl.searchParams.set('returnUrl', encodeURIComponent(currentPath));showVideoPlayer(playUrl.toString());} else {// 原始URL,构造player页面链接- const playerUrl = `player.html?url=${encodeURIComponent(url)}&title=${encodeURIComponent(title)}&index=${episodeIndex}&position=${Math.floor(playbackPosition || 0)}`;+ const playerUrl = `player.html?url=${encodeURIComponent(url)}&title=${encodeURIComponent(title)}&index=${episodeIndex}&position=${Math.floor(playbackPosition || 0)}&returnUrl=${encodeURIComponent(currentPath)}`;showVideoPlayer(playerUrl);}} catch (e) {diff --git a/player.html b/player.htmlindex a13f74e..19ec6d8 100644--- a/player.html+++ b/player.html@@ -497,22 +497,6 @@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参数@@ -1271,7 +1255,7 @@videoHasEnded = false; // 重置视频结束标志// 获取当前URL参数,保留source参数- const urlParams = new URLSearchParams(window.location.search);+ const urlParams = new URL(window.location.href);const sourceName = urlParams.get('source') || '';const sourceCode = urlParams.get('source_code') || '';diff --git a/watch.html b/watch.htmlindex 822030a..50fba0c 100644--- a/watch.html+++ b/watch.html@@ -33,6 +33,9 @@} else if (referrer && (referrer.includes('/s=') || referrer.includes('?s='))) {// 来源是搜索页面returnUrl = referrer;+ } else if (referrer && referrer.trim() !== '') {+ // 如果有referrer但不是搜索页,也使用它+ returnUrl = referrer;} else {// 默认回到首页returnUrl = '/';