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
yangchenggong1_wd
2024-09-19 14:17:26 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
6cb302d1af90d2eaf5485f47e131a504163de055
6cb302d1
1 parent
ed5ab62a
fix |> 20369 根据关键字搜索号主,搜索结果号主tab,号主的名称里面没有对关键字高亮显示红色
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
69 additions
and
5 deletions
sight_harmony/features/wdComponent/src/main/ets/components/mine/follow/FollowChildComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/search/SearchCreatorComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/search/SearchResultContentComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/mine/follow/FollowChildComponent.ets
View file @
6cb302d
...
...
@@ -4,6 +4,7 @@ import { HttpUtils } from 'wdNetwork/Index'
import { WDRouterRule, WDRouterPage } from 'wdRouter/Index'
import { TrackConstants, TrackingContent } from 'wdTracking/Index'
import MinePageDatasModel from '../../../model/MinePageDatasModel'
import { SearchShowRed, titleInitRes, textItem } from '../../../utils/searchShowRed'
import { FollowListDetailItem } from '../../../viewmodel/FollowListDetailItem'
import { FollowOperationRequestItem } from '../../../viewmodel/FollowOperationRequestItem'
...
...
@@ -14,6 +15,7 @@ export struct FollowChildComponent{
@State columnHeight:number = 202
@State isLoadingAttention:boolean = false
@State searchText:string = ""
aboutToAppear(): void {
if(this.type == 0 && StringUtils.isEmpty(this.data.introduction)){
...
...
@@ -190,7 +192,20 @@ export struct FollowChildComponent{
.margin({right: 11})
Column(){
Text(this.data.cnUserName)
Text(){
if (StringUtils.isNotEmpty(this.searchText) && this.titleInit(this.data.cnUserName, this.searchText).titleMarked) {
ForEach(this.titleInit(this.data.cnUserName, this.searchText).textArr, (textItem: textItem) => {
if (textItem.isRed) {
Span(textItem.content)
.fontColor("#ED2800")
} else {
Span(textItem.content)
}
})
} else {
Span(this.data.cnUserName)
}
}
.fontWeight(400)
.fontSize(18)
.lineHeight(22)
...
...
@@ -351,4 +366,21 @@ export struct FollowChildComponent{
WDRouterRule.jumpWithPage(WDRouterPage.peopleShipHomePage, params)
}
}
// 正则过滤检索词
createCaseInsensitiveRegex(str: string, pattern: string) {
let regex = new RegExp(pattern, 'gi');
return str.replace(regex, (match) => `<em>${match}</em>`);
}
checkForPattern(str: string, pattern: string) {
let highlightedStr = this.createCaseInsensitiveRegex(str, pattern);
return highlightedStr;
}
titleInit(str: string, pattern: string) {
const title = this.checkForPattern(str, pattern)
const titleInitRes:titleInitRes = SearchShowRed.titleInit(title)
return titleInitRes
}
}
\ No newline at end of file
...
...
sight_harmony/features/wdComponent/src/main/ets/components/search/SearchCreatorComponent.ets
View file @
6cb302d
import { ToastUtils } from 'wdKit/Index'
import {
StringUtils,
ToastUtils } from 'wdKit/Index'
import { WDRouterRule, WDRouterPage, ProcessUtils } from 'wdRouter/Index'
import { SearchShowRed, titleInitRes, textItem } from '../../utils/searchShowRed'
import { SearchRmhDescription } from '../../viewmodel/SearchResultContentItem'
@Component
export struct SearchCreatorComponent{
@ObjectLink item: SearchRmhDescription
userName: string = ''
@State searchText:string = ""
aboutToAppear(): void {
const userNetName: string = this.item.creatorName;
...
...
@@ -38,7 +40,20 @@ export struct SearchCreatorComponent{
.height('92lpx')
.margin({bottom:'15lpx'})
Text(this.userName)
Text(){
if (StringUtils.isNotEmpty(this.searchText) && this.titleInit(this.userName, this.searchText).titleMarked) {
ForEach(this.titleInit(this.userName, this.searchText).textArr, (textItem: textItem) => {
if (textItem.isRed) {
Span(textItem.content)
.fontColor("#ED2800")
} else {
Span(textItem.content)
}
})
} else {
Span(this.userName)
}
}
.fontSize('25lpx')
.fontWeight('400lpx')
.lineHeight('35lpx')
...
...
@@ -62,4 +77,21 @@ export struct SearchCreatorComponent{
WDRouterRule.jumpWithPage(WDRouterPage.peopleShipHomePage, params)
}
}
// 正则过滤检索词
createCaseInsensitiveRegex(str: string, pattern: string) {
let regex = new RegExp(pattern, 'gi');
return str.replace(regex, (match) => `<em>${match}</em>`);
}
checkForPattern(str: string, pattern: string) {
let highlightedStr = this.createCaseInsensitiveRegex(str, pattern);
return highlightedStr;
}
titleInit(str: string, pattern: string) {
const title = this.checkForPattern(str, pattern)
const titleInitRes:titleInitRes = SearchShowRed.titleInit(title)
return titleInitRes
}
}
\ No newline at end of file
...
...
sight_harmony/features/wdComponent/src/main/ets/components/search/SearchResultContentComponent.ets
View file @
6cb302d
...
...
@@ -282,7 +282,7 @@ export struct SearchResultContentComponent {
if (this.data_rmh != null && this.data_rmh.length > 0) {
if (this.data_rmh.length === 1) {
ListItem() {
FollowChildComponent({ data: this.bean, type: 1 })
FollowChildComponent({ data: this.bean, type: 1
,searchText: decodeURI(this.keywords)
})
}.padding({ left: "31lpx", right: "31lpx" })
} else {
ListItem() {
...
...
@@ -356,7 +356,7 @@ export struct SearchResultContentComponent {
ListItemGroup() {
ForEach(this.data_rmh, (item: SearchRmhDescription, index: number) => {
ListItem() {
SearchCreatorComponent({ item: item })
SearchCreatorComponent({ item: item
,searchText: decodeURI(this.keywords)
})
}
.width('150lpx')
.height('100%')
...
...
Please
register
or
login
to post a comment