Toggle navigation
Toggle navigation
This project
Loading...
Sign in
developOne
/
harmonyPool
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
陈剑华
2024-05-29 15:26:40 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
395b4960d693b4aa7b6738d0822ace65700539a7
395b4960
1 parent
778f7c85
feat: 18024 搜索结果-时间轴专题样式卡,显示标题的时间轴卡,标题展示不全,见截图
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
16 deletions
sight_harmony/features/wdComponent/src/main/ets/utils/searchShowRed.ets
sight_harmony/features/wdComponent/src/main/ets/utils/searchShowRed.ets
View file @
395b496
...
...
@@ -27,32 +27,60 @@ export class SearchShowRed {
res.push(content);
}
SearchShowRed.formatTitle(html, res, 0, textArr);
console.log('SearchShowRed-res', JSON.stringify(res))
SearchShowRed.formatTitle(
html.replaceAll('<em>', '').replaceAll('</em>', ''),
res,
0,
textArr
);
}
const titleInitRes: titleInitRes = {
titleMarked,
textArr
}
console.log('SearchShowRed-titleInitRes', JSON.stringify(titleInitRes))
return titleInitRes
}
private static formatTitle(textStr: string, matchArr: string[], index: number, textArr: textItem[]) {
const item: string = matchArr[index];
const arr = textStr.split(item);
arr.forEach((str: string, ind: number) => {
if (ind === 0) {
textArr.push({
content: str.replaceAll('<em>', '').replaceAll('</em>', ''),
isRed: false
} as textItem)
textArr.push({
content: item,
isRed: true
})
} else if (ind === 1) {
SearchShowRed.formatTitle(str, matchArr, index + 1, textArr)
}
})
if (!item) {
textArr.push({
content: textStr,
isRed: false
})
return;
}
const ind = textStr.indexOf(item);
const len = item.length;
if (ind === 0) {
textArr.push({
content: item,
isRed: true
})
SearchShowRed.formatTitle(textStr.slice(len), matchArr, index + 1, textArr);
} else if (ind + len === textStr.length) {
textArr.push({
content: textStr.slice(0, ind),
isRed: false
})
textArr.push({
content: item,
isRed: true
})
} else {
textArr.push({
content: textStr.slice(0, ind),
isRed: false
})
textArr.push({
content: item,
isRed: true
})
SearchShowRed.formatTitle(textStr.slice(ind + len), matchArr, index + 1, textArr);
}
}
}
\ No newline at end of file
...
...
Please
register
or
login
to post a comment