Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 27 additions & 15 deletions src/hooks/useDownload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { local, password, selectedObjs as _selectedObjs } from "~/store"
import { fsList, notify, pathBase, pathJoin } from "~/utils"
import { getLinkByDirAndObj, useRouter, useT } from "~/hooks"
import { useSelectedLink } from "~/hooks"
import { getPagination } from "~/store/settings"
import { Obj } from "~/types"

interface File {
Expand Down Expand Up @@ -69,24 +70,35 @@ export const useDownload = () => {
},
]
} else {
const resp = await fsList(
pathJoin(pathname(), pre, obj.name),
password(),
)
if (resp.code !== 200) {
return resp.message
}
const res: File[] = []
for (const _obj of resp.data.content ?? []) {
const _res = await fetchFolderStructure(
pathJoin(pre, obj.name),
_obj,
let page = 1
const perPage = getPagination().size
while (true) {
const resp = await fsList(
pathJoin(pathname(), pre, obj.name),
password(),
page,
perPage,
)
if (typeof _res === "string") {
return _res
} else {
res.push(..._res)
if (resp.code !== 200) {
return resp.message
}
const content = resp.data.content ?? []
for (const _obj of content) {
const _res = await fetchFolderStructure(
pathJoin(pre, obj.name),
_obj,
)
if (typeof _res === "string") {
return _res
} else {
res.push(..._res)
}
}
if (content.length < perPage) {
break
}
page++
}
return res
}
Expand Down