Commit 227e2dbf by zhaochengxiang

bug fix

parent 53dd0472
...@@ -232,7 +232,7 @@ function highlightSearchContent(content) { ...@@ -232,7 +232,7 @@ function highlightSearchContent(content) {
) )
} }
export function searchContentAddDecorate(content, terms, matchCount=0) { export function searchContentAddDecorate(content, terms, matchCount=0, caseSensitive = false) {
if (!content || content==='') return ''; if (!content || content==='') return '';
if ((terms||[]).length===0 || typeof(content)!=='string') return content; if ((terms||[]).length===0 || typeof(content)!=='string') return content;
...@@ -241,7 +241,10 @@ export function searchContentAddDecorate(content, terms, matchCount=0) { ...@@ -241,7 +241,10 @@ export function searchContentAddDecorate(content, terms, matchCount=0) {
let start = -1; let start = -1;
let useTerm = ''; let useTerm = '';
terms.forEach(term => { terms.forEach(term => {
const index = content.indexOf(term); let index = content.indexOf(term);
if (caseSensitive) {
index = content.toLowerCase().indexOf(term.toLowerCase())
}
if (index !== -1) { if (index !== -1) {
if (start === -1) { if (start === -1) {
...@@ -265,12 +268,12 @@ export function searchContentAddDecorate(content, terms, matchCount=0) { ...@@ -265,12 +268,12 @@ export function searchContentAddDecorate(content, terms, matchCount=0) {
return content; return content;
} }
export function highlightSearchContentByTerms(content, terms) { export function highlightSearchContentByTerms(content, terms, caseSensitive = false) {
if (!content || content==='') return ''; if (!content || content==='') return '';
if ((terms||[]).length===0 || typeof(content)!=='string') return content; if ((terms||[]).length===0 || typeof(content)!=='string') return content;
let processContent = content; let processContent = content;
processContent = searchContentAddDecorate(processContent, terms); processContent = searchContentAddDecorate(processContent, terms, 0, caseSensitive);
return highlightSearchContent(processContent); return highlightSearchContent(processContent);
} }
......
...@@ -6,7 +6,7 @@ import { useDebounceEffect } from 'ahooks' ...@@ -6,7 +6,7 @@ import { useDebounceEffect } from 'ahooks'
import { appId } from "../../../App" import { appId } from "../../../App"
import { dispatch } from '../../../model' import { dispatch } from '../../../model'
import Table from '../ResizeableTable' import Table from '../ResizeableTable'
import { isSzseEnv, showMessage } from "../../../util" import { highlightSearchContentByTerms, isSzseEnv, showMessage } from "../../../util"
import { AssetItem } from "../AssetManage/Component/AssetTable" import { AssetItem } from "../AssetManage/Component/AssetTable"
import UpdateAsset from "../AssetManage/Component/AssetDetailDrawer" import UpdateAsset from "../AssetManage/Component/AssetDetailDrawer"
import { AssetDraftReference } from "../../../util/constant" import { AssetDraftReference } from "../../../util/constant"
...@@ -92,7 +92,7 @@ const FC = (props) => { ...@@ -92,7 +92,7 @@ const FC = (props) => {
return ( return (
<Tooltip title={text}> <Tooltip title={text}>
<Typography.Text ellipsis={true}> <Typography.Text ellipsis={true}>
{text} {highlightSearchContentByTerms(text, [keyword??''], true)}
</Typography.Text> </Typography.Text>
</Tooltip> </Tooltip>
); );
...@@ -141,7 +141,7 @@ const FC = (props) => { ...@@ -141,7 +141,7 @@ const FC = (props) => {
return ( return (
<Tooltip title={text}> <Tooltip title={text}>
<Typography.Text ellipsis={true}> <Typography.Text ellipsis={true}>
{text} {highlightSearchContentByTerms(text, [keyword??''], true)}
</Typography.Text> </Typography.Text>
</Tooltip> </Tooltip>
); );
...@@ -164,7 +164,7 @@ const FC = (props) => { ...@@ -164,7 +164,7 @@ const FC = (props) => {
metadata = text; metadata = text;
} }
return ( return (
<AssetItem metadata={metadata} /> <AssetItem metadata={metadata} terms={[keyword??'']} />
); );
} }
} }
...@@ -201,7 +201,7 @@ const FC = (props) => { ...@@ -201,7 +201,7 @@ const FC = (props) => {
return [[pathCol, ...newColumns, ...fixedCols] return [[pathCol, ...newColumns, ...fixedCols]
, newTableData, data?.total??0] , newTableData, data?.total??0]
}, [filterElements, data, loadingFilterElements, users, fixedCols]) }, [filterElements, data, loadingFilterElements, users, fixedCols, keyword, pathCol])
const getAdmin = () => { const getAdmin = () => {
dispatch({ dispatch({
......
...@@ -82,7 +82,7 @@ export const AssetItem = (props) => { ...@@ -82,7 +82,7 @@ export const AssetItem = (props) => {
</div>} </div>}
> >
<Text ellipsis={true}> <Text ellipsis={true}>
{highlightSearchContentByTerms(content, terms)} {highlightSearchContentByTerms(content, terms, true)}
</Text> </Text>
</Tooltip> </Tooltip>
); );
...@@ -410,7 +410,7 @@ const AssetTable = (props) => { ...@@ -410,7 +410,7 @@ const AssetTable = (props) => {
return ( return (
<Tooltip title={text||''}> <Tooltip title={text||''}>
<Text ellipsis={true}> <Text ellipsis={true}>
{highlightSearchContentByTerms(text, [keyword])} {highlightSearchContentByTerms(text, [keyword??''], true)}
</Text> </Text>
</Tooltip> </Tooltip>
); );
...@@ -440,7 +440,7 @@ const AssetTable = (props) => { ...@@ -440,7 +440,7 @@ const AssetTable = (props) => {
params.render = (metadata, _) => { params.render = (metadata, _) => {
return ( return (
<AssetItem metadata={metadata} terms={[keyword]} /> <AssetItem metadata={metadata} terms={[keyword??'']} />
); );
} }
...@@ -456,7 +456,7 @@ const AssetTable = (props) => { ...@@ -456,7 +456,7 @@ const AssetTable = (props) => {
event.dirId = record.dirId||''; event.dirId = record.dirId||'';
window?.dispatchEvent(event); window?.dispatchEvent(event);
}}> }}>
{highlightSearchContentByTerms(text, [keyword])} {highlightSearchContentByTerms(text, [keyword??''], true)}
</a> </a>
</Text> </Text>
</Tooltip> </Tooltip>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment