陈剑华

Merge remote-tracking branch 'origin/main'

@@ -2,7 +2,7 @@ import { CompDTO, ContentDTO } from 'wdBean'; @@ -2,7 +2,7 @@ import { CompDTO, ContentDTO } from 'wdBean';
2 import { ProcessUtils } from 'wdRouter'; 2 import { ProcessUtils } from 'wdRouter';
3 import { onlyWifiLoadImg } from '../../utils/lazyloadImg'; 3 import { onlyWifiLoadImg } from '../../utils/lazyloadImg';
4 import { hasClicked, persistentStorage } from '../../utils/persistentStorage'; 4 import { hasClicked, persistentStorage } from '../../utils/persistentStorage';
5 -import { DateTimeUtils } from 'wdKit/Index'; 5 +import { DateTimeUtils, NumberFormatterUtils } from 'wdKit/Index';
6 import { LottieView } from '../lottie/LottieView'; 6 import { LottieView } from '../lottie/LottieView';
7 import { router } from '@kit.ArkUI'; 7 import { router } from '@kit.ArkUI';
8 8
@@ -155,13 +155,6 @@ export struct LiveBigImage02Component { @@ -155,13 +155,6 @@ export struct LiveBigImage02Component {
155 } 155 }
156 156
157 private computeShowNum(count: number): string { 157 private computeShowNum(count: number): string {
158 - if (count >= 10000) {  
159 - let num = (count / 10000).toFixed(1)  
160 - if (Number(num.substring(num.length - 1)) == 0) {  
161 - num = num.substring(0, num.length - 2)  
162 - }  
163 - return num + '万人参加'  
164 - }  
165 - return `${count}人参加` 158 + return NumberFormatterUtils.formatNumberWithWan(count) + '人参加'
166 } 159 }
167 } 160 }
1 import { CompDTO, ContentDTO, LiveRoomDataBean } from 'wdBean'; 1 import { CompDTO, ContentDTO, LiveRoomDataBean } from 'wdBean';
2 import { CommonConstants } from 'wdConstant/Index'; 2 import { CommonConstants } from 'wdConstant/Index';
3 -import { Logger } from 'wdKit/Index'; 3 +import { Logger, NumberFormatterUtils } from 'wdKit/Index';
4 import { ProcessUtils } from 'wdRouter'; 4 import { ProcessUtils } from 'wdRouter';
5 import PageViewModel from '../../viewmodel/PageViewModel'; 5 import PageViewModel from '../../viewmodel/PageViewModel';
6 import { onlyWifiLoadImg } from '../../utils/lazyloadImg'; 6 import { onlyWifiLoadImg } from '../../utils/lazyloadImg';
@@ -98,15 +98,7 @@ export struct ZhGridLayout02NewsContent { @@ -98,15 +98,7 @@ export struct ZhGridLayout02NewsContent {
98 } 98 }
99 99
100 private computeShowNum(bean: LiveRoomDataBean): string { 100 private computeShowNum(bean: LiveRoomDataBean): string {
101 - let count = bean.pv  
102 - if (count >= 10000) {  
103 - let num = (count / 10000).toFixed(1)  
104 - if (Number(num.substring(num.length - 1)) == 0) {  
105 - num = num.substring(0, num.length - 2)  
106 - }  
107 - return num + '万人参加'  
108 - }  
109 - return `${count}人参加` 101 + return NumberFormatterUtils.formatNumberWithWan(bean.pv) + '人参加'
110 } 102 }
111 } 103 }
112 104
@@ -4,6 +4,7 @@ import { HttpUtils } from 'wdNetwork/Index' @@ -4,6 +4,7 @@ import { HttpUtils } from 'wdNetwork/Index'
4 import { WDRouterRule, WDRouterPage } from 'wdRouter/Index' 4 import { WDRouterRule, WDRouterPage } from 'wdRouter/Index'
5 import { TrackConstants, TrackingContent } from 'wdTracking/Index' 5 import { TrackConstants, TrackingContent } from 'wdTracking/Index'
6 import MinePageDatasModel from '../../../model/MinePageDatasModel' 6 import MinePageDatasModel from '../../../model/MinePageDatasModel'
  7 +import { SearchShowRed, titleInitRes, textItem } from '../../../utils/searchShowRed'
7 import { FollowListDetailItem } from '../../../viewmodel/FollowListDetailItem' 8 import { FollowListDetailItem } from '../../../viewmodel/FollowListDetailItem'
8 import { FollowOperationRequestItem } from '../../../viewmodel/FollowOperationRequestItem' 9 import { FollowOperationRequestItem } from '../../../viewmodel/FollowOperationRequestItem'
9 10
@@ -14,6 +15,7 @@ export struct FollowChildComponent{ @@ -14,6 +15,7 @@ export struct FollowChildComponent{
14 @State columnHeight:number = 202 15 @State columnHeight:number = 202
15 16
16 @State isLoadingAttention:boolean = false 17 @State isLoadingAttention:boolean = false
  18 + @State searchText:string = ""
17 19
18 aboutToAppear(): void { 20 aboutToAppear(): void {
19 if(this.type == 0 && StringUtils.isEmpty(this.data.introduction)){ 21 if(this.type == 0 && StringUtils.isEmpty(this.data.introduction)){
@@ -190,7 +192,20 @@ export struct FollowChildComponent{ @@ -190,7 +192,20 @@ export struct FollowChildComponent{
190 .margin({right: 11}) 192 .margin({right: 11})
191 193
192 Column(){ 194 Column(){
193 - Text(this.data.cnUserName) 195 + Text(){
  196 + if (StringUtils.isNotEmpty(this.searchText) && this.titleInit(this.data.cnUserName, this.searchText).titleMarked) {
  197 + ForEach(this.titleInit(this.data.cnUserName, this.searchText).textArr, (textItem: textItem) => {
  198 + if (textItem.isRed) {
  199 + Span(textItem.content)
  200 + .fontColor("#ED2800")
  201 + } else {
  202 + Span(textItem.content)
  203 + }
  204 + })
  205 + } else {
  206 + Span(this.data.cnUserName)
  207 + }
  208 + }
194 .fontWeight(400) 209 .fontWeight(400)
195 .fontSize(18) 210 .fontSize(18)
196 .lineHeight(22) 211 .lineHeight(22)
@@ -351,4 +366,21 @@ export struct FollowChildComponent{ @@ -351,4 +366,21 @@ export struct FollowChildComponent{
351 WDRouterRule.jumpWithPage(WDRouterPage.peopleShipHomePage, params) 366 WDRouterRule.jumpWithPage(WDRouterPage.peopleShipHomePage, params)
352 } 367 }
353 } 368 }
  369 +
  370 + // 正则过滤检索词
  371 + createCaseInsensitiveRegex(str: string, pattern: string) {
  372 + let regex = new RegExp(pattern, 'gi');
  373 + return str.replace(regex, (match) => `<em>${match}</em>`);
  374 + }
  375 +
  376 + checkForPattern(str: string, pattern: string) {
  377 + let highlightedStr = this.createCaseInsensitiveRegex(str, pattern);
  378 + return highlightedStr;
  379 + }
  380 +
  381 + titleInit(str: string, pattern: string) {
  382 + const title = this.checkForPattern(str, pattern)
  383 + const titleInitRes:titleInitRes = SearchShowRed.titleInit(title)
  384 + return titleInitRes
  385 + }
354 } 386 }
1 import measure from '@ohos.measure' 1 import measure from '@ohos.measure'
2 -import { DisplayUtils } from 'wdKit' 2 +import { DisplayUtils, NumberFormatterUtils } from 'wdKit'
3 import { PeopleShipHomePageHeadComponent } from './PeopleShipHomePageHeadComponent' 3 import { PeopleShipHomePageHeadComponent } from './PeopleShipHomePageHeadComponent'
4 import { PeopleShipHomePageAttestationComponent } from './PeopleShipHomePageAttestationComponent' 4 import { PeopleShipHomePageAttestationComponent } from './PeopleShipHomePageAttestationComponent'
5 import { Logger } from 'wdKit' 5 import { Logger } from 'wdKit'
@@ -366,14 +366,7 @@ export struct PeopleShipHomePageTopComponent { @@ -366,14 +366,7 @@ export struct PeopleShipHomePageTopComponent {
366 } 366 }
367 367
368 private computeShowNum(count: number) { 368 private computeShowNum(count: number) {
369 - if (count >= 10000) {  
370 - let num = ( count / 10000).toFixed(1)  
371 - if (Number(num.substring(num.length-1)) == 0) {  
372 - num = num.substring(0, num.length-2)  
373 - }  
374 - return num + '万'  
375 - }  
376 - return `${count}` 369 + return NumberFormatterUtils.formatNumberWithWan(count)
377 } 370 }
378 371
379 // 通过省份code获取IP问题 372 // 通过省份code获取IP问题
1 -import { ToastUtils } from 'wdKit/Index' 1 +import { StringUtils, ToastUtils } from 'wdKit/Index'
2 import { WDRouterRule, WDRouterPage, ProcessUtils } from 'wdRouter/Index' 2 import { WDRouterRule, WDRouterPage, ProcessUtils } from 'wdRouter/Index'
  3 +import { SearchShowRed, titleInitRes, textItem } from '../../utils/searchShowRed'
3 import { SearchRmhDescription } from '../../viewmodel/SearchResultContentItem' 4 import { SearchRmhDescription } from '../../viewmodel/SearchResultContentItem'
4 5
5 @Component 6 @Component
6 export struct SearchCreatorComponent{ 7 export struct SearchCreatorComponent{
7 @ObjectLink item: SearchRmhDescription 8 @ObjectLink item: SearchRmhDescription
8 userName: string = '' 9 userName: string = ''
  10 + @State searchText:string = ""
9 11
10 aboutToAppear(): void { 12 aboutToAppear(): void {
11 const userNetName: string = this.item.creatorName; 13 const userNetName: string = this.item.creatorName;
@@ -38,7 +40,20 @@ export struct SearchCreatorComponent{ @@ -38,7 +40,20 @@ export struct SearchCreatorComponent{
38 .height('92lpx') 40 .height('92lpx')
39 .margin({bottom:'15lpx'}) 41 .margin({bottom:'15lpx'})
40 42
41 - Text(this.userName) 43 + Text(){
  44 + if (StringUtils.isNotEmpty(this.searchText) && this.titleInit(this.userName, this.searchText).titleMarked) {
  45 + ForEach(this.titleInit(this.userName, this.searchText).textArr, (textItem: textItem) => {
  46 + if (textItem.isRed) {
  47 + Span(textItem.content)
  48 + .fontColor("#ED2800")
  49 + } else {
  50 + Span(textItem.content)
  51 + }
  52 + })
  53 + } else {
  54 + Span(this.userName)
  55 + }
  56 + }
42 .fontSize('25lpx') 57 .fontSize('25lpx')
43 .fontWeight('400lpx') 58 .fontWeight('400lpx')
44 .lineHeight('35lpx') 59 .lineHeight('35lpx')
@@ -62,4 +77,21 @@ export struct SearchCreatorComponent{ @@ -62,4 +77,21 @@ export struct SearchCreatorComponent{
62 WDRouterRule.jumpWithPage(WDRouterPage.peopleShipHomePage, params) 77 WDRouterRule.jumpWithPage(WDRouterPage.peopleShipHomePage, params)
63 } 78 }
64 } 79 }
  80 +
  81 + // 正则过滤检索词
  82 + createCaseInsensitiveRegex(str: string, pattern: string) {
  83 + let regex = new RegExp(pattern, 'gi');
  84 + return str.replace(regex, (match) => `<em>${match}</em>`);
  85 + }
  86 +
  87 + checkForPattern(str: string, pattern: string) {
  88 + let highlightedStr = this.createCaseInsensitiveRegex(str, pattern);
  89 + return highlightedStr;
  90 + }
  91 +
  92 + titleInit(str: string, pattern: string) {
  93 + const title = this.checkForPattern(str, pattern)
  94 + const titleInitRes:titleInitRes = SearchShowRed.titleInit(title)
  95 + return titleInitRes
  96 + }
65 } 97 }
@@ -282,7 +282,7 @@ export struct SearchResultContentComponent { @@ -282,7 +282,7 @@ export struct SearchResultContentComponent {
282 if (this.data_rmh != null && this.data_rmh.length > 0) { 282 if (this.data_rmh != null && this.data_rmh.length > 0) {
283 if (this.data_rmh.length === 1) { 283 if (this.data_rmh.length === 1) {
284 ListItem() { 284 ListItem() {
285 - FollowChildComponent({ data: this.bean, type: 1 }) 285 + FollowChildComponent({ data: this.bean, type: 1 ,searchText: decodeURI(this.keywords)})
286 }.padding({ left: "31lpx", right: "31lpx" }) 286 }.padding({ left: "31lpx", right: "31lpx" })
287 } else { 287 } else {
288 ListItem() { 288 ListItem() {
@@ -356,7 +356,7 @@ export struct SearchResultContentComponent { @@ -356,7 +356,7 @@ export struct SearchResultContentComponent {
356 ListItemGroup() { 356 ListItemGroup() {
357 ForEach(this.data_rmh, (item: SearchRmhDescription, index: number) => { 357 ForEach(this.data_rmh, (item: SearchRmhDescription, index: number) => {
358 ListItem() { 358 ListItem() {
359 - SearchCreatorComponent({ item: item }) 359 + SearchCreatorComponent({ item: item ,searchText: decodeURI(this.keywords)})
360 } 360 }
361 .width('150lpx') 361 .width('150lpx')
362 .height('100%') 362 .height('100%')