-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: show progress when downloading whisper and models
- Loading branch information
Showing
10 changed files
with
228 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import React, { FC } from "react"; | ||
import { Button } from "@/components/ui/button"; | ||
import { Loader2 } from "lucide-react"; | ||
|
||
interface IProps { | ||
loading?: boolean; | ||
progress?: number; | ||
handleDownModel?: () => void; | ||
} | ||
|
||
const DownModelButton: FC<IProps> = ({ | ||
loading, | ||
progress, | ||
handleDownModel, | ||
}) => { | ||
return ( | ||
<Button disabled={loading} onClick={() => handleDownModel()}> | ||
{loading ? ( | ||
<> | ||
<Loader2 className="mr-2 h-4 w-4 animate-spin" /> {progress} % | ||
</> | ||
) : ( | ||
"下载" | ||
)} | ||
</Button> | ||
); | ||
}; | ||
|
||
export default DownModelButton; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import React, { FC } from "react"; | ||
import { | ||
DropdownMenu, | ||
DropdownMenuContent, | ||
DropdownMenuItem, | ||
DropdownMenuLabel, | ||
DropdownMenuSeparator, | ||
DropdownMenuTrigger, | ||
} from "@/components/ui/dropdown-menu"; | ||
import { Button } from "@/components/ui/button"; | ||
import { Loader2 } from "lucide-react"; | ||
|
||
interface IProps { | ||
loading?: boolean; | ||
progress?: number; | ||
handleDownModel?: (source: string) => void; | ||
setShowGuide?: (type: boolean) => void; | ||
installComplete?: boolean; | ||
whisperLoading?: boolean; | ||
} | ||
|
||
const DownModelDropdown: FC<IProps> = ({ | ||
loading, | ||
progress, | ||
handleDownModel, | ||
setShowGuide, | ||
installComplete, | ||
whisperLoading, | ||
}) => { | ||
return ( | ||
<DropdownMenu> | ||
<DropdownMenuTrigger asChild> | ||
<Button | ||
variant="outline" | ||
disabled={loading || !installComplete || whisperLoading} | ||
className="w-24" | ||
> | ||
{loading && <Loader2 className="mr-2 h-4 w-4 animate-spin" />} | ||
{loading ? `${progress}%` : "下载"} | ||
</Button> | ||
</DropdownMenuTrigger> | ||
<DropdownMenuContent className="w-[225px]"> | ||
<DropdownMenuLabel>请选择下载源</DropdownMenuLabel> | ||
<DropdownMenuSeparator /> | ||
<DropdownMenuItem | ||
className="cursor-pointer hover:bg-gray-100" | ||
onClick={() => handleDownModel("hf-mirror")} | ||
> | ||
国内镜像源(较快) | ||
</DropdownMenuItem> | ||
<DropdownMenuItem | ||
className="cursor-pointer hover:bg-gray-100" | ||
onClick={() => handleDownModel("huggingface")} | ||
> | ||
huggingface官方源(较慢) | ||
</DropdownMenuItem> | ||
<DropdownMenuSeparator /> | ||
<DropdownMenuItem | ||
className="cursor-pointer hover:bg-gray-100" | ||
onClick={() => setShowGuide(false)} | ||
> | ||
稍后下载 | ||
</DropdownMenuItem> | ||
</DropdownMenuContent> | ||
</DropdownMenu> | ||
); | ||
}; | ||
|
||
export default DownModelDropdown; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React, { FC } from "react"; | ||
|
||
interface IProps { | ||
loading?: boolean; | ||
progress?: number; | ||
handleDownModel?: () => void; | ||
} | ||
const DownModelLink: FC<IProps> = ({ loading, progress, handleDownModel }) => { | ||
return ( | ||
<span className="inline-block"> | ||
该模型未下载, | ||
{loading ? ( | ||
`正在下载中 ${progress}%...` | ||
) : ( | ||
<a | ||
className="cursor-pointer text-blue-500" | ||
onClick={() => handleDownModel()} | ||
> | ||
立即下载 | ||
</a> | ||
)} | ||
</span> | ||
); | ||
}; | ||
|
||
export default DownModelLink; |
Oops, something went wrong.