fix(remote): 修复文件传输返回按钮不刷新列表的问题,过滤回收站等系统文件

This commit is contained in:
2026-03-10 19:09:39 +08:00
parent 2503d8be64
commit 7a39fc3bce
4 changed files with 18 additions and 16 deletions

View File

@@ -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

View File

@@ -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);

View File

@@ -150,12 +150,10 @@ export const LocalFilePanel: React.FC<LocalFilePanelProps> = ({
: '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) ? (
<HardDrive size={16} className="text-blue-500 dark:text-blue-400 shrink-0" />
) : (
<Folder size={16} className="text-gray-500 dark:text-gray-400 shrink-0" />
)
{file.path.match(/^[A-Z]:\\?$/i) ? (
<HardDrive size={16} className="text-gray-500 dark:text-gray-400 shrink-0" />
) : file.type === 'dir' ? (
<Folder size={16} className="text-gray-500 dark:text-gray-400 shrink-0" />
) : (
<FileText size={16} className="text-gray-500 dark:text-gray-400 shrink-0" />
)}

View File

@@ -27,7 +27,7 @@ export const RemoteFilePanel: React.FC<RemoteFilePanelProps> = ({
const [currentPath, setCurrentPath] = useState('')
const [files, setFiles] = useState<RemoteFileItem[]>([])
const [loading, setLoading] = useState(false)
const [pathHistory, setPathHistory] = useState<string[]>([''])
const [pathHistory, setPathHistory] = useState<string[]>([])
const [showDrives, setShowDrives] = useState(true)
const loadDrives = useCallback(async () => {
@@ -66,7 +66,9 @@ export const RemoteFilePanel: React.FC<RemoteFilePanelProps> = ({
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<RemoteFilePanelProps> = ({
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<RemoteFilePanelProps> = ({
}
const handleGoToRoot = () => {
setPathHistory([''])
setPathHistory([])
setCurrentPath('')
loadDrives()
onSelect(null)
@@ -113,7 +114,7 @@ export const RemoteFilePanel: React.FC<RemoteFilePanelProps> = ({
}
const getDisplayPath = () => {
if (showDrives) return '选择驱动器'
if (showDrives) return '远程磁盘'
if (!currentPath) return '远程文件'
return currentPath
}
@@ -181,7 +182,7 @@ export const RemoteFilePanel: React.FC<RemoteFilePanelProps> = ({
)}
>
{isDrive ? (
<HardDrive size={16} className="text-blue-500 dark:text-blue-400 shrink-0" />
<HardDrive size={16} className="text-gray-500 dark:text-gray-400 shrink-0" />
) : file.type === 'dir' ? (
<Folder size={16} className="text-gray-500 dark:text-gray-400 shrink-0" />
) : (