()
| 2308 | //搜索 |
| 2309 | //--------------- |
| 2310 | function toggleSearch() { |
| 2311 | if (searchButton.textContent === '搜索列表') { |
| 2312 | // 如果当前是搜索状态,则进行搜索 |
| 2313 | const searchTerm = prompt('请输入搜索内容:') // 弹出输入框等待用户输入搜索内容 |
| 2314 | if (searchTerm !== null) { // 用户点击了确定按钮 |
| 2315 | filterFiles(searchTerm) // 调用过滤文件函数,传入搜索关键词 |
| 2316 | searchButton.textContent = '回到列表' // 将搜索按钮文本改为"Back" |
| 2317 | } |
| 2318 | } else { |
| 2319 | // 如果当前是Back状态,则恢复初始文件列表 |
| 2320 | resetFileList() |
| 2321 | } |
| 2322 | } |
| 2323 | |
| 2324 | function filterFiles(searchTerm) { |
| 2325 | const files = Array.from(fileListContainer.children) // 获取文件列表的所有子元素(文件项) |
nothing calls this directly
no test coverage detected