diff --git a/src/pages/videos/list/index.tsx b/src/pages/videos/list/index.tsx index ff98510..12e6e9d 100644 --- a/src/pages/videos/list/index.tsx +++ b/src/pages/videos/list/index.tsx @@ -41,6 +41,7 @@ const Video = () => { const { data: category, isLoading: isCategoryFetching } = useAtomValue(categoryByIdAtom) const [ open, setOpen ] = useState(false) const [ openFilter, setFilterOpen ] = useState(false) + const [ searchKey, setSearchKey ] = useState(search?.title) const columns = useMemo(() => { return [ @@ -69,6 +70,12 @@ const Video = () => { colProps: { span: 8 }, + render: (_text, record) => { + //高亮搜索关键字, 从search.title中获取 + const title = record.title?.replace?.(new RegExp(`(${search?.title})`, 'ig'), '$1') + + return + } }, { 'title': t(`${i18nPrefix}.columns.title_sub`, 'TitleSub'), @@ -79,6 +86,12 @@ const Video = () => { }, colProps: { span: 16 + }, + render: (_text, record) => { + //高亮搜索关键字, 从search.title中获取 + const title = record.title_sub?.replace?.(new RegExp(`(${search?.title_sub})`, 'ig'), '$1') + + return } }, { @@ -158,7 +171,7 @@ const Video = () => { const props = { ...config } as any delete props.mode const isForm = config.type === 'form' - let value = isForm && config.value ? dayjs().set('year', config.value) : undefined + let value = isForm && config.value ? dayjs().set('year', config.value) : undefined if (config.value?.$isDayjsObject) { value = config.value as dayjs.Dayjs } @@ -558,6 +571,7 @@ const Video = () => { useEffect(() => { + setSearchKey(search?.title) filterForm.setFieldsValue(search) }, [ search ]) @@ -575,19 +589,23 @@ const Video = () => { headerTitle={t(`${i18nPrefix}.title`, '视频管理')} toolbar={{ search: { - loading: isFetching && !!search.key, + loading: isFetching && !!search.title, onSearch: (value: string) => { setSearch(prev => ({ ...prev, - key: value + title: value })) }, allowClear: true, + onChange: (e) => { + setSearchKey(e.target?.value) + }, + value: searchKey, placeholder: t(`${i18nPrefix}.placeholder`, '输入视频名称') }, actions: [ - +