Update index.html

This commit is contained in:
公明 2025-06-07 12:15:43 +08:00 committed by GitHub
parent 9b172c3555
commit 7e11dd934b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -269,6 +269,22 @@
box-shadow: 0 4px 8px rgba(74, 144, 226, 0.3); box-shadow: 0 4px 8px rgba(74, 144, 226, 0.3);
} }
.export-btn {
background: #2ecc71;
color: white;
border: none;
border-radius: 5px;
padding: 8px 20px;
cursor: pointer;
margin-left: 10px;
transition: all 0.3s ease;
}
.export-btn:hover {
background: #27ae60;
transform: translateY(-2px);
box-shadow: 0 4px 8px rgba(46, 204, 113, 0.3);
}
.empty-state { .empty-state {
text-align: center; text-align: center;
padding: 50px 20px; padding: 50px 20px;
@ -488,6 +504,7 @@
<option value="false">安全请求</option> <option value="false">安全请求</option>
</select> </select>
<button class="filter-btn" onclick="filterData()">筛选</button> <button class="filter-btn" onclick="filterData()">筛选</button>
<button class="export-btn" onclick="exportToExcel()">导出Excel</button>
</div> </div>
</div> </div>
@ -700,6 +717,50 @@
fetchData(1, itemsPerPage, document.getElementById('filter-result').value); fetchData(1, itemsPerPage, document.getElementById('filter-result').value);
}); });
// 导出Excel功能
async function exportToExcel() {
try {
document.body.style.cursor = 'wait';
// 获取当前筛选条件
const resultFilter = document.getElementById('filter-result').value;
// 调用后端导出接口
const response = await fetch(`/export?result=${resultFilter}`);
if (!response.ok) {
throw new Error('导出失败');
}
// 将响应转换为blob
const blob = await response.blob();
// 创建一个临时下载链接
const url = window.URL.createObjectURL(blob);
const a = document.createElement('a');
a.style.display = 'none';
a.href = url;
// 设置文件名
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
const filename = `PrivHunterAI-扫描结果-${timestamp}.xlsx`;
a.download = filename;
// 触发下载
document.body.appendChild(a);
a.click();
// 清理
window.URL.revokeObjectURL(url);
document.body.removeChild(a);
} catch (error) {
alert('导出失败: ' + error.message);
} finally {
document.body.style.cursor = 'default';
}
}
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
fetchData(); fetchData();