From c863d3b2e00fb961d9fa202351693b6a55ed28a7 Mon Sep 17 00:00:00 2001 From: Krcia <1503175889@qq.com> Date: Fri, 7 Nov 2025 15:23:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E7=BD=91=E9=A1=B5=E5=B8=83?= =?UTF-8?q?=E5=B1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker/html/home.html | 204 +++++++++++++++++++++++++++++++++++++----- docker/nginx.conf | 2 +- 2 files changed, 183 insertions(+), 23 deletions(-) diff --git a/docker/html/home.html b/docker/html/home.html index 1d820c6..662cd4c 100644 --- a/docker/html/home.html +++ b/docker/html/home.html @@ -269,10 +269,6 @@
正在加载任务数据...
- -
- 最后更新: -- -
@@ -352,9 +348,9 @@ var progressPercent = Math.round(task.progress * 100) + '%'; taskHtml += ` -
+
-
${task.fileName}
+
${task.filename}
@@ -375,12 +371,12 @@ // 更新任务进度(不重新渲染整个列表) function updateTaskProgress(tasks) { tasks = tasks.data; - tasks.forEach(function () { - var taskItem = $(`.task-item[data-id="${task.id}"]`); + tasks.forEach(function (item) { + var taskItem = $(`.task-item[data-id="${item.task_id}"]`); if (taskItem.length > 0) { - var progressPercent = Math.round(task.progress * 100) + '%'; - var statusText = task.status === 'completed' ? '已完成' : '进行中'; - var statusClass = task.status === 'completed' ? 'status-completed' : 'status-processing'; + var progressPercent = Math.round(item.progress * 100) + '%'; + var statusText = item.status === 'completed' ? '已完成' : '进行中'; + var statusClass = item.status === 'completed' ? 'status-completed' : 'status-processing'; // 更新进度条 var progressBar = taskItem.find('.layui-progress-bar'); @@ -442,10 +438,12 @@ formType: 0, }, function (url, index) { layer.close(index); - // 获取token - const token = localStorage.getItem('Authorization'); - // 调用检查接口 + const token = localStorage.getItem('Authorization'); + const loadingIndex = layer.load(2, { + shade: [0.1, '#000'] + }); + fetch(`/api/check/${encodeURIComponent(url)}`, { method: 'GET', headers: { @@ -454,25 +452,187 @@ } }) .then(response => { - console.log('响应状态:', response.status); - console.log('响应头:', response.headers); - if (!response.ok) { throw new Error('检查URL失败'); } return response.json(); }) .then(data => { - console.log('接口返回数据:', data); - // 重新加载任务列表 - // initTaskList(); + layer.close(loadingIndex); + + if (data.code !== 200 || !data.data) { + layer.msg('接口返回异常', { icon: 2 }); + return; + } + + const { serial_number, title, url: urlList } = data.data; + + // 检测设备类型 + const isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent); + + // 动态生成URL列表HTML - 响应式布局 + const urlHtml = urlList.map((u, index) => { + if (isMobile) { + // 手机端布局 - 垂直排列 + return ` +
  • +
    + ${u} +
    + +
  • `; + } else { + // 电脑端布局 - 水平排列 + return ` +
  • +
    + ${u} +
    +
    + +
    +
  • `; + } + }).join(''); + + // 响应式弹窗设置 + const popupSettings = isMobile ? { + area: ['90vw', '70vh'], + content: ` +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    +
    +
      ${urlHtml || '
    • 无URL
    • '}
    +
    +
    +
    +
    + ` + } : { + area: ['580px', '420px'], + content: ` +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    +
    +
      ${urlHtml || '
    • 无URL
    • '}
    +
    +
    +
    +
    + ` + }; + + // 打开弹窗 + const popupIndex = layer.open({ + type: 1, + title: '链接详情', + ...popupSettings, + btn: ['关闭'], + success: function (layero) { + // 为选择按钮绑定点击事件 + $(layero).find('.select-url').on('click', function () { + const serial = $(this).data('serial'); + const selectedUrl = $(this).data('url'); + + + // 响应式提示框 + const msgSettings = isMobile ? { + area: ['80vw', 'auto'], + time: 4000 + } : { + area: ['400px', 'auto'], + time: 3000 + }; + const downloadLoading = layer.msg('正在提交下载任务...', {icon: 16, time: 0}); + fetch('/api/download', { + method: 'POST', + headers: { + 'Authorization': token, + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ + name: serial, + url: selectedUrl + }) + }) + .then(response => { + if (!response.ok) { + throw new Error('下载任务提交失败'); + } + return response.json(); + }) + .then(data => { + layer.close(downloadLoading); + if (data.code === 200) { + layer.msg('下载任务提交成功', {icon: 1}); + // 关闭所有弹出层 + layer.closeAll(); + // 重新加载任务列表 + initTaskList(); + } else { + layer.msg('下载任务提交失败: ' + data.msg, {icon: 2}); + } + }) + .catch(error => { + layer.close(downloadLoading); + layer.msg('下载任务提交失败: ' + error.message, {icon: 2}); + }); + }); + }, + yes: function(index) { + layer.close(index); + } + }); }) .catch(error => { - console.log('错误信息:', error); - layer.msg('添加任务失败: ' + error.message); + layer.close(loadingIndex); + layer.msg('添加任务失败: ' + error.message, { icon: 2, time: 2000 }); }); }); }); + + initTaskList(); }); diff --git a/docker/nginx.conf b/docker/nginx.conf index 8314572..315be36 100644 --- a/docker/nginx.conf +++ b/docker/nginx.conf @@ -13,7 +13,7 @@ http { default $remote_addr; } server { - listen 4560; + listen 80; server_name localhost; client_header_buffer_size 64k; large_client_header_buffers 8 128k;