chore: search by debounce
This commit is contained in:
@@ -147,13 +147,13 @@ const Catalog: React.FC = () => {
|
|||||||
fetchData();
|
fetchData();
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleNameChange = (e: any) => {
|
const handleNameChange = _.debounce((e: any) => {
|
||||||
setQueryParams({
|
setQueryParams({
|
||||||
...queryParams,
|
...queryParams,
|
||||||
page: 1,
|
page: 1,
|
||||||
search: e.target.value
|
search: e.target.value
|
||||||
});
|
});
|
||||||
};
|
}, 350);
|
||||||
|
|
||||||
const handleCategoryChange = (value: any) => {
|
const handleCategoryChange = (value: any) => {
|
||||||
setQueryParams({
|
setQueryParams({
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
import fallbackImg from '@/assets/images/img.png';
|
import fallbackImg from '@/assets/images/img.png';
|
||||||
import IMG from '@/assets/images/small-logo-200x200.png';
|
|
||||||
import AutoTooltip from '@/components/auto-tooltip';
|
import AutoTooltip from '@/components/auto-tooltip';
|
||||||
import IconFont from '@/components/icon-font';
|
import IconFont from '@/components/icon-font';
|
||||||
import TagWrapper from '@/components/tags-wrapper';
|
import TagWrapper from '@/components/tags-wrapper';
|
||||||
import { Tag, Typography } from 'antd';
|
import { Tag, Typography } from 'antd';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import React, { useCallback, useMemo } from 'react';
|
import React, { useCallback } from 'react';
|
||||||
import { modelCategories } from '../config';
|
import { modelCategories } from '../config';
|
||||||
import { CatalogItem as CatalogItemType } from '../config/types';
|
import { CatalogItem as CatalogItemType } from '../config/types';
|
||||||
import '../style/catalog-item.less';
|
import '../style/catalog-item.less';
|
||||||
@@ -24,15 +23,6 @@ const CatalogItem: React.FC<CatalogItemProps> = (props) => {
|
|||||||
onClick(data);
|
onClick(data);
|
||||||
}, [data, onClick]);
|
}, [data, onClick]);
|
||||||
|
|
||||||
const icon = useMemo(() => {
|
|
||||||
const home = data.home?.replace(/\/$/, '');
|
|
||||||
const icon = data.icon?.replace(/^\//, '');
|
|
||||||
if (icon) {
|
|
||||||
return data.icon;
|
|
||||||
}
|
|
||||||
return IMG;
|
|
||||||
}, [data]);
|
|
||||||
|
|
||||||
const handleOnError = (e: any) => {
|
const handleOnError = (e: any) => {
|
||||||
e.target.src = fallbackImg;
|
e.target.src = fallbackImg;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user