mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-23 06:46:40 +08:00
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)
This commit is contained in:
@ -6,13 +6,14 @@ interface IImage {
|
|||||||
id: string;
|
id: string;
|
||||||
className?: string;
|
className?: string;
|
||||||
onClick?(): void;
|
onClick?(): void;
|
||||||
|
t?: string | number;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Image = ({ id, className, ...props }: IImage) => {
|
const Image = ({ id, t, className, ...props }: IImage) => {
|
||||||
return (
|
return (
|
||||||
<img
|
<img
|
||||||
{...props}
|
{...props}
|
||||||
src={`${api_host}/document/image/${id}`}
|
src={`${api_host}/document/image/${id}${t ? `?_t=${t}` : ''}`}
|
||||||
alt=""
|
alt=""
|
||||||
className={classNames('max-w-[45vw] max-h-[40wh] block', className)}
|
className={classNames('max-w-[45vw] max-h-[40wh] block', className)}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@ -22,6 +22,7 @@ export interface IChunkListResult {
|
|||||||
setPagination?: (pagination: { page: number; pageSize: number }) => void;
|
setPagination?: (pagination: { page: number; pageSize: number }) => void;
|
||||||
available: number | undefined;
|
available: number | undefined;
|
||||||
handleSetAvailable: (available: number | undefined) => void;
|
handleSetAvailable: (available: number | undefined) => void;
|
||||||
|
dataUpdatedAt?: number; // Timestamp when data was last updated - useful for cache busting
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useSelectChunkList = () => {
|
export const useSelectChunkList = () => {
|
||||||
@ -118,7 +119,11 @@ export const useFetchNextChunkList = (
|
|||||||
const [available, setAvailable] = useState<number | undefined>();
|
const [available, setAvailable] = useState<number | undefined>();
|
||||||
const debouncedSearchString = useDebounce(searchString, { wait: 500 });
|
const debouncedSearchString = useDebounce(searchString, { wait: 500 });
|
||||||
|
|
||||||
const { data, isFetching: loading } = useQuery({
|
const {
|
||||||
|
data,
|
||||||
|
isFetching: loading,
|
||||||
|
dataUpdatedAt,
|
||||||
|
} = useQuery({
|
||||||
queryKey: [
|
queryKey: [
|
||||||
'fetchChunkList',
|
'fetchChunkList',
|
||||||
documentId,
|
documentId,
|
||||||
@ -183,6 +188,7 @@ export const useFetchNextChunkList = (
|
|||||||
handleInputChange: onInputChange,
|
handleInputChange: onInputChange,
|
||||||
available,
|
available,
|
||||||
handleSetAvailable,
|
handleSetAvailable,
|
||||||
|
dataUpdatedAt, // Timestamp when data was last updated - useful for cache busting
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -25,6 +25,7 @@ interface IProps {
|
|||||||
selected: boolean;
|
selected: boolean;
|
||||||
clickChunkCard: (chunkId: string) => void;
|
clickChunkCard: (chunkId: string) => void;
|
||||||
textMode: ChunkTextMode;
|
textMode: ChunkTextMode;
|
||||||
|
t?: string | number; // Cache-busting key for images
|
||||||
}
|
}
|
||||||
|
|
||||||
const ChunkCard = ({
|
const ChunkCard = ({
|
||||||
@ -36,6 +37,7 @@ const ChunkCard = ({
|
|||||||
selected,
|
selected,
|
||||||
clickChunkCard,
|
clickChunkCard,
|
||||||
textMode,
|
textMode,
|
||||||
|
t: imageCacheKey,
|
||||||
}: IProps) => {
|
}: IProps) => {
|
||||||
const available = Number(item.available_int);
|
const available = Number(item.available_int);
|
||||||
const [enabled, setEnabled] = useState(false);
|
const [enabled, setEnabled] = useState(false);
|
||||||
@ -79,7 +81,11 @@ const ChunkCard = ({
|
|||||||
onMouseLeave={() => setOpen(false)}
|
onMouseLeave={() => setOpen(false)}
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
<Image id={item.image_id} className={styles.image}></Image>
|
<Image
|
||||||
|
t={imageCacheKey}
|
||||||
|
id={item.image_id}
|
||||||
|
className={styles.image}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</PopoverTrigger>
|
</PopoverTrigger>
|
||||||
<PopoverContent
|
<PopoverContent
|
||||||
@ -90,6 +96,7 @@ const ChunkCard = ({
|
|||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
<Image
|
<Image
|
||||||
|
t={imageCacheKey}
|
||||||
id={item.image_id}
|
id={item.image_id}
|
||||||
className={styles.imagePreview}
|
className={styles.imagePreview}
|
||||||
></Image>
|
></Image>
|
||||||
|
|||||||
@ -55,6 +55,7 @@ const Chunk = () => {
|
|||||||
handleInputChange,
|
handleInputChange,
|
||||||
available,
|
available,
|
||||||
handleSetAvailable,
|
handleSetAvailable,
|
||||||
|
dataUpdatedAt,
|
||||||
} = useFetchNextChunkList();
|
} = useFetchNextChunkList();
|
||||||
const { handleChunkCardClick, selectedChunkId } = useHandleChunkCardClick();
|
const { handleChunkCardClick, selectedChunkId } = useHandleChunkCardClick();
|
||||||
const isPdf = documentInfo?.type === 'pdf';
|
const isPdf = documentInfo?.type === 'pdf';
|
||||||
@ -277,6 +278,7 @@ const Chunk = () => {
|
|||||||
clickChunkCard={handleChunkCardClick}
|
clickChunkCard={handleChunkCardClick}
|
||||||
selected={item.chunk_id === selectedChunkId}
|
selected={item.chunk_id === selectedChunkId}
|
||||||
textMode={textMode}
|
textMode={textMode}
|
||||||
|
t={dataUpdatedAt}
|
||||||
></ChunkCard>
|
></ChunkCard>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user