Skip to content

Commit 44cbb98

Browse files
authored
feat(desktop): only approve download in desktop not website (#4095)
1 parent 913b117 commit 44cbb98

1 file changed

Lines changed: 12 additions & 13 deletions

File tree

apps/desktop/layer/renderer/src/components/ui/media/PreviewMediaContent.tsx

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
TooltipPortal,
77
TooltipTrigger,
88
} from "@follow/components/ui/tooltip/index.js"
9+
import { IN_ELECTRON } from "@follow/shared/constants"
910
import type { MediaModel } from "@follow/shared/hono"
1011
import { stopPropagation } from "@follow/utils/dom"
1112
import { cn } from "@follow/utils/utils"
@@ -21,6 +22,7 @@ import { TransformComponent, TransformWrapper } from "react-zoom-pan-pinch"
2122

2223
import { m } from "~/components/common/Motion"
2324
import { COPY_MAP } from "~/constants"
25+
import { ipcServices } from "~/lib/client"
2426
import { replaceImgUrlIfNeed } from "~/lib/img-proxy"
2527

2628
import { useCurrentModal } from "../modal/stacked/hooks"
@@ -202,19 +204,16 @@ const HeaderActions: FC<{
202204
<HeaderButton description={t(COPY_MAP.OpenInBrowser())} onClick={() => window.open(src)}>
203205
<i className="i-mgc-external-link-cute-re" />
204206
</HeaderButton>
205-
<HeaderButton
206-
description={t("common:words.download")}
207-
onClick={() => {
208-
const a = document.createElement("a")
209-
a.href = src
210-
a.download = src.split("/").pop()!
211-
a.target = "_blank"
212-
a.rel = "noreferrer"
213-
a.click()
214-
}}
215-
>
216-
<i className="i-mgc-download-2-cute-re" />
217-
</HeaderButton>
207+
{IN_ELECTRON && (
208+
<HeaderButton
209+
description={t("common:words.download")}
210+
onClick={() => {
211+
ipcServices?.app.download(src)
212+
}}
213+
>
214+
<i className="i-mgc-download-2-cute-re" />
215+
</HeaderButton>
216+
)}
218217

219218
<HeaderButton
220219
description={t("common:words.close")}

0 commit comments

Comments
 (0)