添加查看上传记录页面

This commit is contained in:
luke 2025-06-17 10:45:01 +08:00
parent 140d41d7a3
commit d8b6b7b689
5 changed files with 184 additions and 2 deletions

View File

@ -1,7 +1,7 @@
{
"manifest_version": 3,
"name": "渠道应用开发部知识库",
"version": "2.0.6",
"version": "2.0.7",
"description": "通过关键词快速搜索内部文档",
"permissions": ["storage"],
"host_permissions": [

109
pages/upload-history.html Normal file
View File

@ -0,0 +1,109 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>上传记录</title>
<style>
body {
font-family: system-ui, sans-serif;
background: #f9fbfc;
margin: 0;
padding: 20px;
}
.history-wrapper {
max-width: 960px;
margin: auto;
background: #fff;
padding: 24px 30px;
border-radius: 12px;
box-shadow: 0 6px 20px #ccc5;
}
h2 {
font-size: 1.3rem;
margin-bottom: 20px;
color: #1a2b57;
}
table {
width: 100%;
border-collapse: collapse;
margin-bottom: 20px;
table-layout: fixed;
}
th, td {
text-align: left;
padding: 8px 12px;
border-bottom: 1px solid #e1e4ec;
word-break: break-word;
}
th {
background: #f2f4f7;
color: #333;
}
td a {
color: #2266cc;
text-decoration: none;
}
td a:hover {
text-decoration: underline;
}
.pagination {
text-align: center;
margin-top: 10px;
}
.pagination button {
margin: 0 3px;
padding: 6px 10px;
background: #f0f3f7;
border: 1px solid #ccc;
border-radius: 5px;
cursor: pointer;
}
.pagination button.active {
background: #3d5afe;
color: #fff;
}
.pagination button:hover:not(.active) {
background: #dce4f7;
}
.page-size {
margin-top: 10px;
text-align: right;
font-size: 14px;
}
.page-size select {
padding: 4px 8px;
font-size: 14px;
}
</style>
</head>
<body>
<div class="history-wrapper">
<h2>上传记录</h2>
<table>
<thead>
<tr>
<th style="width: 60%;">文件名</th>
<th style="width: 20%;">上传时间</th>
<th style="width: 20%;">有效期</th>
</tr>
</thead>
<tbody id="historyTableBody">
<!-- JS 填充记录 -->
</tbody>
</table>
<div class="pagination" id="pagination"></div>
<div class="page-size">
每页显示
<select id="pageSizeSelect">
<option value="10">10</option>
<option value="20">20</option>
<option value="50">50</option>
</select> 条记录
</div>
</div>
<script src="../scripts/upload-history.js"></script>
</body>
</html>

View File

@ -72,7 +72,9 @@
<div id="uploadList"></div>
</div>
<div class="result-panel">
<h3>上传结果 JSON</h3>
<h3>上传结果 JSON
<a href="upload-history.html" target="_blank" style="font-size: 13px; color: #2563eb; text-decoration: none; padding: 10px">查看历史上传记录 ↗</a>
</h3>
<pre id="jsonResult" class="json-box"></pre>
</div>
</div>

View File

@ -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 | 完成上传记录展示 |

70
scripts/upload-history.js Normal file
View File

@ -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 = `<td colspan="3">暂无记录</td>`;
tableBody.appendChild(tr);
return;
}
records.forEach(rec => {
const tr = document.createElement("tr");
tr.innerHTML = `
<td><a href="${rec.url}" target="_blank">${rec.fileName}</a></td>
<td>${rec.uploadTime}</td>
<td>${rec.daysRemaining}</td>
`;
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);
});