(action)
| 311 | |
| 312 | // 批量操作 |
| 313 | async batchAction(action) { |
| 314 | const selectedFiles = Array.from(this.selectedFiles); |
| 315 | |
| 316 | if (selectedFiles.length === 0) { |
| 317 | showStatus('请先选择要操作的文件', 'error'); |
| 318 | return; |
| 319 | } |
| 320 | |
| 321 | const actionNames = { |
| 322 | enable: '启用', |
| 323 | disable: '禁用', |
| 324 | delete: '删除', |
| 325 | enable_credit: '开启积分', |
| 326 | disable_credit: '关闭积分' |
| 327 | }; |
| 328 | const actionLabel = actionNames[action] || action; |
| 329 | const confirmMsg = action === 'delete' |
| 330 | ? `确定要删除选中的 ${selectedFiles.length} 个文件吗?\n注意:此操作不可恢复!` |
| 331 | : `确定要${actionLabel}选中的 ${selectedFiles.length} 个文件吗?`; |
| 332 | |
| 333 | if (!confirm(confirmMsg)) return; |
| 334 | |
| 335 | try { |
| 336 | showStatus(`正在执行批量${actionLabel}操作...`, 'info'); |
| 337 | |
| 338 | const response = await fetch(`${this.getEndpoint('batchAction')}?${this.getModeParam()}`, { |
| 339 | method: 'POST', |
| 340 | headers: getAuthHeaders(), |
| 341 | body: JSON.stringify({ action, filenames: selectedFiles }) |
| 342 | }); |
| 343 | |
| 344 | const data = await response.json(); |
| 345 | |
| 346 | if (response.ok) { |
| 347 | const successCount = data.success_count || data.succeeded; |
| 348 | showStatus(`批量操作完成:成功处理 ${successCount}/${selectedFiles.length} 个文件`, 'success'); |
| 349 | this.selectedFiles.clear(); |
| 350 | this.updateBatchControls(); |
| 351 | await this.refresh(); |
| 352 | } else { |
| 353 | showStatus(`批量操作失败: ${data.detail || data.error || '未知错误'}`, 'error'); |
| 354 | } |
| 355 | } catch (error) { |
| 356 | showStatus(`批量操作网络错误: ${error.message}`, 'error'); |
| 357 | } |
| 358 | } |
| 359 | }; |
| 360 | } |
| 361 |
nothing calls this directly
no test coverage detected