()
| 2391 | } |
| 2392 | //选中下载 |
| 2393 | async function downloadSelectedFiles() { |
| 2394 | // 获取所有选中的复选框 |
| 2395 | const checkboxes = document.querySelectorAll('input[name="fileCheckbox"]:checked') |
| 2396 | if (checkboxes.length === 0) { |
| 2397 | showModal('没有选中的文件', 2000) |
| 2398 | return |
| 2399 | } |
| 2400 | // 创建一个 JSZip 实例 |
| 2401 | const zip = new JSZip() |
| 2402 | |
| 2403 | try { |
| 2404 | // 遍历所有选中的复选框 |
| 2405 | for (const checkbox of checkboxes) { |
| 2406 | // 获取文件项信息 |
| 2407 | const fileItem = checkbox.closest('li') |
| 2408 | const fileName = fileItem.querySelector('a[data-display-name]').dataset.displayName |
| 2409 | |
| 2410 | // 调用 downloadFile 函数,将文件添加到压缩包中 |
| 2411 | await downloadFile(webdavfold, fileName, zip) |
| 2412 | } |
| 2413 | |
| 2414 | // 生成 ZIP 文件 |
| 2415 | const zipBlob = await zip.generateAsync({ type: 'blob' }) |
| 2416 | |
| 2417 | // 创建下载链接并触发下载 |
| 2418 | const zipUrl = URL.createObjectURL(zipBlob) |
| 2419 | const a = document.createElement('a') |
| 2420 | a.href = zipUrl |
| 2421 | a.download = 'selected_files.zip' |
| 2422 | a.click() |
| 2423 | |
| 2424 | console.log('压缩包下载完成') |
| 2425 | showModal('下载选中完成:', 2000) |
| 2426 | } catch (error) { |
| 2427 | console.error('下载选中文件失败:', error) |
| 2428 | showModal('下载选中文件失败: ' + error.message, 2000) |
| 2429 | |
| 2430 | } |
| 2431 | } |
| 2432 | |
| 2433 | //选中删除 |
| 2434 | function deleteSelectedFiles() { |
nothing calls this directly
no test coverage detected