From 7a39fc3bcea7b3607d80e6e0fc671ff348b3ea61 Mon Sep 17 00:00:00 2001 From: ssdfasd <2156608475@qq.com> Date: Tue, 10 Mar 2026 19:09:39 +0800 Subject: [PATCH] =?UTF-8?q?fix(remote):=20=E4=BF=AE=E5=A4=8D=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E4=BC=A0=E8=BE=93=E8=BF=94=E5=9B=9E=E6=8C=89=E9=92=AE?= =?UTF-8?q?=E4=B8=8D=E5=88=B7=E6=96=B0=E5=88=97=E8=A1=A8=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=EF=BC=8C=E8=BF=87=E6=BB=A4=E5=9B=9E=E6=94=B6=E7=AB=99?= =?UTF-8?q?=E7=AD=89=E7=B3=BB=E7=BB=9F=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/core/files/routes.ts | 4 ++-- remote/src/services/file/FileService.js | 3 +++ .../components/file-transfer/LocalFilePanel.tsx | 10 ++++------ .../file-transfer/RemoteFilePanel.tsx | 17 +++++++++-------- 4 files changed, 18 insertions(+), 16 deletions(-) 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' ? ( ) : (