feat(ui): 优化上传交互与首页样式

This commit is contained in:
肖应宇 2026-04-13 17:56:20 +08:00
parent f0fb54e41f
commit b7a9f8da9b
3 changed files with 1940 additions and 1406 deletions

3240
index.html

File diff suppressed because it is too large Load Diff

View File

@ -724,8 +724,24 @@ function setupEventListeners() {
dropZone.addEventListener('dragover', handleDragOver); dropZone.addEventListener('dragover', handleDragOver);
dropZone.addEventListener('dragleave', handleDragLeave); dropZone.addEventListener('dragleave', handleDragLeave);
dropZone.addEventListener('drop', handleDrop); dropZone.addEventListener('drop', handleDrop);
browseBtn.addEventListener('click', () => { if (!isProcessing) fileInput.click(); }); dropZone.addEventListener('click', (event) => {
fileInput.addEventListener('change', handleFileSelect); if (isProcessing) return;
// 点击上传区空白区域时触发文件选择;避免与内部按钮重复触发。
if (event.target.closest('button, a, input, label, select, textarea')) return;
if (browseBtn) {
browseBtn.click();
return;
}
if (fileInput) {
fileInput.click();
}
});
if (browseBtn && fileInput) {
browseBtn.addEventListener('click', () => { if (!isProcessing) fileInput.click(); });
}
if (fileInput) {
fileInput.addEventListener('change', handleFileSelect);
}
if (browseFolderBtn && folderInput) { if (browseFolderBtn && folderInput) {
browseFolderBtn.addEventListener('click', () => { if (!isProcessing) folderInput.click(); }); browseFolderBtn.addEventListener('click', () => { if (!isProcessing) folderInput.click(); });
} }
@ -1131,6 +1147,18 @@ function refreshFormatFilters() {
// XSS 防护:转义文件扩展名,防止恶意文件名注入 // XSS 防护:转义文件扩展名,防止恶意文件名注入
const safeExt = escapeHtml(ext); const safeExt = escapeHtml(ext);
const safeLabel = escapeHtml(label); const safeLabel = escapeHtml(label);
if ((ext || '').toLowerCase() === 'pdf') {
excludedExtensions.delete(ext);
fragments.push(`
<!--
<label class="flex items-center space-x-1 bg-white border border-gray-200 rounded px-2 py-1 shadow-sm">
<input type="checkbox" class="format-filter-checkbox" data-ext="${safeExt}" ${checked}>
<span>${safeLabel} <span class="text-gray-400">(${count})</span></span>
</label>
-->
`);
return;
}
fragments.push(` fragments.push(`
<label class="flex items-center space-x-1 bg-white border border-gray-200 rounded px-2 py-1 shadow-sm"> <label class="flex items-center space-x-1 bg-white border border-gray-200 rounded px-2 py-1 shadow-sm">
<input type="checkbox" class="format-filter-checkbox" data-ext="${safeExt}" ${checked}> <input type="checkbox" class="format-filter-checkbox" data-ext="${safeExt}" ${checked}>
@ -1140,6 +1168,10 @@ function refreshFormatFilters() {
}); });
// fragments.push('<div class="flex-grow"></div><button type="button" id="resetFormatFilters" class="text-xs text-blue-600">重置</button>'); // fragments.push('<div class="flex-grow"></div><button type="button" id="resetFormatFilters" class="text-xs text-blue-600">重置</button>');
if (fragments.length === 0) {
container.innerHTML = '';
return;
}
container.innerHTML = `<div class="flex flex-wrap gap-2 items-center">${fragments.join('')}</div>`; container.innerHTML = `<div class="flex flex-wrap gap-2 items-center">${fragments.join('')}</div>`;
} }

View File

@ -63,22 +63,22 @@
<div class="flex items-center overflow-hidden mr-2"> <div class="flex items-center overflow-hidden mr-2">
<iconify-icon icon="${icon}" class="${iconColor} mr-2 flex-shrink-0" width="20"></iconify-icon> <iconify-icon icon="${icon}" class="${iconColor} mr-2 flex-shrink-0" width="20"></iconify-icon>
<span class="flex flex-col overflow-hidden"> <span class="flex flex-col overflow-hidden">
<span class="text-sm text-gray-800 truncate" title="${displayName}">${displayName}</span> <span class="truncate text-[13px] text-[#999999]" title="${displayName} (${global.formatFileSize(file.size)})">${displayName} (${global.formatFileSize(file.size)})</span>
${displayPath && displayPath !== displayName ? `<span class="text-[11px] text-gray-500 truncate" title="${displayPath}">${displayPath}</span>` : ''} ${displayPath && displayPath !== displayName ? `<span class="text-[11px] text-gray-500 truncate" title="${displayPath}">${displayPath}</span>` : ''}
</span> </span>
${virtualBadge} ${virtualBadge}
${isExcluded ? '<span class="ml-2 inline-block text-[10px] px-1.5 py-0.5 rounded bg-gray-200 text-gray-600 flex-shrink-0">已排除</span>' : ''} ${isExcluded ? '<span class="ml-2 inline-block text-[10px] px-1.5 py-0.5 rounded bg-gray-200 text-gray-600 flex-shrink-0">已排除</span>' : ''}
<span class="text-xs text-gray-500 ml-2 flex-shrink-0">(${global.formatFileSize(file.size)})</span>
</div> </div>
<div class="flex items-center gap-2 flex-shrink-0"> <div class="flex items-center gap-2 flex-shrink-0">
<button data-index="${index}" class="preview-file-btn text-gray-400 hover:text-blue-600 flex-shrink-0" title="预览">
<iconify-icon icon="carbon:search" width="16"></iconify-icon>
</button>
<button data-index="${index}" class="remove-file-btn text-gray-400 hover:text-red-600 flex-shrink-0" title="移除"> <button data-index="${index}" class="remove-file-btn text-gray-400 hover:text-red-600 flex-shrink-0" title="移除">
<iconify-icon icon="carbon:close" width="16"></iconify-icon> <iconify-icon icon="carbon:close" width="16"></iconify-icon>
</button> </button>
</div> </div>
`; `;
/* <button data-index="${index}" class="preview-file-btn text-gray-400 hover:text-blue-600 flex-shrink-0" title="">
<iconify-icon icon="carbon:search" width="16"></iconify-icon>
</button>*/
if (isExcluded) { if (isExcluded) {
listItem.classList.add('opacity-60'); listItem.classList.add('opacity-60');
} }