Skip to content

Commit

Permalink
fix: proxy sp1.piokok.com and video preview url
Browse files Browse the repository at this point in the history
  • Loading branch information
hyoban committed Sep 28, 2024
1 parent 935c87d commit 0338876
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
16 changes: 14 additions & 2 deletions apps/renderer/src/components/ui/media.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,18 @@ const MediaImpl: FC<MediaProps> = ({
: src,
)

const previewImageSrc = useMemo(
() =>
proxy && previewImageUrl
? getImageProxyUrl({
url: previewImageUrl,
width: proxy.width,
height: proxy.height,
})
: previewImageUrl,
[previewImageUrl, proxy],
)

const [mediaLoadState, setMediaLoadState] = useState<"loading" | "loaded" | "error">("loading")
const errorHandle: React.ReactEventHandler<HTMLImageElement> = useEventCallback((e) => {
if (imgSrc !== props.src) {
Expand Down Expand Up @@ -135,7 +147,7 @@ const MediaImpl: FC<MediaProps> = ({
)}
onClick={handleClick}
>
<VideoPreview src={src!} previewImageUrl={previewImageUrl} thumbnail={thumbnail} />
<VideoPreview src={src!} previewImageUrl={previewImageSrc} thumbnail={thumbnail} />
</span>
)
}
Expand All @@ -151,7 +163,7 @@ const MediaImpl: FC<MediaProps> = ({
mediaContainerClassName,
mediaLoadState,
popper,
previewImageUrl,
previewImageSrc,
props.height,
props.width,
rest,
Expand Down
4 changes: 4 additions & 0 deletions packages/shared/src/image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@ export const imageRefererMatches = [
url: /^https:\/\/(?:\w|-)+\.cdninstagram\.com/,
referer: "https://www.instagram.com",
},
{
url: /^https:\/\/sp1\.piokok\.com/,
referer: "https://sp1.piokok.com",
},
]

0 comments on commit 0338876

Please sign in to comment.