@@ -10,9 +10,8 @@ import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/u
1010import { Progress } from '@/components/ui/progress'
1111import { FolderOpen , Upload , RefreshCw , X } from 'lucide-react'
1212import type { FileInfo } from '@/types/files'
13- import { API_BASE_URL } from '@/config'
1413import { useMobile } from '@/hooks/useMobile'
15- import { useFile } from '@/api/files'
14+ import { getFileApiUrl , useFile } from '@/api/files'
1615
1716export interface FileBrowserHandle {
1817 goBack : ( ) => void
@@ -156,19 +155,6 @@ useEffect(() => {
156155 }
157156} , [ initialFileError ] )
158157
159- const getFileApiUrl = useCallback ( ( path : string ) => {
160- if ( path . includes ( '..' ) ) {
161- return `${ API_BASE_URL } /api/files/?path=${ encodeURIComponent ( path ) } `
162- }
163-
164- const encodedPath = path
165- . split ( '/' )
166- . map ( segment => encodeURIComponent ( segment ) )
167- . join ( '/' )
168-
169- return `${ API_BASE_URL } /api/files/${ encodedPath } `
170- } , [ ] )
171-
172158 const loadFiles = useCallback ( async ( path : string ) => {
173159 setLoading ( true )
174160 setError ( null )
@@ -188,7 +174,7 @@ useEffect(() => {
188174 } finally {
189175 setLoading ( false )
190176 }
191- } , [ getFileApiUrl , onDirectoryLoad ] )
177+ } , [ onDirectoryLoad ] )
192178
193179 const normalizePath = useCallback ( ( path : string ) => {
194180 const normalized = path
@@ -276,7 +262,7 @@ useEffect(() => {
276262 } finally {
277263 setLoading ( false )
278264 }
279- } , [ getFileApiUrl , onFileSelect , isMobile , onPreviewStateChange ] )
265+ } , [ onFileSelect , isMobile , onPreviewStateChange ] )
280266
281267 const handleCloseModal = useCallback ( ( ) => {
282268 setIsPreviewModalOpen ( false )
@@ -312,7 +298,7 @@ useEffect(() => {
312298 } catch ( err ) {
313299 return err instanceof Error ? err . message : 'Upload failed'
314300 }
315- } , [ currentPath , getFileApiUrl ] )
301+ } , [ currentPath ] )
316302
317303 const handleUploadItems = useCallback ( async ( items : UploadItem [ ] ) => {
318304 if ( items . length === 0 ) return
@@ -382,7 +368,7 @@ useEffect(() => {
382368 } catch ( err ) {
383369 setError ( err instanceof Error ? err . message : 'Create failed' )
384370 }
385- } , [ currentPath , getFileApiUrl , loadFiles ] )
371+ } , [ currentPath , loadFiles ] )
386372
387373 const handleDelete = useCallback ( async ( path : string ) => {
388374 try {
@@ -399,7 +385,7 @@ useEffect(() => {
399385 } catch ( err ) {
400386 setError ( err instanceof Error ? err . message : 'Delete failed' )
401387 }
402- } , [ currentPath , getFileApiUrl , loadFiles ] )
388+ } , [ currentPath , loadFiles ] )
403389
404390 const handleRename = useCallback ( async ( oldPath : string , newPath : string ) => {
405391 try {
@@ -417,7 +403,7 @@ useEffect(() => {
417403 } catch ( err ) {
418404 setError ( err instanceof Error ? err . message : 'Rename failed' )
419405 }
420- } , [ currentPath , getFileApiUrl , loadFiles ] )
406+ } , [ currentPath , loadFiles ] )
421407
422408 const handleDragEnter = ( e : React . DragEvent ) => {
423409 e . preventDefault ( )
0 commit comments