修复文件管理器滚动功能和软链接支持

主要改进:
- 重新设计布局结构,确保状态栏始终可见
- 添加软链接图标和目标路径显示支持
- 修复滚动条功能,使用绝对定位的滚动容器
- 优化文件名编辑框的自适应宽度和居中显示
- 完善软链接点击处理逻辑

布局优化:
- 外层容器:h-full flex flex-col overflow-hidden
- 滚动区域:flex-1 relative overflow-hidden 包含 absolute inset-0 overflow-y-auto
- 状态栏:flex-shrink-0 确保始终可见

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
ZacharyZcR
2025-09-16 19:40:51 +08:00
parent 16de73d6ad
commit 7059ebcc0e
2 changed files with 157 additions and 46 deletions

View File

@@ -30,7 +30,8 @@ import {
deleteSSHItem,
renameSSHItem,
connectSSH,
getSSHStatus
getSSHStatus,
identifySSHSymlink
} from "@/ui/main-axios.ts";
@@ -345,9 +346,95 @@ function FileManagerContent({ initialHost, onClose }: FileManagerModernProps) {
setIsCreatingNewFile(true);
}
function handleFileOpen(file: FileItem) {
// Handle symlink resolution
const handleSymlinkClick = async (file: FileItem) => {
if (!currentHost || !sshSessionId) {
toast.error(t("fileManager.noSSHConnection"));
return;
}
try {
// 确保SSH连接有效
let currentSessionId = sshSessionId;
try {
const status = await getSSHStatus(currentSessionId);
if (!status.connected) {
const result = await connectSSH(currentSessionId, {
hostId: currentHost.id,
host: currentHost.ip,
port: currentHost.port,
username: currentHost.username,
authType: currentHost.authType,
password: currentHost.password,
key: currentHost.key,
keyPassword: currentHost.keyPassword,
credentialId: currentHost.credentialId
});
if (!result.success) {
throw new Error(t("fileManager.failedToReconnectSSH"));
}
}
} catch (sessionErr) {
throw sessionErr;
}
const symlinkInfo = await identifySSHSymlink(currentSessionId, file.path);
if (symlinkInfo.type === "directory") {
// 如果软链接指向目录,导航到它
setCurrentPath(symlinkInfo.target);
} else if (symlinkInfo.type === "file") {
// 如果软链接指向文件,打开文件
// 计算窗口位置(稍微错开)
const windowCount = Date.now() % 10;
const offsetX = 120 + (windowCount * 30);
const offsetY = 120 + (windowCount * 30);
// 创建目标文件对象
const targetFile: FileItem = {
...file,
path: symlinkInfo.target
};
// 创建窗口组件工厂函数
const createWindowComponent = (windowId: string) => (
<FileWindow
windowId={windowId}
file={targetFile}
sshSessionId={currentSessionId}
sshHost={currentHost}
initialX={offsetX}
initialY={offsetY}
/>
);
openWindow({
title: file.name,
x: offsetX,
y: offsetY,
width: 800,
height: 600,
isMaximized: false,
isMinimized: false,
component: createWindowComponent
});
}
} catch (error: any) {
toast.error(
error?.response?.data?.error ||
error?.message ||
t("fileManager.failedToResolveSymlink")
);
}
};
async function handleFileOpen(file: FileItem) {
if (file.type === 'directory') {
setCurrentPath(file.path);
} else if (file.type === 'link') {
// 处理软链接
await handleSymlinkClick(file);
} else {
// 在新窗口中打开文件
if (!sshSessionId) {