Translate Chinese comments to English in File Manager components
- Complete translation of FileWindow.tsx comments and hardcoded text - Complete translation of DraggableWindow.tsx hardcoded text - Complete translation of FileManagerSidebar.tsx comments - Complete translation of FileManagerGrid.tsx comments and UI text - Complete translation of DiffViewer.tsx hardcoded text with proper i18n - Partial translation of FileManagerModern.tsx comments (major sections done) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -107,7 +107,7 @@ export function FileManagerContextMenu({
|
||||
useEffect(() => {
|
||||
if (!isVisible) return;
|
||||
|
||||
// 调整菜单位置避免超出屏幕
|
||||
// Adjust menu position to avoid going off screen
|
||||
const adjustPosition = () => {
|
||||
const menuWidth = 200;
|
||||
const menuHeight = 300;
|
||||
@@ -130,13 +130,13 @@ export function FileManagerContextMenu({
|
||||
|
||||
adjustPosition();
|
||||
|
||||
// 延迟添加事件监听器,避免捕获到触发菜单的那次点击
|
||||
// Delay adding event listeners to avoid capturing the click that triggered the menu
|
||||
let cleanupFn: (() => void) | null = null;
|
||||
|
||||
const timeoutId = setTimeout(() => {
|
||||
// 点击外部关闭菜单
|
||||
// Click outside to close menu
|
||||
const handleClickOutside = (event: MouseEvent) => {
|
||||
// 检查点击是否在菜单内部
|
||||
// Check if click is inside menu
|
||||
const target = event.target as Element;
|
||||
const menuElement = document.querySelector("[data-context-menu]");
|
||||
|
||||
@@ -145,13 +145,13 @@ export function FileManagerContextMenu({
|
||||
}
|
||||
};
|
||||
|
||||
// 右键点击关闭菜单(Windows行为)
|
||||
// Right-click to close menu (Windows behavior)
|
||||
const handleRightClick = (event: MouseEvent) => {
|
||||
event.preventDefault();
|
||||
onClose();
|
||||
};
|
||||
|
||||
// 键盘支持
|
||||
// Keyboard support
|
||||
const handleKeyDown = (event: KeyboardEvent) => {
|
||||
if (event.key === "Escape") {
|
||||
event.preventDefault();
|
||||
@@ -159,12 +159,12 @@ export function FileManagerContextMenu({
|
||||
}
|
||||
};
|
||||
|
||||
// 窗口失焦关闭菜单
|
||||
// Close menu on window blur
|
||||
const handleBlur = () => {
|
||||
onClose();
|
||||
};
|
||||
|
||||
// 滚动时关闭菜单(Windows行为)
|
||||
// Close menu on scroll (Windows behavior)
|
||||
const handleScroll = () => {
|
||||
onClose();
|
||||
};
|
||||
@@ -175,7 +175,7 @@ export function FileManagerContextMenu({
|
||||
window.addEventListener("blur", handleBlur);
|
||||
window.addEventListener("scroll", handleScroll, true);
|
||||
|
||||
// 设置清理函数
|
||||
// Set cleanup function
|
||||
cleanupFn = () => {
|
||||
document.removeEventListener("mousedown", handleClickOutside, true);
|
||||
document.removeEventListener("contextmenu", handleRightClick);
|
||||
@@ -183,7 +183,7 @@ export function FileManagerContextMenu({
|
||||
window.removeEventListener("blur", handleBlur);
|
||||
window.removeEventListener("scroll", handleScroll, true);
|
||||
};
|
||||
}, 50); // 50ms延迟,确保不会捕获到触发菜单的点击
|
||||
}, 50); // 50ms delay to ensure we don't capture the click that triggered the menu
|
||||
|
||||
return () => {
|
||||
clearTimeout(timeoutId);
|
||||
@@ -204,13 +204,13 @@ export function FileManagerContextMenu({
|
||||
(f) => f.type === "file" && f.executable,
|
||||
);
|
||||
|
||||
// 构建菜单项
|
||||
// Build menu items
|
||||
const menuItems: MenuItem[] = [];
|
||||
|
||||
if (isFileContext) {
|
||||
// 文件/文件夹选中时的菜单
|
||||
// Menu when files/folders are selected
|
||||
|
||||
// 打开终端功能 - 支持文件和文件夹
|
||||
// Open terminal function - supports files and folders
|
||||
if (onOpenTerminal) {
|
||||
const targetPath = isSingleFile
|
||||
? files[0].type === "directory"
|
||||
@@ -229,7 +229,7 @@ export function FileManagerContextMenu({
|
||||
});
|
||||
}
|
||||
|
||||
// 运行可执行文件功能 - 仅对单个可执行文件显示
|
||||
// Run executable file function - only show for single executable files
|
||||
if (isSingleFile && hasExecutableFiles && onRunExecutable) {
|
||||
menuItems.push({
|
||||
icon: <Play className="w-4 h-4" />,
|
||||
@@ -239,7 +239,7 @@ export function FileManagerContextMenu({
|
||||
});
|
||||
}
|
||||
|
||||
// 添加分隔符(如果有上述功能)
|
||||
// Add separator (if above functions exist)
|
||||
if (
|
||||
onOpenTerminal ||
|
||||
(isSingleFile && hasExecutableFiles && onRunExecutable)
|
||||
@@ -247,7 +247,7 @@ export function FileManagerContextMenu({
|
||||
menuItems.push({ separator: true } as MenuItem);
|
||||
}
|
||||
|
||||
// 预览功能
|
||||
// Preview function
|
||||
if (hasFiles && onPreview) {
|
||||
menuItems.push({
|
||||
icon: <Eye className="w-4 h-4" />,
|
||||
@@ -257,7 +257,7 @@ export function FileManagerContextMenu({
|
||||
});
|
||||
}
|
||||
|
||||
// 下载功能
|
||||
// Download function
|
||||
if (hasFiles && onDownload) {
|
||||
menuItems.push({
|
||||
icon: <Download className="w-4 h-4" />,
|
||||
@@ -269,7 +269,7 @@ export function FileManagerContextMenu({
|
||||
});
|
||||
}
|
||||
|
||||
// 拖拽到桌面菜单项(支持浏览器和桌面应用)
|
||||
// Drag to desktop menu item (supports browser and desktop apps)
|
||||
if (hasFiles && onDragToDesktop) {
|
||||
const isModernBrowser = "showSaveFilePicker" in window;
|
||||
menuItems.push({
|
||||
@@ -284,7 +284,7 @@ export function FileManagerContextMenu({
|
||||
});
|
||||
}
|
||||
|
||||
// PIN/UNPIN 功能 - 仅对单个文件显示
|
||||
// PIN/UNPIN function - only show for single files
|
||||
if (isSingleFile && files[0].type === "file") {
|
||||
const isCurrentlyPinned = isPinned ? isPinned(files[0]) : false;
|
||||
|
||||
@@ -303,7 +303,7 @@ export function FileManagerContextMenu({
|
||||
}
|
||||
}
|
||||
|
||||
// 添加文件夹快捷方式 - 仅对单个文件夹显示
|
||||
// Add folder shortcut - only show for single folders
|
||||
if (isSingleFile && files[0].type === "directory" && onAddShortcut) {
|
||||
menuItems.push({
|
||||
icon: <Bookmark className="w-4 h-4" />,
|
||||
@@ -312,7 +312,7 @@ export function FileManagerContextMenu({
|
||||
});
|
||||
}
|
||||
|
||||
// 添加分隔符(如果有上述功能)
|
||||
// Add separator (if above functions exist)
|
||||
if (
|
||||
(hasFiles && (onPreview || onDownload || onDragToDesktop)) ||
|
||||
(isSingleFile &&
|
||||
@@ -323,7 +323,7 @@ export function FileManagerContextMenu({
|
||||
menuItems.push({ separator: true } as MenuItem);
|
||||
}
|
||||
|
||||
// 重命名功能
|
||||
// Rename function
|
||||
if (isSingleFile && onRename) {
|
||||
menuItems.push({
|
||||
icon: <Edit3 className="w-4 h-4" />,
|
||||
@@ -333,7 +333,7 @@ export function FileManagerContextMenu({
|
||||
});
|
||||
}
|
||||
|
||||
// 复制功能
|
||||
// Copy function
|
||||
if (onCopy) {
|
||||
menuItems.push({
|
||||
icon: <Copy className="w-4 h-4" />,
|
||||
@@ -345,7 +345,7 @@ export function FileManagerContextMenu({
|
||||
});
|
||||
}
|
||||
|
||||
// 剪切功能
|
||||
// Cut function
|
||||
if (onCut) {
|
||||
menuItems.push({
|
||||
icon: <Scissors className="w-4 h-4" />,
|
||||
@@ -357,12 +357,12 @@ export function FileManagerContextMenu({
|
||||
});
|
||||
}
|
||||
|
||||
// 添加分隔符(如果有编辑功能)
|
||||
// Add separator (if edit functions exist)
|
||||
if ((isSingleFile && onRename) || onCopy || onCut) {
|
||||
menuItems.push({ separator: true } as MenuItem);
|
||||
}
|
||||
|
||||
// 删除功能
|
||||
// Delete function
|
||||
if (onDelete) {
|
||||
menuItems.push({
|
||||
icon: <Trash2 className="w-4 h-4" />,
|
||||
@@ -375,12 +375,12 @@ export function FileManagerContextMenu({
|
||||
});
|
||||
}
|
||||
|
||||
// 添加分隔符(如果有删除功能)
|
||||
// Add separator (if delete function exists)
|
||||
if (onDelete) {
|
||||
menuItems.push({ separator: true } as MenuItem);
|
||||
}
|
||||
|
||||
// 属性功能
|
||||
// Properties function
|
||||
if (isSingleFile && onProperties) {
|
||||
menuItems.push({
|
||||
icon: <Info className="w-4 h-4" />,
|
||||
@@ -389,9 +389,9 @@ export function FileManagerContextMenu({
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// 空白区域右键菜单
|
||||
// Empty area right-click menu
|
||||
|
||||
// 在当前目录打开终端
|
||||
// Open terminal in current directory
|
||||
if (onOpenTerminal && currentPath) {
|
||||
menuItems.push({
|
||||
icon: <Terminal className="w-4 h-4" />,
|
||||
@@ -401,7 +401,7 @@ export function FileManagerContextMenu({
|
||||
});
|
||||
}
|
||||
|
||||
// 上传功能
|
||||
// Upload function
|
||||
if (onUpload) {
|
||||
menuItems.push({
|
||||
icon: <Upload className="w-4 h-4" />,
|
||||
@@ -411,12 +411,12 @@ export function FileManagerContextMenu({
|
||||
});
|
||||
}
|
||||
|
||||
// 添加分隔符(如果有终端或上传功能)
|
||||
// Add separator (if terminal or upload functions exist)
|
||||
if ((onOpenTerminal && currentPath) || onUpload) {
|
||||
menuItems.push({ separator: true } as MenuItem);
|
||||
}
|
||||
|
||||
// 新建文件夹
|
||||
// New folder
|
||||
if (onNewFolder) {
|
||||
menuItems.push({
|
||||
icon: <FolderPlus className="w-4 h-4" />,
|
||||
@@ -426,7 +426,7 @@ export function FileManagerContextMenu({
|
||||
});
|
||||
}
|
||||
|
||||
// 新建文件
|
||||
// New file
|
||||
if (onNewFile) {
|
||||
menuItems.push({
|
||||
icon: <FilePlus className="w-4 h-4" />,
|
||||
@@ -436,12 +436,12 @@ export function FileManagerContextMenu({
|
||||
});
|
||||
}
|
||||
|
||||
// 添加分隔符(如果有新建功能)
|
||||
// Add separator (if new functions exist)
|
||||
if (onNewFolder || onNewFile) {
|
||||
menuItems.push({ separator: true } as MenuItem);
|
||||
}
|
||||
|
||||
// 刷新功能
|
||||
// Refresh function
|
||||
if (onRefresh) {
|
||||
menuItems.push({
|
||||
icon: <RefreshCw className="w-4 h-4" />,
|
||||
@@ -451,7 +451,7 @@ export function FileManagerContextMenu({
|
||||
});
|
||||
}
|
||||
|
||||
// 粘贴功能
|
||||
// Paste function
|
||||
if (hasClipboard && onPaste) {
|
||||
menuItems.push({
|
||||
icon: <Clipboard className="w-4 h-4" />,
|
||||
@@ -462,15 +462,15 @@ export function FileManagerContextMenu({
|
||||
}
|
||||
}
|
||||
|
||||
// 过滤掉连续的分隔符
|
||||
// Filter out consecutive separators
|
||||
const filteredMenuItems = menuItems.filter((item, index) => {
|
||||
if (!item.separator) return true;
|
||||
|
||||
// 如果是分隔符,检查前一个和后一个是否也是分隔符
|
||||
// If it's a separator, check if previous and next are also separators
|
||||
const prevItem = index > 0 ? menuItems[index - 1] : null;
|
||||
const nextItem = index < menuItems.length - 1 ? menuItems[index + 1] : null;
|
||||
|
||||
// 如果前一个或后一个是分隔符,则过滤掉当前分隔符
|
||||
// If previous or next is a separator, filter out current separator
|
||||
if (prevItem?.separator || nextItem?.separator) {
|
||||
return false;
|
||||
}
|
||||
@@ -478,7 +478,7 @@ export function FileManagerContextMenu({
|
||||
return true;
|
||||
});
|
||||
|
||||
// 移除开头和结尾的分隔符
|
||||
// Remove separators at beginning and end
|
||||
const finalMenuItems = filteredMenuItems.filter((item, index) => {
|
||||
if (!item.separator) return true;
|
||||
return index > 0 && index < filteredMenuItems.length - 1;
|
||||
@@ -486,10 +486,10 @@ export function FileManagerContextMenu({
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* 透明遮罩层用于捕获点击事件 */}
|
||||
{/* Transparent overlay to capture click events */}
|
||||
<div className="fixed inset-0 z-40" />
|
||||
|
||||
{/* 菜单本体 */}
|
||||
{/* Menu body */}
|
||||
<div
|
||||
data-context-menu
|
||||
className="fixed bg-dark-bg border border-dark-border rounded-lg shadow-xl min-w-[180px] max-w-[250px] z-50 overflow-hidden"
|
||||
|
||||
Reference in New Issue
Block a user