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

@@ -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" />
) : (