Skip to content

一分钟搭建影视站,支持Docker等部署方式

fix: 修复和优化Toast消息提示功能,确保其显示在顶层并添加适当的转换效果

developer74b432f85486
diff --git a/css/styles.css b/css/styles.css
index 6ded957..0f98263 100644
--- a/css/styles.css
+++ b/css/styles.css
@@ -877,3 +877,19 @@ body {
.card-hover .p-2 {
padding: 0.5rem;
}
+
+/* 确保Toast显示在顶层并有适当的转换效果 */
+#toast {
+ z-index: 9999; /* 确保显示在最上层 */
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
+ min-width: 200px;
+ text-align: center;
+ pointer-events: none; /* 防止toast阻挡点击事件 */
+ transform: translateX(-50%) translateY(0);
+ transition: opacity 0.3s ease, transform 0.3s ease;
+}
+
+#toast.hidden {
+ opacity: 0;
+ transform: translateX(-50%) translateY(-100%);
+}
diff --git a/index.html b/index.html
index 6f4f71b..6a9a3d6 100644
--- a/index.html
+++ b/index.html
@@ -373,7 +373,7 @@
</div>
<!-- 错误提示框 -->
- <div id="toast" class="fixed top-4 left-1/2 -translate-x-1/2 bg-red-500 text-white px-6 py-3 rounded-lg shadow-lg transform transition-all duration-300 opacity-0 -translate-y-full"></div>
+ <div id="toast" class="fixed top-4 left-1/2 -translate-x-1/2 bg-red-500 text-white px-6 py-3 rounded-lg shadow-lg transform transition-all duration-300 opacity-0 -translate-y-full z-50">
<p id="toastMessage"></p>
</div>
diff --git a/js/ui.js b/js/ui.js
index eb5dc93..757f340 100644
--- a/js/ui.js
+++ b/js/ui.js
@@ -18,6 +18,23 @@ const toastQueue = [];
let isShowingToast = false;
function showToast(message, type = 'error') {
+ // 首先确保toast元素存在
+ let toast = document.getElementById('toast');
+ let toastMessage = document.getElementById('toastMessage');
+
+ // 如果toast元素不存在,创建它
+ if (!toast) {
+ toast = document.createElement('div');
+ toast.id = 'toast';
+ toast.className = 'fixed top-4 left-1/2 -translate-x-1/2 px-6 py-3 rounded-lg shadow-lg transform transition-all duration-300 z-50 opacity-0';
+
+ toastMessage = document.createElement('p');
+ toastMessage.id = 'toastMessage';
+ toast.appendChild(toastMessage);
+
+ document.body.appendChild(toast);
+ }
+
// 将新的toast添加到队列
toastQueue.push({ message, type });
diff --git a/player.html b/player.html
index a199d54..2112e04 100644
--- a/player.html
+++ b/player.html
@@ -1557,54 +1557,6 @@
return `${encodeURIComponent(currentVideoTitle)}_${currentEpisodeIndex}`;
}
- // 简单的Toast消息提示函数
- function showToast(message, type = 'error') {
- // 如果已有Toast,先移除它
- const existingToast = document.getElementById('custom-toast');
- if (existingToast) {
- document.body.removeChild(existingToast);
- }
-
- // 创建新的Toast元素
- const toast = document.createElement('div');
- toast.id = 'custom-toast';
-
- // 设置Toast样式
- toast.style.position = 'fixed';
- toast.style.top = '20px';
- toast.style.left = '50%';
- toast.style.transform = 'translateX(-50%)';
- toast.style.backgroundColor = type === 'error' ? '#f44336' : '#4caf50';
- toast.style.color = 'white';
- toast.style.padding = '12px 20px';
- toast.style.borderRadius = '4px';
- toast.style.zIndex = '10000';
- toast.style.boxShadow = '0 2px 8px rgba(0, 0, 0, 0.3)';
- toast.style.opacity = '0';
- toast.style.transition = 'opacity 0.3s ease-in-out';
-
- // 设置Toast内容
- toast.textContent = message;
-
- // 添加到页面
- document.body.appendChild(toast);
-
- // 显示Toast
- setTimeout(() => {
- toast.style.opacity = '1';
-
- // 3秒后隐藏并移除
- setTimeout(() => {
- toast.style.opacity = '0';
- setTimeout(() => {
- if (toast.parentNode) {
- document.body.removeChild(toast);
- }
- }, 300);
- }, 3000);
- }, 10);
- }
-
let controlsLocked = false;
function toggleControlsLock() {
const container = document.getElementById('playerContainer');