Files
ragflow/web/src/components/image/index.tsx
Jimmy Ben Klieve 8dd2394e93 feat: add optional cache busting for image (#12055)
### What problem does this PR solve?

Add optional cache busting for image

#12003  

### Type of change

- [x] New Feature (non-breaking change which adds functionality)
2025-12-22 09:36:45 +08:00

37 lines
893 B
TypeScript

import { api_host } from '@/utils/api';
import classNames from 'classnames';
import { Popover, PopoverContent, PopoverTrigger } from '../ui/popover';
interface IImage {
id: string;
className?: string;
onClick?(): void;
t?: string | number;
}
const Image = ({ id, t, className, ...props }: IImage) => {
return (
<img
{...props}
src={`${api_host}/document/image/${id}${t ? `?_t=${t}` : ''}`}
alt=""
className={classNames('max-w-[45vw] max-h-[40wh] block', className)}
/>
);
};
export default Image;
export const ImageWithPopover = ({ id }: { id: string }) => {
return (
<Popover>
<PopoverTrigger>
<Image id={id} className="max-h-[100px] inline-block"></Image>
</PopoverTrigger>
<PopoverContent>
<Image id={id} className="max-w-[100px] object-contain"></Image>
</PopoverContent>
</Popover>
);
};