diff --git a/src/renderer/src/components/ui/media/preview-media.tsx b/src/renderer/src/components/ui/media/preview-media.tsx index c6bc18cd05..a4a95222d3 100644 --- a/src/renderer/src/components/ui/media/preview-media.tsx +++ b/src/renderer/src/components/ui/media/preview-media.tsx @@ -4,6 +4,7 @@ import { tipcClient } from "@renderer/lib/client" import { stopPropagation } from "@renderer/lib/dom" import { replaceImgUrlIfNeed } from "@renderer/lib/img-proxy" import { showNativeMenu } from "@renderer/lib/native-menu" +import { cn } from "@renderer/lib/utils" import type { FC } from "react" import { Fragment, useCallback, useEffect, useRef, useState } from "react" import type { MediaModel } from "src/hono" @@ -78,6 +79,7 @@ export const PreviewMediaContent: FC<{ initialIndex?: number }> = ({ media, initialIndex = 0 }) => { const [currentMedia, setCurrentMedia] = useState(media[initialIndex]) + const [currentSlideIndex, setCurrentSlideIndex] = useState(initialIndex) const handleContextMenu = useCallback( (image: string, e: React.MouseEvent) => { @@ -114,6 +116,7 @@ export const PreviewMediaContent: FC<{ ) const swiperRef = useRef(null) + // This only to delay show const [showActions, setShowActions] = useState(false) useEffect(() => { @@ -163,36 +166,66 @@ export const PreviewMediaContent: FC<{ }} onSlideChange={({ realIndex }) => { setCurrentMedia(media[realIndex]) + setCurrentSlideIndex(realIndex) }} modules={[Mousewheel, Keyboard]} className="size-full" > {showActions && ( -
+
swiperRef.current?.swiper.slidePrev()} type="button" - className="center fixed left-4 top-1/2 z-[99] size-8 -translate-y-1/2 rounded-full border border-white/20 bg-neutral-900/80 text-white backdrop-blur duration-200 hover:bg-neutral-900" + className="center fixed left-2 top-1/2 z-[99] size-8 -translate-y-1/2 rounded-full border border-white/20 bg-neutral-900/80 text-white backdrop-blur duration-200 hover:bg-neutral-900" > swiperRef.current?.swiper.slideNext()} type="button" - className="center fixed right-4 top-1/2 z-[99] size-8 -translate-y-1/2 rounded-full border border-white/20 bg-neutral-900/80 text-white backdrop-blur duration-200 hover:bg-neutral-900" + className="center fixed right-2 top-1/2 z-[99] size-8 -translate-y-1/2 rounded-full border border-white/20 bg-neutral-900/80 text-white backdrop-blur duration-200 hover:bg-neutral-900" >
)} + {showActions && ( +
+
+ {currentSlideIndex + 1} / {media.length} +
+
+ {Array.from({ length: media.length }) + .fill(0) + .map((_, index) => ( +
+
+ )} + {media.map((med, index) => (