diff --git a/manifest.json b/manifest.json index ec102af..a0a64f0 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 3, "name": "渠道应用开发部知识库", - "version": "2.0.6", + "version": "2.0.7", "description": "通过关键词快速搜索内部文档", "permissions": ["storage"], "host_permissions": [ diff --git a/pages/upload-history.html b/pages/upload-history.html new file mode 100644 index 0000000..d4a60e7 --- /dev/null +++ b/pages/upload-history.html @@ -0,0 +1,109 @@ + + + + + 上传记录 + + + +
+

上传记录

+ + + + + + + + + + + +
文件名上传时间有效期
+ + + +
+ 每页显示 + 条记录 +
+
+ + + + diff --git a/pages/uploader.html b/pages/uploader.html index 403fd92..070cf8f 100644 --- a/pages/uploader.html +++ b/pages/uploader.html @@ -72,7 +72,9 @@
-

上传结果 JSON

+

上传结果 JSON + 查看历史上传记录 ↗ +


     
diff --git a/readme.md b/readme.md index d062c17..62eeb1d 100644 --- a/readme.md +++ b/readme.md @@ -10,4 +10,5 @@ | 2025.06.09 | V2.0.4 | Luke.Ye | 优化es搜索展示页面 | | 2025.06.10 | V2.0.5 | Luke.Ye | 移除自动请求智能助手逻辑 | | 2025.06.16 | V2.0.6 | Luke.Ye | 添加上传文件到对象存储功能 | +| 2025.06.17 | V2.0.7 | Luke.Ye | 完成上传记录展示 | diff --git a/scripts/upload-history.js b/scripts/upload-history.js new file mode 100644 index 0000000..f368e3b --- /dev/null +++ b/scripts/upload-history.js @@ -0,0 +1,70 @@ +const API_HISTORY = "http://app.wisdompulse.cn/api/v1/doc/fetch-os-upload-history"; + +const tableBody = document.getElementById("historyTableBody"); +const pagination = document.getElementById("pagination"); +const pageSizeSelect = document.getElementById("pageSizeSelect"); + +let currentPage = 1; +let total = 0; +let pageSize = parseInt(pageSizeSelect.value); + +function loadUploadHistory(page = 1, size = 10) { + const url = `${API_HISTORY}?page=${page}&size=${size}`; + fetch(url) + .then(res => res.json()) + .then(data => { + renderTable(data.records || []); + renderPagination(data.total || 0, page, size); + }) + .catch(err => { + console.error("加载上传记录失败:", err); + }); +} + +function renderTable(records) { + tableBody.innerHTML = ""; + if (!records.length) { + const tr = document.createElement("tr"); + tr.innerHTML = `暂无记录`; + tableBody.appendChild(tr); + return; + } + + records.forEach(rec => { + const tr = document.createElement("tr"); + tr.innerHTML = ` + ${rec.fileName} + ${rec.uploadTime} + ${rec.daysRemaining} + `; + tableBody.appendChild(tr); + }); +} + +function renderPagination(totalCount, current, size) { + pagination.innerHTML = ""; + total = totalCount; + const totalPages = Math.ceil(totalCount / size); + if (totalPages <= 1) return; + + for (let i = 1; i <= totalPages; i++) { + const btn = document.createElement("button"); + btn.textContent = i; + if (i === current) btn.classList.add("active"); + btn.onclick = () => { + currentPage = i; + loadUploadHistory(currentPage, pageSize); + }; + pagination.appendChild(btn); + } +} + +pageSizeSelect.addEventListener("change", () => { + pageSize = parseInt(pageSizeSelect.value); + currentPage = 1; + loadUploadHistory(currentPage, pageSize); +}); + +window.addEventListener("DOMContentLoaded", () => { + loadUploadHistory(currentPage, pageSize); +});