一分钟搭建影视站,支持Docker等部署方式
新增 detail 地址输入框和处理逻辑,支持自定义API的详细信息
developerb4b4027076f0
diff --git a/index.html b/index.htmlindex 1f60a23..83c664e 100644--- a/index.html+++ b/index.html@@ -118,6 +118,8 @@<div id="addCustomApiForm" class="hidden mt-2 p-2 bg-[#191919] rounded-lg"><input type="text" id="customApiName" placeholder="API名称" class="w-full bg-[#222] border border-[#333] text-white px-2 py-1 rounded mb-2" autocomplete="off"><input type="text" id="customApiUrl" placeholder="https://abc.com" class="w-full bg-[#222] border border-[#333] text-white px-2 py-1 rounded mb-2" autocomplete="off">+ <!-- 新增 detail 地址输入框 -->+ <input type="text" id="customApiDetail" placeholder="detail地址(可选)" class="w-full bg-[#222] border border-[#333] text-white px-2 py-1 rounded mb-2" autocomplete="off"><!-- 添加成人内容切换 --><div class="flex items-center mb-2"><input type="checkbox" id="customApiIsAdult" class="form-checkbox h-4 w-4 text-pink-500 bg-[#222] border border-[#333]">diff --git a/js/api.js b/js/api.jsindex cc8c47b..dc02eae 100644--- a/js/api.js+++ b/js/api.js@@ -1,6 +1,7 @@// 改进的API请求处理函数async function handleApiRequest(url) {const customApi = url.searchParams.get('customApi') || '';+ const customDetail = url.searchParams.get('customDetail') || '';const source = url.searchParams.get('source') || 'heimuer';try {@@ -95,6 +96,10 @@ async function handleApiRequest(url) {}// 如果是自定义API,并且传递了detail参数,尝试特殊处理+ // 优先 customDetail+ if (sourceCode === 'custom' && customDetail) {+ return await handleCustomApiSpecialDetail(id, customDetail);+ }if (sourceCode === 'custom' && url.searchParams.get('useDetail') === 'true') {return await handleCustomApiSpecialDetail(id, customApi);}diff --git a/js/app.js b/js/app.jsindex 24b8b67..5f2e0e2 100644--- a/js/app.js+++ b/js/app.js@@ -220,13 +220,10 @@ function renderCustomAPIsList() {customAPIs.forEach((api, index) => {const apiItem = document.createElement('div');apiItem.className = 'flex items-center justify-between p-1 mb-1 bg-[#222] rounded';-- // 根据是否是成人内容设置不同的样式const textColorClass = api.isAdult ? 'text-pink-400' : 'text-white';-- // 将(18+)标记移到最前面const adultTag = api.isAdult ? '<span class="text-xs text-pink-400 mr-1">(18+)</span>' : '';-+ // 新增 detail 地址显示+ const detailLine = api.detail ? `<div class="text-xs text-gray-400 truncate">detail: ${api.detail}</div>` : '';apiItem.innerHTML = `<div class="flex items-center flex-1 min-w-0"><input type="checkbox" id="custom_api_${index}"@@ -238,6 +235,7 @@ function renderCustomAPIsList() {${adultTag}${api.name}</div><div class="text-xs text-gray-500 truncate">${api.url}</div>+ ${detailLine}</div></div><div class="flex items-center">@@ -246,8 +244,6 @@ function renderCustomAPIsList() {</div>`;container.appendChild(apiItem);-- // 添加事件监听器apiItem.querySelector('input').addEventListener('change', function() {updateSelectedAPIs();checkAdultAPIsSelected();@@ -258,24 +254,15 @@ function renderCustomAPIsList() {// 编辑自定义APIfunction editCustomApi(index) {if (index < 0 || index >= customAPIs.length) return;-const api = customAPIs[index];-- // 填充表单数据- const nameInput = document.getElementById('customApiName');- const urlInput = document.getElementById('customApiUrl');+ document.getElementById('customApiName').value = api.name;+ document.getElementById('customApiUrl').value = api.url;+ document.getElementById('customApiDetail').value = api.detail || '';const isAdultInput = document.getElementById('customApiIsAdult');-- nameInput.value = api.name;- urlInput.value = api.url;if (isAdultInput) isAdultInput.checked = api.isAdult || false;-- // 显示表单const form = document.getElementById('addCustomApiForm');if (form) {form.classList.remove('hidden');-- // 替换表单按钮操作const buttonContainer = form.querySelector('div:last-child');buttonContainer.innerHTML = `<button onclick="updateCustomApi(${index})" class="bg-blue-600 hover:bg-blue-700 text-white px-3 py-1 rounded text-xs">更新</button>@@ -287,50 +274,34 @@ function editCustomApi(index) {// 更新自定义APIfunction updateCustomApi(index) {if (index < 0 || index >= customAPIs.length) return;-const nameInput = document.getElementById('customApiName');const urlInput = document.getElementById('customApiUrl');+ const detailInput = document.getElementById('customApiDetail');const isAdultInput = document.getElementById('customApiIsAdult');-const name = nameInput.value.trim();let url = urlInput.value.trim();+ const detail = detailInput ? detailInput.value.trim() : '';const isAdult = isAdultInput ? isAdultInput.checked : false;-if (!name || !url) {showToast('请输入API名称和链接', 'warning');return;}-- // 确保URL格式正确if (!/^https?:\/\/.+/.test(url)) {showToast('API链接格式不正确,需以http://或https://开头', 'warning');return;}-- // 移除URL末尾的斜杠- if (url.endsWith('/')) {- url = url.slice(0, -1);- }-- // 更新API信息- customAPIs[index] = { name, url, isAdult };+ if (url.endsWith('/')) url = url.slice(0, -1);+ // 保存 detail 字段+ customAPIs[index] = { name, url, detail, isAdult };localStorage.setItem('customAPIs', JSON.stringify(customAPIs));-- // 重新渲染自定义API列表renderCustomAPIsList();-- // 重新检查成人API选中状态checkAdultAPIsSelected();-- // 恢复添加按钮restoreAddCustomApiButtons();-- // 清空表单并隐藏nameInput.value = '';urlInput.value = '';+ if (detailInput) detailInput.value = '';if (isAdultInput) isAdultInput.checked = false;document.getElementById('addCustomApiForm').classList.add('hidden');-showToast('已更新自定义API: ' + name, 'success');}@@ -339,6 +310,7 @@ function cancelEditCustomApi() {// 清空表单document.getElementById('customApiName').value = '';document.getElementById('customApiUrl').value = '';+ document.getElementById('customApiDetail').value = '';const isAdultInput = document.getElementById('customApiIsAdult');if (isAdultInput) isAdultInput.checked = false;@@ -420,6 +392,7 @@ function cancelAddCustomApi() {form.classList.add('hidden');document.getElementById('customApiName').value = '';document.getElementById('customApiUrl').value = '';+ document.getElementById('customApiDetail').value = '';const isAdultInput = document.getElementById('customApiIsAdult');if (isAdultInput) isAdultInput.checked = false;@@ -432,52 +405,39 @@ function cancelAddCustomApi() {function addCustomApi() {const nameInput = document.getElementById('customApiName');const urlInput = document.getElementById('customApiUrl');+ const detailInput = document.getElementById('customApiDetail');const isAdultInput = document.getElementById('customApiIsAdult');-const name = nameInput.value.trim();let url = urlInput.value.trim();+ const detail = detailInput ? detailInput.value.trim() : '';const isAdult = isAdultInput ? isAdultInput.checked : false;-if (!name || !url) {showToast('请输入API名称和链接', 'warning');return;}-- // 确保URL格式正确if (!/^https?:\/\/.+/.test(url)) {showToast('API链接格式不正确,需以http://或https://开头', 'warning');return;}-- // 移除URL末尾的斜杠if (url.endsWith('/')) {url = url.slice(0, -1);}-- // 添加到自定义API列表 - 增加isAdult属性- customAPIs.push({ name, url, isAdult });+ // 保存 detail 字段+ customAPIs.push({ name, url, detail, isAdult });localStorage.setItem('customAPIs', JSON.stringify(customAPIs));-- // 默认选中新添加的APIconst newApiIndex = customAPIs.length - 1;selectedAPIs.push('custom_' + newApiIndex);localStorage.setItem('selectedAPIs', JSON.stringify(selectedAPIs));// 重新渲染自定义API列表renderCustomAPIsList();-- // 更新选中的API数量updateSelectedApiCount();-- // 重新检查成人API选中状态checkAdultAPIsSelected();-- // 清空表单并隐藏nameInput.value = '';urlInput.value = '';+ if (detailInput) detailInput.value = '';if (isAdultInput) isAdultInput.checked = false;document.getElementById('addCustomApiForm').classList.add('hidden');-showToast('已添加自定义API: ' + name, 'success');}@@ -848,8 +808,12 @@ async function showDetails(id, vod_name, sourceCode) {hideLoading();return;}-- apiParams = '&customApi=' + encodeURIComponent(customApi.url) + '&source=custom';+ // 传递 detail 字段+ if (customApi.detail) {+ apiParams = '&customApi=' + encodeURIComponent(customApi.url) + '&customDetail=' + encodeURIComponent(customApi.detail) + '&source=custom';+ } else {+ apiParams = '&customApi=' + encodeURIComponent(customApi.url) + '&source=custom';+ }} else {// 内置APIapiParams = '&source=' + sourceCode;