2024-12-24 12:14:28 +08:00
|
|
|
import React, { useMemo } from "react";
|
2024-12-19 18:33:13 +08:00
|
|
|
import { Image } from "antd-mobile";
|
|
|
|
export default function OwnImage({
|
|
|
|
src,
|
|
|
|
width = "100%",
|
|
|
|
height = "100%",
|
|
|
|
className,
|
2024-12-20 20:47:20 +08:00
|
|
|
outClassName,
|
2024-12-19 18:33:13 +08:00
|
|
|
roundedFull,
|
2024-12-20 20:47:20 +08:00
|
|
|
rounded,
|
2024-12-19 18:33:13 +08:00
|
|
|
...others
|
|
|
|
}) {
|
2024-12-24 12:14:28 +08:00
|
|
|
const loadingImage = useMemo(
|
|
|
|
() => (
|
|
|
|
<div
|
2024-12-26 20:09:06 +08:00
|
|
|
className={`bg-gray-700 absolute top-0 z-0 animate-pulse ${
|
2024-12-24 12:14:28 +08:00
|
|
|
roundedFull ? "rounded-full" : rounded
|
|
|
|
}`}
|
|
|
|
/>
|
|
|
|
),
|
|
|
|
[]
|
|
|
|
);
|
2024-12-19 18:33:13 +08:00
|
|
|
return (
|
2024-12-20 20:47:20 +08:00
|
|
|
<div
|
|
|
|
className={`flex flex-col justify-center items-center relative ${outClassName}`}
|
|
|
|
>
|
2024-12-19 18:33:13 +08:00
|
|
|
<div className={`${className}`}>
|
|
|
|
<Image
|
|
|
|
height={height}
|
|
|
|
width={width}
|
|
|
|
fit="cover"
|
|
|
|
src={src}
|
2024-12-20 20:47:20 +08:00
|
|
|
className={roundedFull ? "rounded-full" : rounded}
|
2024-12-19 18:33:13 +08:00
|
|
|
// placeholder=""
|
2024-12-24 12:14:28 +08:00
|
|
|
fallback={loadingImage}
|
|
|
|
placeholder={loadingImage}
|
2024-12-19 18:33:13 +08:00
|
|
|
{...others}
|
|
|
|
/>
|
|
|
|
<div className="w-full h-full bg-transparent absolute top-0 z-20" />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|