mirror of
https://github.com/Nezumi-2711/onedrive-vercel-index.git
synced 2026-09-22 13:38:45 +00:00
Merge pull request #396 from myl7/fix-dl
This commit is contained in:
@@ -239,7 +239,7 @@ const FileListing: FC<{ query?: ParsedUrlQuery }> = ({ query }) => {
|
|||||||
} else if (files.length > 1) {
|
} else if (files.length > 1) {
|
||||||
setTotalGenerating(true)
|
setTotalGenerating(true)
|
||||||
|
|
||||||
const toastId = toast.loading(DownloadingToast(router))
|
const toastId = toast.loading(<DownloadingToast router={router} />)
|
||||||
downloadMultipleFiles({ toastId, router, files, folder })
|
downloadMultipleFiles({ toastId, router, files, folder })
|
||||||
.then(() => {
|
.then(() => {
|
||||||
setTotalGenerating(false)
|
setTotalGenerating(false)
|
||||||
@@ -278,7 +278,7 @@ const FileListing: FC<{ query?: ParsedUrlQuery }> = ({ query }) => {
|
|||||||
})()
|
})()
|
||||||
|
|
||||||
setFolderGenerating({ ...folderGenerating, [id]: true })
|
setFolderGenerating({ ...folderGenerating, [id]: true })
|
||||||
const toastId = toast.loading(DownloadingToast(router))
|
const toastId = toast.loading(<DownloadingToast router={router} />)
|
||||||
|
|
||||||
downloadTreelikeMultipleFiles({
|
downloadTreelikeMultipleFiles({
|
||||||
toastId,
|
toastId,
|
||||||
|
|||||||
@@ -7,12 +7,12 @@ import { fetcher } from '../utils/fetchWithSWR'
|
|||||||
import { getStoredToken } from '../utils/protectedRouteHandler'
|
import { getStoredToken } from '../utils/protectedRouteHandler'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a loading toast with file download progress support
|
* A loading toast component with file download progress support
|
||||||
* @param router Next router instance, used for reloading the page
|
* @param props
|
||||||
* @param progress Current downloading and compression progress (returned by jszip metadata)
|
* @param props.router Next router instance, used for reloading the page
|
||||||
* @returns Toast component with loading progress
|
* @param props.progress Current downloading and compression progress (returned by jszip metadata)
|
||||||
*/
|
*/
|
||||||
export function DownloadingToast(router: NextRouter, progress?: string) {
|
export function DownloadingToast({ router, progress }: { router: NextRouter, progress?: string }) {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -84,7 +84,7 @@ export async function downloadMultipleFiles({
|
|||||||
|
|
||||||
// Create zip file and download it
|
// Create zip file and download it
|
||||||
const b = await zip.generateAsync({ type: 'blob' }, metadata => {
|
const b = await zip.generateAsync({ type: 'blob' }, metadata => {
|
||||||
toast.loading(DownloadingToast(router, metadata.percent.toFixed(0)), {
|
toast.loading(<DownloadingToast router={router} progress={metadata.percent.toFixed(0)} />, {
|
||||||
id: toastId,
|
id: toastId,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -152,7 +152,7 @@ export async function downloadTreelikeMultipleFiles({
|
|||||||
|
|
||||||
// Create zip file and download it
|
// Create zip file and download it
|
||||||
const b = await zip.generateAsync({ type: 'blob' }, metadata => {
|
const b = await zip.generateAsync({ type: 'blob' }, metadata => {
|
||||||
toast.loading(DownloadingToast(router, metadata.percent.toFixed(0)), {
|
toast.loading(<DownloadingToast router={router} progress={metadata.percent.toFixed(0)} />, {
|
||||||
id: toastId,
|
id: toastId,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user