Commit 227e2dbf by zhaochengxiang

bug fix

parent 53dd0472
......@@ -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 ((terms||[]).length===0 || typeof(content)!=='string') return content;
......@@ -241,7 +241,10 @@ export function searchContentAddDecorate(content, terms, matchCount=0) {
let start = -1;
let useTerm = '';
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 (start === -1) {
......@@ -265,12 +268,12 @@ export function searchContentAddDecorate(content, terms, matchCount=0) {
return content;
}
export function highlightSearchContentByTerms(content, terms) {
export function highlightSearchContentByTerms(content, terms, caseSensitive = false) {
if (!content || content==='') return '';
if ((terms||[]).length===0 || typeof(content)!=='string') return content;
let processContent = content;
processContent = searchContentAddDecorate(processContent, terms);
processContent = searchContentAddDecorate(processContent, terms, 0, caseSensitive);
return highlightSearchContent(processContent);
}
......
......@@ -6,7 +6,7 @@ import { useDebounceEffect } from 'ahooks'
import { appId } from "../../../App"
import { dispatch } from '../../../model'
import Table from '../ResizeableTable'
import { isSzseEnv, showMessage } from "../../../util"
import { highlightSearchContentByTerms, isSzseEnv, showMessage } from "../../../util"
import { AssetItem } from "../AssetManage/Component/AssetTable"
import UpdateAsset from "../AssetManage/Component/AssetDetailDrawer"
import { AssetDraftReference } from "../../../util/constant"
......@@ -92,7 +92,7 @@ const FC = (props) => {
return (
<Tooltip title={text}>
<Typography.Text ellipsis={true}>
{text}
{highlightSearchContentByTerms(text, [keyword??''], true)}
</Typography.Text>
</Tooltip>
);
......@@ -141,7 +141,7 @@ const FC = (props) => {
return (
<Tooltip title={text}>
<Typography.Text ellipsis={true}>
{text}
{highlightSearchContentByTerms(text, [keyword??''], true)}
</Typography.Text>
</Tooltip>
);
......@@ -164,7 +164,7 @@ const FC = (props) => {
metadata = text;
}
return (
<AssetItem metadata={metadata} />
<AssetItem metadata={metadata} terms={[keyword??'']} />
);
}
}
......@@ -201,7 +201,7 @@ const FC = (props) => {
return [[pathCol, ...newColumns, ...fixedCols]
, newTableData, data?.total??0]
}, [filterElements, data, loadingFilterElements, users, fixedCols])
}, [filterElements, data, loadingFilterElements, users, fixedCols, keyword, pathCol])
const getAdmin = () => {
dispatch({
......
......@@ -82,7 +82,7 @@ export const AssetItem = (props) => {
</div>}
>
<Text ellipsis={true}>
{highlightSearchContentByTerms(content, terms)}
{highlightSearchContentByTerms(content, terms, true)}
</Text>
</Tooltip>
);
......@@ -410,7 +410,7 @@ const AssetTable = (props) => {
return (
<Tooltip title={text||''}>
<Text ellipsis={true}>
{highlightSearchContentByTerms(text, [keyword])}
{highlightSearchContentByTerms(text, [keyword??''], true)}
</Text>
</Tooltip>
);
......@@ -440,7 +440,7 @@ const AssetTable = (props) => {
params.render = (metadata, _) => {
return (
<AssetItem metadata={metadata} terms={[keyword]} />
<AssetItem metadata={metadata} terms={[keyword??'']} />
);
}
......@@ -456,7 +456,7 @@ const AssetTable = (props) => {
event.dirId = record.dirId||'';
window?.dispatchEvent(event);
}}>
{highlightSearchContentByTerms(text, [keyword])}
{highlightSearchContentByTerms(text, [keyword??''], true)}
</a>
</Text>
</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