diff --git a/web/src/app.tsx b/web/src/app.tsx index c00c245..09e2b73 100644 --- a/web/src/app.tsx +++ b/web/src/app.tsx @@ -1,6 +1,5 @@ import i18n from '@/locales/config'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; -import { ReactQueryDevtools } from '@tanstack/react-query-devtools'; import { App, ConfigProvider, ConfigProviderProps, theme } from 'antd'; import pt_BR from 'antd/lib/locale/pt_BR'; import deDE from 'antd/locale/de_DE'; @@ -68,7 +67,7 @@ function Root({ children }: React.PropsWithChildren) { > {children} - + {/* */} ); } diff --git a/web/src/components/chunk_image/index.less b/web/src/components/chunk_image/index.less new file mode 100644 index 0000000..6aff0bd --- /dev/null +++ b/web/src/components/chunk_image/index.less @@ -0,0 +1,15 @@ +.primitiveImg { + display: inline-block; + max-height: 100px; +} + +.image { + max-width: 100px; + object-fit: contain; +} + +.imagePreview { + display: block; + max-width: 45vw; + max-height: 40vh; +} diff --git a/web/src/components/chunk_image/index.tsx b/web/src/components/chunk_image/index.tsx new file mode 100644 index 0000000..c1ddca9 --- /dev/null +++ b/web/src/components/chunk_image/index.tsx @@ -0,0 +1,37 @@ +import { Popover } from 'antd'; +import classNames from 'classnames'; + +import styles from './index.less'; + +interface IImage { + id: string; + className: string; +} + +const ChunkImage = ({ id, className, ...props }: IImage) => { + const imgSrc = id; + + return ( + + ); +}; + +export default ChunkImage; + +export const ImageWithPopover = ({ id }: { id: string }) => { + return ( + + } + > + + + ); +}; diff --git a/web/src/pages/add-knowledge/components/knowledge-chunk/index.less b/web/src/pages/add-knowledge/components/knowledge-chunk/index.less index a41a35a..0867737 100644 --- a/web/src/pages/add-knowledge/components/knowledge-chunk/index.less +++ b/web/src/pages/add-knowledge/components/knowledge-chunk/index.less @@ -90,3 +90,39 @@ cursor: pointer; } + +.imagePreviewPane { + width: 200px; + min-width: 200px; + background-color: #f0f9ff; + border-radius: 8px; + padding: 16px; + display: flex; + flex-direction: column; + + h4 { + text-align: center; + margin-bottom: 12px; + font-weight: 500; + } + + p { + text-align: center; + margin-bottom: 12px; + font-weight: 500; + } + + .imagePreviewContainer { + flex: 1; + display: flex; + align-items: center; + justify-content: center; + overflow: hidden; + + .fullSizeImage { + max-width: 100%; + max-height: 100%; + object-fit: contain; + } + } +} diff --git a/web/src/pages/add-knowledge/components/knowledge-chunk/index.tsx b/web/src/pages/add-knowledge/components/knowledge-chunk/index.tsx index 6bce601..78f8152 100644 --- a/web/src/pages/add-knowledge/components/knowledge-chunk/index.tsx +++ b/web/src/pages/add-knowledge/components/knowledge-chunk/index.tsx @@ -1,3 +1,4 @@ +import ChunkImage from '@/components/chunk_image'; import { useFetchNextChunkList, useSwitchChunk } from '@/hooks/chunk-hooks'; import type { PaginationProps } from 'antd'; import { Divider, Flex, Pagination, Space, Spin, message } from 'antd'; @@ -46,6 +47,14 @@ const Chunk = () => { documentId, } = useUpdateChunk(); + // 获取选中的chunk + const selectedChunk = data.find((item) => item.chunk_id === selectedChunkId); + + // 获取图片ID,兼容两种字段名 + const getImageId = (chunk: any) => { + return chunk?.image_id || chunk?.img_id; + }; + const onPaginationChange: PaginationProps['onShowSizeChange'] = ( page, size, @@ -134,6 +143,35 @@ const Chunk = () => { > + {/* 左侧图片预览窗格 */} +
+

{t('关联图片显示区域')}

+ {selectedChunk ? ( + getImageId(selectedChunk) ? ( +
+ +
+ ) : ( +
+ {' '} +

{t('chunk.noImageAssociated', '此区块没有关联图片')}

+
+ ) + ) : ( +
+ {' '} +

+ {t( + 'chunk.selectChunkToViewImage', + '请选择一个块以查看其图片', + )} +

+
+ )} +
{ const { visible, hideModal, - showModal, onCreateOk, loading: creatingLoading, } = useSaveKnowledge(); @@ -67,15 +57,6 @@ const KnowledgeList = () => { onChange={handleInputChange} prefix={} /> - - {/**/}