From a4d1d3b16c0a2b3874b97aedf1d43b543d611f6f Mon Sep 17 00:00:00 2001 From: jialin Date: Wed, 25 Jun 2025 14:32:11 +0800 Subject: [PATCH] style: skeleton for search result --- .../llmodels/components/file-skeleton.tsx | 19 ++++- .../llmodels/components/hf-model-file.tsx | 2 +- .../llmodels/components/search-result.tsx | 81 +++++++++++++------ src/pages/llmodels/style/search-result.less | 4 + 4 files changed, 77 insertions(+), 29 deletions(-) diff --git a/src/pages/llmodels/components/file-skeleton.tsx b/src/pages/llmodels/components/file-skeleton.tsx index 37c0cd7f..93442adc 100644 --- a/src/pages/llmodels/components/file-skeleton.tsx +++ b/src/pages/llmodels/components/file-skeleton.tsx @@ -8,13 +8,24 @@ const Wrapper = styled(Flex)` background-color: var(--ant-color-bg-container); `; -const FileSkeleton = () => { +const FileSkeleton: React.FC<{ counts: number; itemHeight?: number }> = ({ + counts = 2, + itemHeight +}) => { return ( - + - - + {Array.from({ length: counts }).map((_, index) => ( + + ))} ); diff --git a/src/pages/llmodels/components/hf-model-file.tsx b/src/pages/llmodels/components/hf-model-file.tsx index 438ebc31..24385a74 100644 --- a/src/pages/llmodels/components/hf-model-file.tsx +++ b/src/pages/llmodels/components/hf-model-file.tsx @@ -385,7 +385,7 @@ const HFModelFile: React.FC = forwardRef((props, ref) => { {dataSource.loading ? ( {_.times(5, (index: number) => { - return ; + return ; })} ) : dataSource.fileList.length ? ( diff --git a/src/pages/llmodels/components/search-result.tsx b/src/pages/llmodels/components/search-result.tsx index 0e400e69..22dce824 100644 --- a/src/pages/llmodels/components/search-result.tsx +++ b/src/pages/llmodels/components/search-result.tsx @@ -2,11 +2,14 @@ import IconFont from '@/components/icon-font'; import SimpleOverlay from '@/components/simple-overlay'; import { SearchOutlined } from '@ant-design/icons'; import { useIntl } from '@umijs/max'; -import { Button, Col, Empty, Row, Spin } from 'antd'; +import { Button, Empty, Spin } from 'antd'; +import _ from 'lodash'; import React, { useMemo } from 'react'; import 'simplebar-react/dist/simplebar.min.css'; +import styled from 'styled-components'; import { modelSourceMap } from '../config'; import '../style/search-result.less'; +import FileSkeleton from './file-skeleton'; import HFModelItem from './hf-model-item'; interface SearchResultProps { @@ -20,6 +23,25 @@ interface SearchResultProps { isEvaluating?: boolean; } +const ItemFileWrapper = styled.div` + display: flex; + flex-direction: column; + justify-content: center; + width: 100%; + gap: 24px; +`; + +const SpinWrapper = styled.div` + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + bottom: 0; + display: flex; + justify-content: center; +`; + const SearchResult: React.FC = (props) => { const { resultList, onSelect, isEvaluating, source, networkError } = props; const intl = useIntl(); @@ -94,32 +116,43 @@ const SearchResult: React.FC = (props) => {
{resultList.length ? ( - + {resultList.map((item, index) => ( - -
handleSelect(e, item)} - onKeyDown={(e) => handleOnEnter(e, item)} - > - -
- +
handleSelect(e, item)} + onKeyDown={(e) => handleOnEnter(e, item)} + > + +
))} -
+ + ) : props.loading ? ( + + {_.times(10, (index: number) => { + return ( + + ); + })} + ) : ( - !props.loading && renderEmpty + renderEmpty )}
diff --git a/src/pages/llmodels/style/search-result.less b/src/pages/llmodels/style/search-result.less index 5941a5aa..f6b645aa 100644 --- a/src/pages/llmodels/style/search-result.less +++ b/src/pages/llmodels/style/search-result.less @@ -3,6 +3,10 @@ .search-result-wrap { padding: 16px @padding; border-radius: 0 0 var(--border-radius-base) var(--border-radius-base); + + .ant-spin-container.ant-spin-blur { + opacity: unset; + } } .gguf-tips {