mirror of
https://github.com/ikun0014/lx-music-mobile.git
synced 2025-07-03 17:02:10 +08:00
修复使用范围存储时的新建文件夹问题
This commit is contained in:
parent
154ee13953
commit
74554ab088
@ -122,19 +122,21 @@ export default forwardRef<ListType, ListProps>(({
|
||||
}
|
||||
}, [])
|
||||
|
||||
const readDir = async(newPath: string, dirOnly: boolean, filter?: string[], isRefresh?: boolean, isOpen?: boolean) => {
|
||||
if (isReading) return
|
||||
const readDir = async(newPath: string, dirOnly: boolean, filter?: string[], isRefresh?: boolean, isOpen?: boolean): Promise<PathItem[]> => {
|
||||
if (isReading) return []
|
||||
setIsReading(true)
|
||||
return handleReadDir(newPath, dirOnly, filter, isRefresh).then(list => {
|
||||
if (isUnmountedRef.current) return
|
||||
if (isUnmountedRef.current) return []
|
||||
if (!isOpen && newPath != path && newPath.startsWith(path)) parentDirInfo.set(newPath, path)
|
||||
setList(list)
|
||||
setPath(newPath)
|
||||
return list
|
||||
}).catch((err: any) => {
|
||||
toast(`Read dir error: ${err.message as string}`, 'long')
|
||||
// console.log('prevPath', prevPath)
|
||||
// if (isReadingDir.current) return
|
||||
// setPath(prevPath)
|
||||
return []
|
||||
}).finally(() => {
|
||||
setIsReading(false)
|
||||
})
|
||||
|
@ -9,6 +9,7 @@ import { scaleSizeH } from '@/utils/pixelRatio'
|
||||
import { useStatusbarHeight } from '@/store/common/hook'
|
||||
import NewFolderModal, { type NewFolderType } from './NewFolderModal'
|
||||
import OpenStorageModal, { type OpenDirModalType } from './OpenStorageModal'
|
||||
import type { PathItem } from './ListItem'
|
||||
|
||||
|
||||
export default memo(({
|
||||
@ -19,8 +20,8 @@ export default memo(({
|
||||
}: {
|
||||
title: string
|
||||
path: string
|
||||
onRefreshDir: (dir: string) => Promise<void>
|
||||
onOpenDir: (dir: string) => Promise<void>
|
||||
onRefreshDir: (dir: string) => Promise<PathItem[]>
|
||||
onOpenDir: (dir: string) => Promise<PathItem[]>
|
||||
}) => {
|
||||
const theme = useTheme()
|
||||
const newFolderTypeRef = useRef<NewFolderType>(null)
|
||||
|
@ -6,6 +6,7 @@ import ConfirmAlert, { type ConfirmAlertType } from '@/components/common/Confirm
|
||||
import { createStyle, toast } from '@/utils/tools'
|
||||
import { mkdir } from '@/utils/fs'
|
||||
import { useTheme } from '@/store/theme/hook'
|
||||
import type { PathItem } from './ListItem'
|
||||
const filterFileName = /[\\/:*?#"<>|]/
|
||||
|
||||
|
||||
@ -45,7 +46,7 @@ const NameInput = forwardRef<NameInputType, {}>((props, ref) => {
|
||||
export interface NewFolderType {
|
||||
show: (path: string) => void
|
||||
}
|
||||
export default forwardRef<NewFolderType, { onRefreshDir: (dir: string) => Promise<void> }>(({ onRefreshDir }, ref) => {
|
||||
export default forwardRef<NewFolderType, { onRefreshDir: (dir: string) => Promise<PathItem[]> }>(({ onRefreshDir }, ref) => {
|
||||
const confirmAlertRef = useRef<ConfirmAlertType>(null)
|
||||
const nameInputRef = useRef<NameInputType>(null)
|
||||
const pathRef = useRef<string>('')
|
||||
@ -74,8 +75,9 @@ export default forwardRef<NewFolderType, { onRefreshDir: (dir: string) => Promis
|
||||
}
|
||||
const newPath = `${pathRef.current}/${text}`
|
||||
mkdir(newPath).then(() => {
|
||||
void onRefreshDir(pathRef.current).then(() => {
|
||||
void onRefreshDir(newPath)
|
||||
void onRefreshDir(pathRef.current).then((list) => {
|
||||
const target = list.find(item => item.name == text)
|
||||
if (target) void onRefreshDir(target.path)
|
||||
})
|
||||
nameInputRef.current?.setName('')
|
||||
}).catch((err: any) => {
|
||||
|
@ -11,6 +11,7 @@ import Button from '@/components/common/Button'
|
||||
import ButtonPrimary from '@/components/common/ButtonPrimary'
|
||||
import { useUnmounted } from '@/utils/hooks'
|
||||
import { Icon } from '@/components/common/Icon'
|
||||
import type { PathItem } from './ListItem'
|
||||
const filterFileName = /[\\:*?#"<>|]/
|
||||
|
||||
|
||||
@ -53,7 +54,7 @@ const PathInput = forwardRef<PathInputType, {}>((props, ref) => {
|
||||
export interface OpenDirModalType {
|
||||
show: (paths: string[]) => void
|
||||
}
|
||||
export default forwardRef<OpenDirModalType, { onOpenDir: (dir: string) => Promise<void> }>(({
|
||||
export default forwardRef<OpenDirModalType, { onOpenDir: (dir: string) => Promise<PathItem[]> }>(({
|
||||
onOpenDir,
|
||||
}, ref) => {
|
||||
const confirmAlertRef = useRef<ConfirmAlertType>(null)
|
||||
|
Loading…
x
Reference in New Issue
Block a user