diff --git a/api/core/files/routes.ts b/api/core/files/routes.ts index 733caa0..b3fb6c6 100644 --- a/api/core/files/routes.ts +++ b/api/core/files/routes.ts @@ -99,7 +99,7 @@ router.get( }), ) - const visibleItems = items.filter((i): i is FileItemDTO => i !== null && !i.name.startsWith('.')) + const visibleItems = items.filter((i): i is FileItemDTO => i !== null && !i.name.startsWith('.') && !i.name.startsWith('$')) visibleItems.sort((a, b) => { if (a.type === b.type) return a.name.localeCompare(b.name) return a.type === 'dir' ? -1 : 1 @@ -173,7 +173,7 @@ router.get( }), ) - const visibleItems = items.filter((i): i is FileItemDTO => i !== null && !i.name.startsWith('.')) + const visibleItems = items.filter((i): i is FileItemDTO => i !== null && !i.name.startsWith('.') && !i.name.startsWith('$')) visibleItems.sort((a, b) => { if (a.type === b.type) return a.name.localeCompare(b.name) return a.type === 'dir' ? -1 : 1 diff --git a/remote/src/services/file/FileService.js b/remote/src/services/file/FileService.js index 9274ec3..8168e1f 100644 --- a/remote/src/services/file/FileService.js +++ b/remote/src/services/file/FileService.js @@ -186,6 +186,9 @@ class FileService { const files = fs.readdirSync(targetDir); for (const name of files) { + if (name.startsWith('.')) continue; + if (name.startsWith('$')) continue; + try { const itemPath = path.join(targetDir, name); const stat = fs.statSync(itemPath); diff --git a/src/modules/remote/components/file-transfer/LocalFilePanel.tsx b/src/modules/remote/components/file-transfer/LocalFilePanel.tsx index e9859f5..d8fc92d 100644 --- a/src/modules/remote/components/file-transfer/LocalFilePanel.tsx +++ b/src/modules/remote/components/file-transfer/LocalFilePanel.tsx @@ -150,12 +150,10 @@ export const LocalFilePanel: React.FC = ({ : 'hover:bg-gray-100 dark:hover:bg-gray-700/50 text-gray-700 dark:text-gray-200' )} > - {file.type === 'dir' || file.path.match(/^[A-Z]:\\?$/i) ? ( - file.path.match(/^[A-Z]:\\?$/i) ? ( - - ) : ( - - ) + {file.path.match(/^[A-Z]:\\?$/i) ? ( + + ) : file.type === 'dir' ? ( + ) : ( )} diff --git a/src/modules/remote/components/file-transfer/RemoteFilePanel.tsx b/src/modules/remote/components/file-transfer/RemoteFilePanel.tsx index 2057ee0..912f864 100644 --- a/src/modules/remote/components/file-transfer/RemoteFilePanel.tsx +++ b/src/modules/remote/components/file-transfer/RemoteFilePanel.tsx @@ -27,7 +27,7 @@ export const RemoteFilePanel: React.FC = ({ const [currentPath, setCurrentPath] = useState('') const [files, setFiles] = useState([]) const [loading, setLoading] = useState(false) - const [pathHistory, setPathHistory] = useState(['']) + const [pathHistory, setPathHistory] = useState([]) const [showDrives, setShowDrives] = useState(true) const loadDrives = useCallback(async () => { @@ -66,7 +66,9 @@ export const RemoteFilePanel: React.FC = ({ if (showDrives) { return } - if (pathHistory.length > 1) { + if (pathHistory.length <= 1) { + loadDrives() + } else { const newHistory = [...pathHistory] newHistory.pop() const prevPath = newHistory[newHistory.length - 1] @@ -74,15 +76,14 @@ export const RemoteFilePanel: React.FC = ({ setCurrentPath(prevPath) onSelect(null) onPathChange?.(prevPath) - } else { - loadDrives() + loadFiles(prevPath) } } const handleGoInto = (file: RemoteFileItem) => { if (showDrives) { const newPath = file.path + '\\' - setPathHistory(['', newPath]) + setPathHistory([newPath]) setCurrentPath(newPath) loadFiles(newPath) onPathChange?.(newPath) @@ -105,7 +106,7 @@ export const RemoteFilePanel: React.FC = ({ } const handleGoToRoot = () => { - setPathHistory(['']) + setPathHistory([]) setCurrentPath('') loadDrives() onSelect(null) @@ -113,7 +114,7 @@ export const RemoteFilePanel: React.FC = ({ } const getDisplayPath = () => { - if (showDrives) return '选择驱动器' + if (showDrives) return '远程磁盘' if (!currentPath) return '远程文件' return currentPath } @@ -181,7 +182,7 @@ export const RemoteFilePanel: React.FC = ({ )} > {isDrive ? ( - + ) : file.type === 'dir' ? ( ) : (