fix bug
This commit is contained in:
@@ -26,7 +26,8 @@ from dialogs_tkinter import (CreatePartitionDialog, MountDialog, CreateRaidDialo
|
||||
from dialogs_smart import SmartInfoDialog, SmartOverviewDialog
|
||||
from smart_monitor import SmartMonitor
|
||||
# 导入增强对话框
|
||||
from dialogs_enhanced import EnhancedFormatDialog, EnhancedRaidDeleteDialog, EnhancedPartitionDialog
|
||||
from dialogs_enhanced import (EnhancedFormatDialog, EnhancedRaidDeleteDialog,
|
||||
EnhancedPartitionDialog, DependencyCheckDialog)
|
||||
|
||||
|
||||
class MainWindow:
|
||||
@@ -138,6 +139,8 @@ class MainWindow:
|
||||
# 帮助菜单
|
||||
help_menu = tk.Menu(menubar, tearoff=0)
|
||||
menubar.add_cascade(label="帮助", menu=help_menu)
|
||||
help_menu.add_command(label="依赖检查", command=self._show_dependency_check)
|
||||
help_menu.add_separator()
|
||||
help_menu.add_command(label="关于", command=self._show_about)
|
||||
|
||||
def _show_about(self):
|
||||
@@ -155,6 +158,10 @@ class MainWindow:
|
||||
"使用 Python 3.6+ 和 Tkinter 构建"
|
||||
)
|
||||
|
||||
def _show_dependency_check(self):
|
||||
"""显示依赖检查对话框"""
|
||||
DependencyCheckDialog(self.root)
|
||||
|
||||
def _create_block_devices_tree(self):
|
||||
"""创建块设备 Treeview"""
|
||||
# 创建框架
|
||||
@@ -407,6 +414,48 @@ class MainWindow:
|
||||
menu.add_command(label=f"擦除分区表 {device_path}...",
|
||||
command=lambda: self._handle_wipe_partition_table(device_path))
|
||||
menu.add_separator()
|
||||
|
||||
# 检查磁盘状态
|
||||
has_children = dev_data.get('children') is not None and len(dev_data.get('children', [])) > 0
|
||||
fstype = dev_data.get('fstype', '')
|
||||
|
||||
# 如果磁盘有文件系统(直接格式化的物理盘),添加挂载/卸载/格式化操作
|
||||
if fstype and fstype not in ['LVM2_member', 'linux_raid_member']:
|
||||
if not mount_point or mount_point == '' or mount_point == 'N/A':
|
||||
menu.add_command(label=f"挂载 {device_path}...",
|
||||
command=lambda: self._handle_mount(device_path))
|
||||
else:
|
||||
menu.add_command(label=f"卸载 {device_path}",
|
||||
command=lambda: self._unmount_and_refresh(device_path))
|
||||
menu.add_separator()
|
||||
|
||||
# 格式化物理盘
|
||||
menu.add_command(label=f"格式化物理盘 {device_path}...",
|
||||
command=lambda dp=device_path, dd=dev_data: self._handle_format_partition(dp, dd))
|
||||
|
||||
# 文件系统工具
|
||||
fs_menu = tk.Menu(menu, tearoff=0)
|
||||
if fstype.startswith('ext'):
|
||||
fs_menu.add_command(label=f"检查文件系统 (fsck) {device_path}",
|
||||
command=lambda dp=device_path, ft=fstype: self._handle_fsck(dp, ft))
|
||||
fs_menu.add_command(label=f"调整文件系统大小 (resize2fs) {device_path}",
|
||||
command=lambda dp=device_path, ft=fstype: self._handle_resize2fs(dp, ft))
|
||||
elif fstype == 'xfs':
|
||||
fs_menu.add_command(label=f"修复文件系统 (xfs_repair) {device_path}",
|
||||
command=lambda dp=device_path: self._handle_xfs_repair(dp))
|
||||
elif fstype.lower() == 'ntfs':
|
||||
fs_menu.add_command(label=f"修复文件系统 (ntfsfix) {device_path}",
|
||||
command=lambda dp=device_path: self._handle_ntfsfix(dp))
|
||||
if fs_menu.index(tk.END) is not None:
|
||||
menu.add_cascade(label=f"文件系统工具 {device_path}", menu=fs_menu)
|
||||
|
||||
menu.add_separator()
|
||||
elif not has_children:
|
||||
# 没有文件系统、没有子分区的空物理盘,可以直接格式化
|
||||
menu.add_command(label=f"直接格式化物理盘 {device_path}...",
|
||||
command=lambda dp=device_path, dd=dev_data: self._handle_format_partition(dp, dd))
|
||||
menu.add_separator()
|
||||
|
||||
# SMART 信息
|
||||
menu.add_command(label=f"查看 SMART 信息 {device_path}",
|
||||
command=lambda: self._handle_show_smart(device_path))
|
||||
@@ -1092,8 +1141,17 @@ class MainWindow:
|
||||
self.refresh_all_info()
|
||||
|
||||
def _handle_format_raid_array(self, array_path):
|
||||
"""处理格式化 RAID 阵列"""
|
||||
self.disk_ops.format_partition(array_path)
|
||||
"""处理格式化 RAID 阵列 - 使用增强型对话框"""
|
||||
# 获取设备信息
|
||||
dev_data = self.system_manager.get_device_details_by_path(array_path)
|
||||
|
||||
# 使用增强型格式化对话框
|
||||
dialog = EnhancedFormatDialog(self.root, array_path, dev_data or {})
|
||||
fs_type = dialog.wait_for_result()
|
||||
|
||||
if fs_type:
|
||||
# 执行格式化
|
||||
self.disk_ops.format_partition(array_path, fs_type)
|
||||
|
||||
# === LVM 处理函数 ===
|
||||
def refresh_lvm_info(self):
|
||||
|
||||
Reference in New Issue
Block a user