MCPcopy Create free account
hub / github.com/aaPanel/BaoTa / disk_clean_menu

Method disk_clean_menu

script/btcli.py:1652–1733  ·  view source on GitHub ↗

磁盘清理菜单

(self)

Source from the content-addressed store, hash-verified

1650 print(Colors.error("无效的选择"))
1651
1652 def disk_clean_menu(self):
1653 """磁盘清理菜单"""
1654 while True:
1655 print("\n" + "-"*50)
1656 print(Colors.info(" 磁盘清理管理"))
1657 print("-"*50)
1658 print(" 1. 扫描磁盘空间")
1659 print(" 2. 查看扫描结果")
1660 print(" 3. 清理日志/缓存/临时文件(需先扫描磁盘空间)")
1661 print(" 0. 返回上级")
1662 print("-"*50)
1663
1664 choice = input("\n请选择操作 [0-3]: ").strip()
1665
1666 if choice == '1':
1667 print(Colors.info("\n开始扫描磁盘空间..."))
1668 print(Colors.warning("提示: 扫描可能需要一些时间,请耐心等待"))
1669 print("-" * 50)
1670
1671 start_time = time.time()
1672 self.clean_mgr.scan_all(show_progress=True)
1673 elapsed_time = time.time() - start_time
1674
1675 print(Colors.success(f"\n✓ 扫描完成! 耗时: {elapsed_time:.2f} 秒"))
1676 self.clean_mgr.show_scan_results()
1677
1678 elif choice == '2':
1679 if not self.clean_mgr.scan_results:
1680 print(Colors.warning("\n暂无扫描结果,请先执行扫描"))
1681 else:
1682 self.clean_mgr.show_scan_results()
1683
1684 elif choice == '3':
1685 if not self.clean_mgr.scan_results:
1686 print(Colors.warning("\n请先执行扫描"))
1687 continue
1688
1689 if not self.clean_mgr.item_index_map:
1690 print(Colors.warning("\n请先查看扫描结果"))
1691 continue
1692
1693 print(Colors.info("\n清理磁盘空间"))
1694 print(Colors.warning("提示: 请输入要清理的项目编号,多个编号用逗号或空格分隔"))
1695 print(Colors.warning(" 例如: 1,2,3 或 1 2 3"))
1696
1697 numbers_input = input("\n请输入编号 (输入 'all' 清理所有启用项): ").strip()
1698
1699 if not numbers_input:
1700 print(Colors.warning("未输入编号,已取消"))
1701 continue
1702
1703 if numbers_input.lower() == 'all':
1704 # 清理所有启用项
1705 enabled_numbers = [
1706 num for num, item in self.clean_mgr.item_index_map.items()
1707 if item['result']['status']
1708 ]
1709

Callers 1

show_main_menuMethod · 0.95

Calls 11

timeMethod · 0.80
scan_allMethod · 0.80
show_scan_resultsMethod · 0.80
clean_by_numbersMethod · 0.80
infoMethod · 0.45
warningMethod · 0.45
successMethod · 0.45
itemsMethod · 0.45
replaceMethod · 0.45
splitMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected