Feat: may download files(recording/audio/video/speech) (#431)
* may download recording * may download recording/audio/video/speech
This commit is contained in:
@@ -39,6 +39,7 @@ import {
|
||||
TextCursorInputIcon,
|
||||
MicIcon,
|
||||
SquareIcon,
|
||||
DownloadIcon,
|
||||
} from "lucide-react";
|
||||
import { t } from "i18next";
|
||||
import { formatDuration } from "@renderer/lib/utils";
|
||||
@@ -195,6 +196,30 @@ export const MediaCurrentRecording = (props: { height?: number }) => {
|
||||
});
|
||||
};
|
||||
|
||||
const handleDownload = () => {
|
||||
EnjoyApp.dialog
|
||||
.showSaveDialog({
|
||||
title: t("download"),
|
||||
defaultPath: currentRecording.filename,
|
||||
})
|
||||
.then((savePath) => {
|
||||
if (!savePath) return;
|
||||
|
||||
toast.promise(
|
||||
EnjoyApp.download.start(currentRecording.src, savePath as string),
|
||||
{
|
||||
loading: t("downloading", { file: currentRecording.filename }),
|
||||
success: () => t("downloadedSuccessfully"),
|
||||
error: t("downloadFailed"),
|
||||
position: "bottom-right",
|
||||
}
|
||||
);
|
||||
})
|
||||
.catch((err) => {
|
||||
toast.error(err.message);
|
||||
});
|
||||
};
|
||||
|
||||
const calContainerWidth = () => {
|
||||
const w = document
|
||||
.querySelector(".media-recording-container")
|
||||
@@ -515,6 +540,14 @@ export const MediaCurrentRecording = (props: { height?: number }) => {
|
||||
<Share2Icon className="w-4 h-4 mr-4" />
|
||||
<span>{t("share")}</span>
|
||||
</DropdownMenuItem>
|
||||
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer"
|
||||
onClick={handleDownload}
|
||||
>
|
||||
<DownloadIcon className="w-4 h-4 mr-4" />
|
||||
<span>{t("download")}</span>
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</div>
|
||||
|
||||
@@ -29,6 +29,7 @@ import {
|
||||
ZoomInIcon,
|
||||
ZoomOutIcon,
|
||||
MoreVerticalIcon,
|
||||
DownloadIcon,
|
||||
} from "lucide-react";
|
||||
|
||||
const ZOOM_RATIO_OPTIONS = [
|
||||
@@ -93,6 +94,27 @@ export const MediaPlayer = () => {
|
||||
setWidth(w - 48);
|
||||
};
|
||||
|
||||
const handleDownload = () => {
|
||||
EnjoyApp.dialog
|
||||
.showSaveDialog({
|
||||
title: t("download"),
|
||||
defaultPath: media.filename,
|
||||
})
|
||||
.then((savePath) => {
|
||||
if (!savePath) return;
|
||||
|
||||
toast.promise(EnjoyApp.download.start(media.src, savePath as string), {
|
||||
loading: t("downloading", { file: media.filename }),
|
||||
success: () => t("downloadedSuccessfully"),
|
||||
error: t("downloadFailed"),
|
||||
position: "bottom-right",
|
||||
});
|
||||
})
|
||||
.catch((err) => {
|
||||
toast.error(err.message);
|
||||
});
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (ref?.current) {
|
||||
setRef(ref);
|
||||
@@ -233,6 +255,14 @@ export const MediaPlayer = () => {
|
||||
<Share2Icon className="w-4 h-4 mr-4" />
|
||||
<span>{t("share")}</span>
|
||||
</DropdownMenuItem>
|
||||
|
||||
<DropdownMenuItem
|
||||
className="cursor-pointer"
|
||||
onClick={handleDownload}
|
||||
>
|
||||
<DownloadIcon className="w-4 h-4 mr-4" />
|
||||
<span>{t("download")}</span>
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ import {
|
||||
ForwardIcon,
|
||||
AlertCircleIcon,
|
||||
MoreVerticalIcon,
|
||||
DownloadIcon,
|
||||
} from "lucide-react";
|
||||
import { useCopyToClipboard } from "@uidotdev/usehooks";
|
||||
import { t } from "i18next";
|
||||
@@ -112,6 +113,29 @@ export const AssistantMessageComponent = (props: {
|
||||
setShadowing(true);
|
||||
};
|
||||
|
||||
const handleDownload = async () => {
|
||||
if (!speech) return;
|
||||
|
||||
EnjoyApp.dialog
|
||||
.showSaveDialog({
|
||||
title: t("download"),
|
||||
defaultPath: speech.filename,
|
||||
})
|
||||
.then((savePath) => {
|
||||
if (!savePath) return;
|
||||
|
||||
toast.promise(EnjoyApp.download.start(speech.src, savePath as string), {
|
||||
loading: t("downloading", { file: speech.filename }),
|
||||
success: () => t("downloadedSuccessfully"),
|
||||
error: t("downloadFailed"),
|
||||
position: "bottom-right",
|
||||
});
|
||||
})
|
||||
.catch((err) => {
|
||||
toast.error(err.message);
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<div
|
||||
id={`message-${message.id}`}
|
||||
@@ -224,6 +248,15 @@ export const AssistantMessageComponent = (props: {
|
||||
className="w-3 h-3 cursor-pointer"
|
||||
/>
|
||||
))}
|
||||
{Boolean(speech) && (
|
||||
<DownloadIcon
|
||||
data-tooltip-id="global-tooltip"
|
||||
data-tooltip-content={t("download")}
|
||||
data-testid="message-start-shadow"
|
||||
onClick={handleDownload}
|
||||
className="w-3 h-3 cursor-pointer"
|
||||
/>
|
||||
)}
|
||||
|
||||
<DropdownMenuTrigger>
|
||||
<MoreVerticalIcon className="w-3 h-3" />
|
||||
|
||||
Reference in New Issue
Block a user