新增功能:支持单独删除分析列表中的文件
This commit is contained in:
+25
-1
@@ -356,11 +356,35 @@ function renderFileList(files) {
|
||||
elements.fileSelector.style.display = 'flex';
|
||||
elements.fileList.innerHTML = files.map(f => `
|
||||
<div class="file-tag ${f.filename === state.currentFile ? 'active' : ''}" onclick="loadFile('${f.filename}')">
|
||||
${f.original_name}
|
||||
<span class="file-name">${f.original_name}</span>
|
||||
<i class="fas fa-times delete-file-btn" onclick="deleteFile('${f.filename}', event)" title="删除此文件"></i>
|
||||
</div>
|
||||
`).join('');
|
||||
}
|
||||
|
||||
function deleteFile(filename, event) {
|
||||
if (event) event.stopPropagation();
|
||||
if (!confirm('确认删除此文件?')) return;
|
||||
|
||||
fetch(`/delete/${filename}`, { method: 'POST' })
|
||||
.then(res => res.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
if (state.currentFile === filename) {
|
||||
state.currentFile = null;
|
||||
state.allData = null;
|
||||
state.filteredData = null;
|
||||
elements.noData.style.display = 'flex';
|
||||
elements.dataDisplay.style.display = 'none';
|
||||
}
|
||||
loadFileList();
|
||||
} else {
|
||||
alert(data.error || '删除失败');
|
||||
}
|
||||
})
|
||||
.catch(err => alert('删除错误: ' + err.message));
|
||||
}
|
||||
|
||||
// --- Utils ---
|
||||
|
||||
function openUploadModal() {
|
||||
|
||||
Reference in New Issue
Block a user