王士厅
Showing 19 changed files with 268 additions and 240 deletions
@@ -6,6 +6,7 @@ import { CardMediaInfo } from '../cardCommon/CardMediaInfo'; @@ -6,6 +6,7 @@ import { CardMediaInfo } from '../cardCommon/CardMediaInfo';
6 import { Notes } from './notes'; 6 import { Notes } from './notes';
7 import { onlyWifiLoadImg } from '../../utils/lazyloadImg'; 7 import { onlyWifiLoadImg } from '../../utils/lazyloadImg';
8 import { InfomationCardClick } from '../../utils/infomationCardClick' 8 import { InfomationCardClick } from '../../utils/infomationCardClick'
  9 +import { SearchShowRed, titleInitRes, textItem } from '../../utils/searchShowRed';
9 10
10 /** 11 /**
11 * 大专题卡--CompStyle: 10 12 * 大专题卡--CompStyle: 10
@@ -21,9 +22,7 @@ export struct Card10Component { @@ -21,9 +22,7 @@ export struct Card10Component {
21 @State loadImg: boolean = false; 22 @State loadImg: boolean = false;
22 @ObjectLink compDTO: CompDTO 23 @ObjectLink compDTO: CompDTO
23 @State titleMarked: boolean = false; 24 @State titleMarked: boolean = false;
24 - @State str01: string = '';  
25 - @State str02: string = '';  
26 - @State str03: string = ''; 25 + @State textArr: textItem[] = []
27 26
28 async aboutToAppear(): Promise<void> { 27 async aboutToAppear(): Promise<void> {
29 this.titleInit(); 28 this.titleInit();
@@ -31,12 +30,9 @@ export struct Card10Component { @@ -31,12 +30,9 @@ export struct Card10Component {
31 } 30 }
32 31
33 titleInit() { 32 titleInit() {
34 - if (this.contentDTO.title?.includes('<em>') && this.contentDTO.title?.includes('</em>')) {  
35 - this.titleMarked = true;  
36 - this.str01 = this.contentDTO.title?.split('<em>')[0] || '';  
37 - this.str02 = this.contentDTO.title?.split('<em>')[1].split('</em>')[0] || '';  
38 - this.str03 = this.contentDTO.title?.split('<em>')[1].split('</em>')[1] || '';  
39 - } 33 + const titleInitRes:titleInitRes = SearchShowRed.titleInit(this.contentDTO.title);
  34 + this.titleMarked = titleInitRes.titleMarked;
  35 + this.textArr = titleInitRes.textArr;
40 } 36 }
41 37
42 build() { 38 build() {
@@ -45,10 +41,14 @@ export struct Card10Component { @@ -45,10 +41,14 @@ export struct Card10Component {
45 if (this.contentDTO.titleShow === 1 && this.contentDTO.newsTitle) { 41 if (this.contentDTO.titleShow === 1 && this.contentDTO.newsTitle) {
46 Text() { 42 Text() {
47 if (this.titleMarked) { 43 if (this.titleMarked) {
48 - Span(this.str01)  
49 - Span(this.str02) 44 + ForEach(this.textArr, (textItem: textItem) => {
  45 + if (textItem.isRed) {
  46 + Span(textItem.content)
50 .fontColor(0xED2800) 47 .fontColor(0xED2800)
51 - Span(this.str03) 48 + } else {
  49 + Span(textItem.content)
  50 + }
  51 + })
52 } else { 52 } else {
53 Span(this.contentDTO.newsTitle) 53 Span(this.contentDTO.newsTitle)
54 } 54 }
@@ -7,6 +7,7 @@ import { CardSourceInfo } from '../cardCommon/CardSourceInfo'; @@ -7,6 +7,7 @@ import { CardSourceInfo } from '../cardCommon/CardSourceInfo';
7 import { Notes } from './notes'; 7 import { Notes } from './notes';
8 import { persistentStorage, hasClicked } from '../../utils/persistentStorage'; 8 import { persistentStorage, hasClicked } from '../../utils/persistentStorage';
9 import { InfomationCardClick } from '../../utils/infomationCardClick' 9 import { InfomationCardClick } from '../../utils/infomationCardClick'
  10 +import { SearchShowRed, titleInitRes, textItem } from '../../utils/searchShowRed';
10 11
11 const TAG = 'Card11Component'; 12 const TAG = 'Card11Component';
12 13
@@ -21,9 +22,7 @@ export struct Card11Component { @@ -21,9 +22,7 @@ export struct Card11Component {
21 @State clicked: boolean = false; 22 @State clicked: boolean = false;
22 @ObjectLink compDTO: CompDTO 23 @ObjectLink compDTO: CompDTO
23 @State titleMarked: boolean = false; 24 @State titleMarked: boolean = false;
24 - @State str01: string = '';  
25 - @State str02: string = '';  
26 - @State str03: string = ''; 25 + @State textArr: textItem[] = []
27 26
28 async aboutToAppear(): Promise<void> { 27 async aboutToAppear(): Promise<void> {
29 this.titleInit(); 28 this.titleInit();
@@ -31,12 +30,9 @@ export struct Card11Component { @@ -31,12 +30,9 @@ export struct Card11Component {
31 } 30 }
32 31
33 titleInit() { 32 titleInit() {
34 - if (this.contentDTO.title?.includes('<em>') && this.contentDTO.title?.includes('</em>')) {  
35 - this.titleMarked = true;  
36 - this.str01 = this.contentDTO.title?.split('<em>')[0] || '';  
37 - this.str02 = this.contentDTO.title?.split('<em>')[1].split('</em>')[0] || '';  
38 - this.str03 = this.contentDTO.title?.split('<em>')[1].split('</em>')[1] || '';  
39 - } 33 + const titleInitRes:titleInitRes = SearchShowRed.titleInit(this.contentDTO.title);
  34 + this.titleMarked = titleInitRes.titleMarked;
  35 + this.textArr = titleInitRes.textArr;
40 } 36 }
41 37
42 build() { 38 build() {
@@ -49,10 +45,14 @@ export struct Card11Component { @@ -49,10 +45,14 @@ export struct Card11Component {
49 } 45 }
50 Text() { 46 Text() {
51 if (this.titleMarked) { 47 if (this.titleMarked) {
52 - Span(this.str01)  
53 - Span(this.str02) 48 + ForEach(this.textArr, (textItem: textItem) => {
  49 + if (textItem.isRed) {
  50 + Span(textItem.content)
54 .fontColor(0xED2800) 51 .fontColor(0xED2800)
55 - Span(this.str03) 52 + } else {
  53 + Span(textItem.content)
  54 + }
  55 + })
56 } else { 56 } else {
57 Span(this.contentDTO.newsTitle) 57 Span(this.contentDTO.newsTitle)
58 } 58 }
@@ -6,6 +6,7 @@ import { ProcessUtils } from 'wdRouter'; @@ -6,6 +6,7 @@ import { ProcessUtils } from 'wdRouter';
6 import {CarderInteraction} from '../CarderInteraction' 6 import {CarderInteraction} from '../CarderInteraction'
7 import { persistentStorage, hasClicked } from '../../utils/persistentStorage'; 7 import { persistentStorage, hasClicked } from '../../utils/persistentStorage';
8 import { InfomationCardClick } from '../../utils/infomationCardClick' 8 import { InfomationCardClick } from '../../utils/infomationCardClick'
  9 +import { SearchShowRed, titleInitRes, textItem } from '../../utils/searchShowRed';
9 10
10 const TAG = 'Card12Component'; 11 const TAG = 'Card12Component';
11 12
@@ -20,9 +21,7 @@ export struct Card12Component { @@ -20,9 +21,7 @@ export struct Card12Component {
20 @State contentDTO: ContentDTO = new ContentDTO(); 21 @State contentDTO: ContentDTO = new ContentDTO();
21 @State clicked: boolean = false; 22 @State clicked: boolean = false;
22 @State titleMarked: boolean = false; 23 @State titleMarked: boolean = false;
23 - @State str01: string = '';  
24 - @State str02: string = '';  
25 - @State str03: string = ''; 24 + @State textArr: textItem[] = []
26 25
27 aboutToAppear(): void { 26 aboutToAppear(): void {
28 this.titleInit(); 27 this.titleInit();
@@ -30,12 +29,9 @@ export struct Card12Component { @@ -30,12 +29,9 @@ export struct Card12Component {
30 } 29 }
31 30
32 titleInit() { 31 titleInit() {
33 - if (this.contentDTO.title?.includes('<em>') && this.contentDTO.title?.includes('</em>')) {  
34 - this.titleMarked = true;  
35 - this.str01 = this.contentDTO.title?.split('<em>')[0] || '';  
36 - this.str02 = this.contentDTO.title?.split('<em>')[1].split('</em>')[0] || '';  
37 - this.str03 = this.contentDTO.title?.split('<em>')[1].split('</em>')[1] || '';  
38 - } 32 + const titleInitRes:titleInitRes = SearchShowRed.titleInit(this.contentDTO.title);
  33 + this.titleMarked = titleInitRes.titleMarked;
  34 + this.textArr = titleInitRes.textArr;
39 } 35 }
40 36
41 build() { 37 build() {
@@ -48,10 +44,14 @@ export struct Card12Component { @@ -48,10 +44,14 @@ export struct Card12Component {
48 if (this.contentDTO.newsTitle) { 44 if (this.contentDTO.newsTitle) {
49 Text() { 45 Text() {
50 if (this.titleMarked) { 46 if (this.titleMarked) {
51 - Span(this.str01)  
52 - Span(this.str02) 47 + ForEach(this.textArr, (textItem: textItem) => {
  48 + if (textItem.isRed) {
  49 + Span(textItem.content)
53 .fontColor(0xED2800) 50 .fontColor(0xED2800)
54 - Span(this.str03) 51 + } else {
  52 + Span(textItem.content)
  53 + }
  54 + })
55 } else { 55 } else {
56 Span(this.contentDTO.newsTitle) 56 Span(this.contentDTO.newsTitle)
57 } 57 }
@@ -7,6 +7,7 @@ import {CarderInteraction} from '../CarderInteraction' @@ -7,6 +7,7 @@ import {CarderInteraction} from '../CarderInteraction'
7 import { onlyWifiLoadImg } from '../../utils/lazyloadImg'; 7 import { onlyWifiLoadImg } from '../../utils/lazyloadImg';
8 import { persistentStorage, hasClicked } from '../../utils/persistentStorage'; 8 import { persistentStorage, hasClicked } from '../../utils/persistentStorage';
9 import { InfomationCardClick } from '../../utils/infomationCardClick' 9 import { InfomationCardClick } from '../../utils/infomationCardClick'
  10 +import { SearchShowRed, titleInitRes, textItem } from '../../utils/searchShowRed';
10 11
11 const TAG = 'Card14Component'; 12 const TAG = 'Card14Component';
12 13
@@ -22,9 +23,7 @@ export struct Card14Component { @@ -22,9 +23,7 @@ export struct Card14Component {
22 @State loadImg: boolean = false; 23 @State loadImg: boolean = false;
23 @State clicked: boolean = false; 24 @State clicked: boolean = false;
24 @State titleMarked: boolean = false; 25 @State titleMarked: boolean = false;
25 - @State str01: string = '';  
26 - @State str02: string = '';  
27 - @State str03: string = ''; 26 + @State textArr: textItem[] = []
28 27
29 async aboutToAppear(): Promise<void> { 28 async aboutToAppear(): Promise<void> {
30 this.titleInit(); 29 this.titleInit();
@@ -33,12 +32,9 @@ export struct Card14Component { @@ -33,12 +32,9 @@ export struct Card14Component {
33 } 32 }
34 33
35 titleInit() { 34 titleInit() {
36 - if (this.contentDTO.title?.includes('<em>') && this.contentDTO.title?.includes('</em>')) {  
37 - this.titleMarked = true;  
38 - this.str01 = this.contentDTO.title?.split('<em>')[0] || '';  
39 - this.str02 = this.contentDTO.title?.split('<em>')[1].split('</em>')[0] || '';  
40 - this.str03 = this.contentDTO.title?.split('<em>')[1].split('</em>')[1] || '';  
41 - } 35 + const titleInitRes:titleInitRes = SearchShowRed.titleInit(this.contentDTO.title);
  36 + this.titleMarked = titleInitRes.titleMarked;
  37 + this.textArr = titleInitRes.textArr;
42 } 38 }
43 39
44 build() { 40 build() {
@@ -52,10 +48,14 @@ export struct Card14Component { @@ -52,10 +48,14 @@ export struct Card14Component {
52 48
53 Text() { 49 Text() {
54 if (this.titleMarked) { 50 if (this.titleMarked) {
55 - Span(this.str01)  
56 - Span(this.str02) 51 + ForEach(this.textArr, (textItem: textItem) => {
  52 + if (textItem.isRed) {
  53 + Span(textItem.content)
57 .fontColor(0xED2800) 54 .fontColor(0xED2800)
58 - Span(this.str03) 55 + } else {
  56 + Span(textItem.content)
  57 + }
  58 + })
59 } else { 59 } else {
60 Span(this.contentDTO.newsTitle) 60 Span(this.contentDTO.newsTitle)
61 } 61 }
@@ -7,6 +7,7 @@ import {CarderInteraction} from '../CarderInteraction' @@ -7,6 +7,7 @@ import {CarderInteraction} from '../CarderInteraction'
7 import { onlyWifiLoadImg } from '../../utils/lazyloadImg'; 7 import { onlyWifiLoadImg } from '../../utils/lazyloadImg';
8 import { persistentStorage, hasClicked } from '../../utils/persistentStorage'; 8 import { persistentStorage, hasClicked } from '../../utils/persistentStorage';
9 import { InfomationCardClick } from '../../utils/infomationCardClick' 9 import { InfomationCardClick } from '../../utils/infomationCardClick'
  10 +import { SearchShowRed, titleInitRes, textItem } from '../../utils/searchShowRed';
10 11
11 const TAG: string = 'Card15Component'; 12 const TAG: string = 'Card15Component';
12 13
@@ -26,9 +27,7 @@ export struct Card15Component { @@ -26,9 +27,7 @@ export struct Card15Component {
26 @State loadImg: boolean = false; 27 @State loadImg: boolean = false;
27 @State clicked: boolean = false; 28 @State clicked: boolean = false;
28 @State titleMarked: boolean = false; 29 @State titleMarked: boolean = false;
29 - @State str01: string = '';  
30 - @State str02: string = '';  
31 - @State str03: string = ''; 30 + @State textArr: textItem[] = []
32 31
33 async aboutToAppear(): Promise<void> { 32 async aboutToAppear(): Promise<void> {
34 this.titleInit(); 33 this.titleInit();
@@ -37,12 +36,9 @@ export struct Card15Component { @@ -37,12 +36,9 @@ export struct Card15Component {
37 } 36 }
38 37
39 titleInit() { 38 titleInit() {
40 - if (this.contentDTO.title?.includes('<em>') && this.contentDTO.title?.includes('</em>')) {  
41 - this.titleMarked = true;  
42 - this.str01 = this.contentDTO.title?.split('<em>')[0] || '';  
43 - this.str02 = this.contentDTO.title?.split('<em>')[1].split('</em>')[0] || '';  
44 - this.str03 = this.contentDTO.title?.split('<em>')[1].split('</em>')[1] || '';  
45 - } 39 + const titleInitRes:titleInitRes = SearchShowRed.titleInit(this.contentDTO.title);
  40 + this.titleMarked = titleInitRes.titleMarked;
  41 + this.textArr = titleInitRes.textArr;
46 } 42 }
47 43
48 build() { 44 build() {
@@ -53,10 +49,14 @@ export struct Card15Component { @@ -53,10 +49,14 @@ export struct Card15Component {
53 if (this.contentDTO.newsTitle) { 49 if (this.contentDTO.newsTitle) {
54 Text() { 50 Text() {
55 if (this.titleMarked) { 51 if (this.titleMarked) {
56 - Span(this.str01)  
57 - Span(this.str02) 52 + ForEach(this.textArr, (textItem: textItem) => {
  53 + if (textItem.isRed) {
  54 + Span(textItem.content)
58 .fontColor(0xED2800) 55 .fontColor(0xED2800)
59 - Span(this.str03) 56 + } else {
  57 + Span(textItem.content)
  58 + }
  59 + })
60 } else { 60 } else {
61 Span(this.contentDTO.newsTitle) 61 Span(this.contentDTO.newsTitle)
62 } 62 }
@@ -7,6 +7,7 @@ import {CarderInteraction} from '../CarderInteraction' @@ -7,6 +7,7 @@ import {CarderInteraction} from '../CarderInteraction'
7 import { onlyWifiLoadImg } from '../../utils/lazyloadImg'; 7 import { onlyWifiLoadImg } from '../../utils/lazyloadImg';
8 import { persistentStorage, hasClicked } from '../../utils/persistentStorage'; 8 import { persistentStorage, hasClicked } from '../../utils/persistentStorage';
9 import { InfomationCardClick } from '../../utils/infomationCardClick' 9 import { InfomationCardClick } from '../../utils/infomationCardClick'
  10 +import { SearchShowRed, titleInitRes, textItem } from '../../utils/searchShowRed';
10 11
11 const TAG = 'Card16Component'; 12 const TAG = 'Card16Component';
12 13
@@ -27,9 +28,7 @@ export struct Card16Component { @@ -27,9 +28,7 @@ export struct Card16Component {
27 @State loadImg: boolean = false; 28 @State loadImg: boolean = false;
28 @State clicked: boolean = false; 29 @State clicked: boolean = false;
29 @State titleMarked: boolean = false; 30 @State titleMarked: boolean = false;
30 - @State str01: string = '';  
31 - @State str02: string = '';  
32 - @State str03: string = ''; 31 + @State textArr: textItem[] = []
33 32
34 async aboutToAppear(): Promise<void> { 33 async aboutToAppear(): Promise<void> {
35 this.titleInit(); 34 this.titleInit();
@@ -38,12 +37,9 @@ export struct Card16Component { @@ -38,12 +37,9 @@ export struct Card16Component {
38 } 37 }
39 38
40 titleInit() { 39 titleInit() {
41 - if (this.contentDTO.title?.includes('<em>') && this.contentDTO.title?.includes('</em>')) {  
42 - this.titleMarked = true;  
43 - this.str01 = this.contentDTO.title?.split('<em>')[0] || '';  
44 - this.str02 = this.contentDTO.title?.split('<em>')[1].split('</em>')[0] || '';  
45 - this.str03 = this.contentDTO.title?.split('<em>')[1].split('</em>')[1] || '';  
46 - } 40 + const titleInitRes:titleInitRes = SearchShowRed.titleInit(this.contentDTO.title);
  41 + this.titleMarked = titleInitRes.titleMarked;
  42 + this.textArr = titleInitRes.textArr;
47 } 43 }
48 44
49 build() { 45 build() {
@@ -56,10 +52,14 @@ export struct Card16Component { @@ -56,10 +52,14 @@ export struct Card16Component {
56 if (this.contentDTO.newsTitle) { 52 if (this.contentDTO.newsTitle) {
57 Text() { 53 Text() {
58 if (this.titleMarked) { 54 if (this.titleMarked) {
59 - Span(this.str01)  
60 - Span(this.str02) 55 + ForEach(this.textArr, (textItem: textItem) => {
  56 + if (textItem.isRed) {
  57 + Span(textItem.content)
61 .fontColor(0xED2800) 58 .fontColor(0xED2800)
62 - Span(this.str03) 59 + } else {
  60 + Span(textItem.content)
  61 + }
  62 + })
63 } else { 63 } else {
64 Span(this.contentDTO.newsTitle) 64 Span(this.contentDTO.newsTitle)
65 } 65 }
@@ -7,6 +7,7 @@ import { onlyWifiLoadImg } from '../../utils/lazyloadImg'; @@ -7,6 +7,7 @@ import { onlyWifiLoadImg } from '../../utils/lazyloadImg';
7 import { CardMediaInfo } from '../cardCommon/CardMediaInfo'; 7 import { CardMediaInfo } from '../cardCommon/CardMediaInfo';
8 import { persistentStorage, hasClicked } from '../../utils/persistentStorage'; 8 import { persistentStorage, hasClicked } from '../../utils/persistentStorage';
9 import { InfomationCardClick } from '../../utils/infomationCardClick' 9 import { InfomationCardClick } from '../../utils/infomationCardClick'
  10 +import { SearchShowRed, titleInitRes, textItem } from '../../utils/searchShowRed';
10 11
11 const TAG = 'Card17Component'; 12 const TAG = 'Card17Component';
12 13
@@ -22,9 +23,7 @@ export struct Card17Component { @@ -22,9 +23,7 @@ export struct Card17Component {
22 @State clicked: boolean = false; 23 @State clicked: boolean = false;
23 @ObjectLink compDTO: CompDTO 24 @ObjectLink compDTO: CompDTO
24 @State titleMarked: boolean = false; 25 @State titleMarked: boolean = false;
25 - @State str01: string = '';  
26 - @State str02: string = '';  
27 - @State str03: string = ''; 26 + @State textArr: textItem[] = []
28 27
29 async aboutToAppear(): Promise<void> { 28 async aboutToAppear(): Promise<void> {
30 console.log('Card17Component', JSON.stringify(this.contentDTO)) 29 console.log('Card17Component', JSON.stringify(this.contentDTO))
@@ -34,22 +33,23 @@ export struct Card17Component { @@ -34,22 +33,23 @@ export struct Card17Component {
34 } 33 }
35 34
36 titleInit() { 35 titleInit() {
37 - if (this.contentDTO.title?.includes('<em>') && this.contentDTO.title?.includes('</em>')) {  
38 - this.titleMarked = true;  
39 - this.str01 = this.contentDTO.title?.split('<em>')[0] || '';  
40 - this.str02 = this.contentDTO.title?.split('<em>')[1].split('</em>')[0] || '';  
41 - this.str03 = this.contentDTO.title?.split('<em>')[1].split('</em>')[1] || '';  
42 - } 36 + const titleInitRes:titleInitRes = SearchShowRed.titleInit(this.contentDTO.title);
  37 + this.titleMarked = titleInitRes.titleMarked;
  38 + this.textArr = titleInitRes.textArr;
43 } 39 }
44 40
45 build() { 41 build() {
46 Column({ space: 8 }) { 42 Column({ space: 8 }) {
47 Text() { 43 Text() {
48 if (this.titleMarked) { 44 if (this.titleMarked) {
49 - Span(this.str01)  
50 - Span(this.str02) 45 + ForEach(this.textArr, (textItem: textItem) => {
  46 + if (textItem.isRed) {
  47 + Span(textItem.content)
51 .fontColor(0xED2800) 48 .fontColor(0xED2800)
52 - Span(this.str03) 49 + } else {
  50 + Span(textItem.content)
  51 + }
  52 + })
53 } else { 53 } else {
54 Span(this.contentDTO.newsTitle) 54 Span(this.contentDTO.newsTitle)
55 } 55 }
@@ -6,6 +6,7 @@ import { CarderInteraction } from '../CarderInteraction' @@ -6,6 +6,7 @@ import { CarderInteraction } from '../CarderInteraction'
6 import { onlyWifiLoadImg } from '../../utils/lazyloadImg'; 6 import { onlyWifiLoadImg } from '../../utils/lazyloadImg';
7 import { persistentStorage, hasClicked } from '../../utils/persistentStorage'; 7 import { persistentStorage, hasClicked } from '../../utils/persistentStorage';
8 import { InfomationCardClick } from '../../utils/infomationCardClick' 8 import { InfomationCardClick } from '../../utils/infomationCardClick'
  9 +import { SearchShowRed, titleInitRes, textItem } from '../../utils/searchShowRed';
9 10
10 const TAG = 'Card19Component'; 11 const TAG = 'Card19Component';
11 12
@@ -20,9 +21,7 @@ export struct Card19Component { @@ -20,9 +21,7 @@ export struct Card19Component {
20 @State contentDTO: ContentDTO = new ContentDTO() 21 @State contentDTO: ContentDTO = new ContentDTO()
21 @State clicked: boolean = false; 22 @State clicked: boolean = false;
22 @State titleMarked: boolean = false; 23 @State titleMarked: boolean = false;
23 - @State str01: string = '';  
24 - @State str02: string = '';  
25 - @State str03: string = ''; 24 + @State textArr: textItem[] = []
26 25
27 async aboutToAppear(): Promise<void> { 26 async aboutToAppear(): Promise<void> {
28 this.titleInit(); 27 this.titleInit();
@@ -31,12 +30,9 @@ export struct Card19Component { @@ -31,12 +30,9 @@ export struct Card19Component {
31 } 30 }
32 31
33 titleInit() { 32 titleInit() {
34 - if (this.contentDTO.title?.includes('<em>') && this.contentDTO.title?.includes('</em>')) {  
35 - this.titleMarked = true;  
36 - this.str01 = this.contentDTO.title?.split('<em>')[0] || '';  
37 - this.str02 = this.contentDTO.title?.split('<em>')[1].split('</em>')[0] || '';  
38 - this.str03 = this.contentDTO.title?.split('<em>')[1].split('</em>')[1] || '';  
39 - } 33 + const titleInitRes:titleInitRes = SearchShowRed.titleInit(this.contentDTO.title);
  34 + this.titleMarked = titleInitRes.titleMarked;
  35 + this.textArr = titleInitRes.textArr;
40 } 36 }
41 37
42 build() { 38 build() {
@@ -47,10 +43,14 @@ export struct Card19Component { @@ -47,10 +43,14 @@ export struct Card19Component {
47 if (this.contentDTO.newsTitle) { 43 if (this.contentDTO.newsTitle) {
48 Text() { 44 Text() {
49 if (this.titleMarked) { 45 if (this.titleMarked) {
50 - Span(this.str01)  
51 - Span(this.str02) 46 + ForEach(this.textArr, (textItem: textItem) => {
  47 + if (textItem.isRed) {
  48 + Span(textItem.content)
52 .fontColor(0xED2800) 49 .fontColor(0xED2800)
53 - Span(this.str03) 50 + } else {
  51 + Span(textItem.content)
  52 + }
  53 + })
54 } else { 54 } else {
55 Span(this.contentDTO.newsTitle=='null'?"":this.contentDTO.newsTitle) 55 Span(this.contentDTO.newsTitle=='null'?"":this.contentDTO.newsTitle)
56 } 56 }
@@ -7,6 +7,7 @@ import {CarderInteraction} from '../CarderInteraction' @@ -7,6 +7,7 @@ import {CarderInteraction} from '../CarderInteraction'
7 import { onlyWifiLoadImg } from '../../utils/lazyloadImg'; 7 import { onlyWifiLoadImg } from '../../utils/lazyloadImg';
8 import { persistentStorage, hasClicked } from '../../utils/persistentStorage'; 8 import { persistentStorage, hasClicked } from '../../utils/persistentStorage';
9 import { InfomationCardClick } from '../../utils/infomationCardClick' 9 import { InfomationCardClick } from '../../utils/infomationCardClick'
  10 +import { SearchShowRed, titleInitRes, textItem } from '../../utils/searchShowRed';
10 11
11 const TAG = 'Card20Component'; 12 const TAG = 'Card20Component';
12 13
@@ -21,9 +22,7 @@ export struct Card20Component { @@ -21,9 +22,7 @@ export struct Card20Component {
21 @State contentDTO: ContentDTO = new ContentDTO(); 22 @State contentDTO: ContentDTO = new ContentDTO();
22 @State clicked: boolean = false; 23 @State clicked: boolean = false;
23 @State titleMarked: boolean = false; 24 @State titleMarked: boolean = false;
24 - @State str01: string = '';  
25 - @State str02: string = '';  
26 - @State str03: string = ''; 25 + @State textArr: textItem[] = []
27 26
28 aboutToAppear(): void { 27 aboutToAppear(): void {
29 this.titleInit(); 28 this.titleInit();
@@ -31,12 +30,9 @@ export struct Card20Component { @@ -31,12 +30,9 @@ export struct Card20Component {
31 } 30 }
32 31
33 titleInit() { 32 titleInit() {
34 - if (this.contentDTO.title?.includes('<em>') && this.contentDTO.title?.includes('</em>')) {  
35 - this.titleMarked = true;  
36 - this.str01 = this.contentDTO.title?.split('<em>')[0] || '';  
37 - this.str02 = this.contentDTO.title?.split('<em>')[1].split('</em>')[0] || '';  
38 - this.str03 = this.contentDTO.title?.split('<em>')[1].split('</em>')[1] || '';  
39 - } 33 + const titleInitRes:titleInitRes = SearchShowRed.titleInit(this.contentDTO.title);
  34 + this.titleMarked = titleInitRes.titleMarked;
  35 + this.textArr = titleInitRes.textArr;
40 } 36 }
41 37
42 build() { 38 build() {
@@ -48,10 +44,14 @@ export struct Card20Component { @@ -48,10 +44,14 @@ export struct Card20Component {
48 Text() { 44 Text() {
49 45
50 if (this.titleMarked) { 46 if (this.titleMarked) {
51 - Span(this.str01)  
52 - Span(this.str02) 47 + ForEach(this.textArr, (textItem: textItem) => {
  48 + if (textItem.isRed) {
  49 + Span(textItem.content)
53 .fontColor(0xED2800) 50 .fontColor(0xED2800)
54 - Span(this.str03) 51 + } else {
  52 + Span(textItem.content)
  53 + }
  54 + })
55 } else { 55 } else {
56 Span(this.contentDTO.newsTitle) 56 Span(this.contentDTO.newsTitle)
57 } 57 }
@@ -7,6 +7,7 @@ import {CarderInteraction} from '../CarderInteraction' @@ -7,6 +7,7 @@ import {CarderInteraction} from '../CarderInteraction'
7 import { onlyWifiLoadImg } from '../../utils/lazyloadImg'; 7 import { onlyWifiLoadImg } from '../../utils/lazyloadImg';
8 import { persistentStorage, hasClicked } from '../../utils/persistentStorage'; 8 import { persistentStorage, hasClicked } from '../../utils/persistentStorage';
9 import { InfomationCardClick } from '../../utils/infomationCardClick' 9 import { InfomationCardClick } from '../../utils/infomationCardClick'
  10 +import { SearchShowRed, titleInitRes, textItem } from '../../utils/searchShowRed';
10 11
11 const TAG: string = 'Card6Component-Card13Component'; 12 const TAG: string = 'Card6Component-Card13Component';
12 13
@@ -22,9 +23,7 @@ export struct Card21Component { @@ -22,9 +23,7 @@ export struct Card21Component {
22 @State loadImg: boolean = false; 23 @State loadImg: boolean = false;
23 @State clicked: boolean = false; 24 @State clicked: boolean = false;
24 @State titleMarked: boolean = false; 25 @State titleMarked: boolean = false;
25 - @State str01: string = '';  
26 - @State str02: string = '';  
27 - @State str03: string = ''; 26 + @State textArr: textItem[] = []
28 27
29 async aboutToAppear(): Promise<void> { 28 async aboutToAppear(): Promise<void> {
30 this.titleInit(); 29 this.titleInit();
@@ -33,12 +32,9 @@ export struct Card21Component { @@ -33,12 +32,9 @@ export struct Card21Component {
33 } 32 }
34 33
35 titleInit() { 34 titleInit() {
36 - if (this.contentDTO.title?.includes('<em>') && this.contentDTO.title?.includes('</em>')) {  
37 - this.titleMarked = true;  
38 - this.str01 = this.contentDTO.title?.split('<em>')[0] || '';  
39 - this.str02 = this.contentDTO.title?.split('<em>')[1].split('</em>')[0] || '';  
40 - this.str03 = this.contentDTO.title?.split('<em>')[1].split('</em>')[1] || '';  
41 - } 35 + const titleInitRes:titleInitRes = SearchShowRed.titleInit(this.contentDTO.title);
  36 + this.titleMarked = titleInitRes.titleMarked;
  37 + this.textArr = titleInitRes.textArr;
42 } 38 }
43 39
44 build() { 40 build() {
@@ -50,10 +46,14 @@ export struct Card21Component { @@ -50,10 +46,14 @@ export struct Card21Component {
50 GridItem() { 46 GridItem() {
51 Text() { 47 Text() {
52 if (this.titleMarked) { 48 if (this.titleMarked) {
53 - Span(this.str01)  
54 - Span(this.str02) 49 + ForEach(this.textArr, (textItem: textItem) => {
  50 + if (textItem.isRed) {
  51 + Span(textItem.content)
55 .fontColor(0xED2800) 52 .fontColor(0xED2800)
56 - Span(this.str03) 53 + } else {
  54 + Span(textItem.content)
  55 + }
  56 + })
57 } else { 57 } else {
58 Span(this.contentDTO.newsTitle) 58 Span(this.contentDTO.newsTitle)
59 } 59 }
@@ -8,12 +8,9 @@ import { Notes } from './notes'; @@ -8,12 +8,9 @@ import { Notes } from './notes';
8 import { onlyWifiLoadImg } from '../../utils/lazyloadImg'; 8 import { onlyWifiLoadImg } from '../../utils/lazyloadImg';
9 import { persistentStorage, hasClicked } from '../../utils/persistentStorage'; 9 import { persistentStorage, hasClicked } from '../../utils/persistentStorage';
10 import { InfomationCardClick } from '../../utils/infomationCardClick'; 10 import { InfomationCardClick } from '../../utils/infomationCardClick';
  11 +import { SearchShowRed, titleInitRes, textItem } from '../../utils/searchShowRed';
11 12
12 const TAG: string = 'Card2Component' 13 const TAG: string = 'Card2Component'
13 -interface textItem {  
14 - content: string,  
15 - isRed: boolean  
16 -}  
17 /** 14 /**
18 * 大图卡: 15 * 大图卡:
19 * compstyle:2 16 * compstyle:2
@@ -33,52 +30,17 @@ export struct Card2Component { @@ -33,52 +30,17 @@ export struct Card2Component {
33 @State textArr: textItem[] = [] 30 @State textArr: textItem[] = []
34 31
35 async aboutToAppear(): Promise<void> { 32 async aboutToAppear(): Promise<void> {
36 - this.clicked = hasClicked(this.contentDTO.objectId)  
37 this.titleInit(); 33 this.titleInit();
  34 + this.clicked = hasClicked(this.contentDTO.objectId)
38 this.loadImg = await onlyWifiLoadImg(); 35 this.loadImg = await onlyWifiLoadImg();
39 } 36 }
40 37
41 titleInit() { 38 titleInit() {
42 - if (this.contentDTO.title?.includes('<em>') && this.contentDTO.title?.includes('</em>')) {  
43 - this.titleMarked = true;  
44 - // this.str01 = this.contentDTO.title?.split('<em>')[0] || '';  
45 - // this.str02 = this.contentDTO.title?.split('<em>')[1].split('</em>')[0] || '';  
46 - // this.str03 = this.contentDTO.title?.split('<em>')[1].split('</em>')[1] || '';  
47 -  
48 - const html: string = this.contentDTO.title;  
49 - const pattern = /<[a-z]+[1-6]?\b[^>]*>(.*?)<\/[a-z]+[1-6]?>/g;  
50 - const res: string[] = [];  
51 - let match: RegExpExecArray | null;  
52 -  
53 - while ((match = pattern.exec(html)) !== null) {  
54 - const content: string = match[1].trim();  
55 - res.push(content);  
56 - }  
57 -  
58 - let textArr: textItem[] = [];  
59 - this.formatTitle(html, res, 0, textArr);  
60 - this.textArr = textArr;  
61 - } 39 + const titleInitRes:titleInitRes = SearchShowRed.titleInit(this.contentDTO.title);
  40 + this.titleMarked = titleInitRes.titleMarked;
  41 + this.textArr = titleInitRes.textArr;
62 } 42 }
63 43
64 - formatTitle(textStr: string, matchArr: string[], index: number, textArr: textItem[]) {  
65 - const item: string = matchArr[index];  
66 - const arr = textStr.split(item);  
67 - arr.forEach((str: string, ind: number) => {  
68 - if (ind === 0) {  
69 - textArr.push({  
70 - content: str.replaceAll('<em>', '').replaceAll('</em>', ''),  
71 - isRed: false  
72 - } as textItem)  
73 - textArr.push({  
74 - content: item,  
75 - isRed: true  
76 - })  
77 - } else if (ind === 1) {  
78 - this.formatTitle(str, matchArr, index + 1, textArr)  
79 - }  
80 - })  
81 - }  
82 44
83 build() { 45 build() {
84 Column() { 46 Column() {
@@ -119,10 +81,6 @@ export struct Card2Component { @@ -119,10 +81,6 @@ export struct Card2Component {
119 81
120 Text() { 82 Text() {
121 if (this.titleMarked) { 83 if (this.titleMarked) {
122 - // Span(this.str01)  
123 - // Span(this.str02)  
124 - // .fontColor(0xED2800)  
125 - // Span(this.str03)  
126 ForEach(this.textArr, (textItem: textItem) => { 84 ForEach(this.textArr, (textItem: textItem) => {
127 if (textItem.isRed) { 85 if (textItem.isRed) {
128 Span(textItem.content) 86 Span(textItem.content)
@@ -5,6 +5,7 @@ import { CardSourceInfo } from '../cardCommon/CardSourceInfo'; @@ -5,6 +5,7 @@ import { CardSourceInfo } from '../cardCommon/CardSourceInfo';
5 import { Notes } from './notes'; 5 import { Notes } from './notes';
6 import { persistentStorage, hasClicked } from '../../utils/persistentStorage'; 6 import { persistentStorage, hasClicked } from '../../utils/persistentStorage';
7 import { InfomationCardClick } from '../../utils/infomationCardClick' 7 import { InfomationCardClick } from '../../utils/infomationCardClick'
  8 +import { SearchShowRed, titleInitRes, textItem } from '../../utils/searchShowRed';
8 9
9 10
10 /** 11 /**
@@ -19,9 +20,7 @@ export struct Card3Component { @@ -19,9 +20,7 @@ export struct Card3Component {
19 @State clicked: boolean = false; 20 @State clicked: boolean = false;
20 @ObjectLink compDTO: CompDTO 21 @ObjectLink compDTO: CompDTO
21 @State titleMarked: boolean = false; 22 @State titleMarked: boolean = false;
22 - @State str01: string = '';  
23 - @State str02: string = '';  
24 - @State str03: string = ''; 23 + @State textArr: textItem[] = []
25 24
26 async aboutToAppear(): Promise<void> { 25 async aboutToAppear(): Promise<void> {
27 this.titleInit(); 26 this.titleInit();
@@ -29,12 +28,9 @@ export struct Card3Component { @@ -29,12 +28,9 @@ export struct Card3Component {
29 } 28 }
30 29
31 titleInit() { 30 titleInit() {
32 - if (this.contentDTO.title?.includes('<em>') && this.contentDTO.title?.includes('</em>')) {  
33 - this.titleMarked = true;  
34 - this.str01 = this.contentDTO.title?.split('<em>')[0] || '';  
35 - this.str02 = this.contentDTO.title?.split('<em>')[1].split('</em>')[0] || '';  
36 - this.str03 = this.contentDTO.title?.split('<em>')[1].split('</em>')[1] || '';  
37 - } 31 + const titleInitRes:titleInitRes = SearchShowRed.titleInit(this.contentDTO.title);
  32 + this.titleMarked = titleInitRes.titleMarked;
  33 + this.textArr = titleInitRes.textArr;
38 } 34 }
39 35
40 build() { 36 build() {
@@ -47,10 +43,14 @@ export struct Card3Component { @@ -47,10 +43,14 @@ export struct Card3Component {
47 } 43 }
48 Text() { 44 Text() {
49 if (this.titleMarked) { 45 if (this.titleMarked) {
50 - Span(this.str01)  
51 - Span(this.str02) 46 + ForEach(this.textArr, (textItem: textItem) => {
  47 + if (textItem.isRed) {
  48 + Span(textItem.content)
52 .fontColor(0xED2800) 49 .fontColor(0xED2800)
53 - Span(this.str03) 50 + } else {
  51 + Span(textItem.content)
  52 + }
  53 + })
54 } else { 54 } else {
55 Span(this.contentDTO.newsTitle) 55 Span(this.contentDTO.newsTitle)
56 } 56 }
@@ -7,6 +7,7 @@ import { onlyWifiLoadImg } from '../../utils/lazyloadImg'; @@ -7,6 +7,7 @@ import { onlyWifiLoadImg } from '../../utils/lazyloadImg';
7 import { Notes } from './notes'; 7 import { Notes } from './notes';
8 import { persistentStorage, hasClicked } from '../../utils/persistentStorage'; 8 import { persistentStorage, hasClicked } from '../../utils/persistentStorage';
9 import { InfomationCardClick } from '../../utils/infomationCardClick' 9 import { InfomationCardClick } from '../../utils/infomationCardClick'
  10 +import { SearchShowRed, titleInitRes, textItem } from '../../utils/searchShowRed';
10 11
11 const TAG: string = 'Card4Component'; 12 const TAG: string = 'Card4Component';
12 13
@@ -25,9 +26,7 @@ export struct Card4Component { @@ -25,9 +26,7 @@ export struct Card4Component {
25 @State loadImg: boolean = false; 26 @State loadImg: boolean = false;
26 @State clicked: boolean = false; 27 @State clicked: boolean = false;
27 @State titleMarked: boolean = false; 28 @State titleMarked: boolean = false;
28 - @State str01: string = '';  
29 - @State str02: string = '';  
30 - @State str03: string = ''; 29 + @State textArr: textItem[] = []
31 @ObjectLink compDTO: CompDTO 30 @ObjectLink compDTO: CompDTO
32 31
33 async aboutToAppear(): Promise<void> { 32 async aboutToAppear(): Promise<void> {
@@ -37,12 +36,9 @@ export struct Card4Component { @@ -37,12 +36,9 @@ export struct Card4Component {
37 } 36 }
38 37
39 titleInit() { 38 titleInit() {
40 - if (this.contentDTO.title?.includes('<em>') && this.contentDTO.title?.includes('</em>')) {  
41 - this.titleMarked = true;  
42 - this.str01 = this.contentDTO.title?.split('<em>')[0] || '';  
43 - this.str02 = this.contentDTO.title?.split('<em>')[1].split('</em>')[0] || '';  
44 - this.str03 = this.contentDTO.title?.split('<em>')[1].split('</em>')[1] || '';  
45 - } 39 + const titleInitRes:titleInitRes = SearchShowRed.titleInit(this.contentDTO.title);
  40 + this.titleMarked = titleInitRes.titleMarked;
  41 + this.textArr = titleInitRes.textArr;
46 } 42 }
47 43
48 build() { 44 build() {
@@ -57,10 +53,14 @@ export struct Card4Component { @@ -57,10 +53,14 @@ export struct Card4Component {
57 } 53 }
58 Text() { 54 Text() {
59 if (this.titleMarked) { 55 if (this.titleMarked) {
60 - Span(this.str01)  
61 - Span(this.str02) 56 + ForEach(this.textArr, (textItem: textItem) => {
  57 + if (textItem.isRed) {
  58 + Span(textItem.content)
62 .fontColor(0xED2800) 59 .fontColor(0xED2800)
63 - Span(this.str03) 60 + } else {
  61 + Span(textItem.content)
  62 + }
  63 + })
64 } else { 64 } else {
65 Span(this.contentDTO.newsTitle) 65 Span(this.contentDTO.newsTitle)
66 } 66 }
@@ -5,6 +5,7 @@ import { onlyWifiLoadImg } from '../../utils/lazyloadImg'; @@ -5,6 +5,7 @@ import { onlyWifiLoadImg } from '../../utils/lazyloadImg';
5 import { Notes } from './notes'; 5 import { Notes } from './notes';
6 import { persistentStorage, hasClicked } from '../../utils/persistentStorage'; 6 import { persistentStorage, hasClicked } from '../../utils/persistentStorage';
7 import { InfomationCardClick } from '../../utils/infomationCardClick' 7 import { InfomationCardClick } from '../../utils/infomationCardClick'
  8 +import { SearchShowRed, titleInitRes, textItem } from '../../utils/searchShowRed';
8 9
9 10
10 const TAG: string = 'Card5Component'; 11 const TAG: string = 'Card5Component';
@@ -22,9 +23,7 @@ export struct Card5Component { @@ -22,9 +23,7 @@ export struct Card5Component {
22 @State loadImg: boolean = false; 23 @State loadImg: boolean = false;
23 @State clicked: boolean = false; 24 @State clicked: boolean = false;
24 @State titleMarked: boolean = false; 25 @State titleMarked: boolean = false;
25 - @State str01: string = '';  
26 - @State str02: string = '';  
27 - @State str03: string = ''; 26 + @State textArr: textItem[] = []
28 27
29 async aboutToAppear(): Promise<void> { 28 async aboutToAppear(): Promise<void> {
30 console.log('Card2Component', JSON.stringify(this.compDTO)) 29 console.log('Card2Component', JSON.stringify(this.compDTO))
@@ -35,12 +34,9 @@ export struct Card5Component { @@ -35,12 +34,9 @@ export struct Card5Component {
35 } 34 }
36 35
37 titleInit() { 36 titleInit() {
38 - if (this.contentDTO.title?.includes('<em>') && this.contentDTO.title?.includes('</em>')) {  
39 - this.titleMarked = true;  
40 - this.str01 = this.contentDTO.title?.split('<em>')[0] || '';  
41 - this.str02 = this.contentDTO.title?.split('<em>')[1].split('</em>')[0] || '';  
42 - this.str03 = this.contentDTO.title?.split('<em>')[1].split('</em>')[1] || '';  
43 - } 37 + const titleInitRes:titleInitRes = SearchShowRed.titleInit(this.contentDTO.title);
  38 + this.titleMarked = titleInitRes.titleMarked;
  39 + this.textArr = titleInitRes.textArr;
44 } 40 }
45 41
46 build() { 42 build() {
@@ -69,10 +65,14 @@ export struct Card5Component { @@ -69,10 +65,14 @@ export struct Card5Component {
69 65
70 Text() { 66 Text() {
71 if (this.titleMarked) { 67 if (this.titleMarked) {
72 - Span(this.str01)  
73 - Span(this.str02) 68 + ForEach(this.textArr, (textItem: textItem) => {
  69 + if (textItem.isRed) {
  70 + Span(textItem.content)
74 .fontColor(0xED2800) 71 .fontColor(0xED2800)
75 - Span(this.str03) 72 + } else {
  73 + Span(textItem.content)
  74 + }
  75 + })
76 } else { 76 } else {
77 Span(this.contentDTO.newsTitle) 77 Span(this.contentDTO.newsTitle)
78 } 78 }
@@ -8,6 +8,7 @@ import { onlyWifiLoadImg } from '../../utils/lazyloadImg'; @@ -8,6 +8,7 @@ import { onlyWifiLoadImg } from '../../utils/lazyloadImg';
8 import { Logger } from 'wdKit/Index'; 8 import { Logger } from 'wdKit/Index';
9 import { persistentStorage, hasClicked } from '../../utils/persistentStorage'; 9 import { persistentStorage, hasClicked } from '../../utils/persistentStorage';
10 import { InfomationCardClick } from '../../utils/infomationCardClick' 10 import { InfomationCardClick } from '../../utils/infomationCardClick'
  11 +import { SearchShowRed, titleInitRes, textItem } from '../../utils/searchShowRed';
11 12
12 const TAG: string = 'Card6Component-Card13Component'; 13 const TAG: string = 'Card6Component-Card13Component';
13 14
@@ -21,9 +22,7 @@ export struct Card6Component { @@ -21,9 +22,7 @@ export struct Card6Component {
21 @State loadImg: boolean = false; 22 @State loadImg: boolean = false;
22 @State clicked: boolean = false; 23 @State clicked: boolean = false;
23 @State titleMarked: boolean = false; 24 @State titleMarked: boolean = false;
24 - @State str01: string = '';  
25 - @State str02: string = '';  
26 - @State str03: string = ''; 25 + @State textArr: textItem[] = []
27 @ObjectLink compDTO: CompDTO 26 @ObjectLink compDTO: CompDTO
28 @State contentDTO: ContentDTO = new ContentDTO(); 27 @State contentDTO: ContentDTO = new ContentDTO();
29 28
@@ -33,12 +32,9 @@ export struct Card6Component { @@ -33,12 +32,9 @@ export struct Card6Component {
33 this.clicked = hasClicked(this.contentDTO.objectId) 32 this.clicked = hasClicked(this.contentDTO.objectId)
34 } 33 }
35 titleInit() { 34 titleInit() {
36 - if (this.contentDTO.title?.includes('<em>') && this.contentDTO.title?.includes('</em>')) {  
37 - this.titleMarked = true;  
38 - this.str01 = this.contentDTO.title?.split('<em>')[0] || '';  
39 - this.str02 = this.contentDTO.title?.split('<em>')[1].split('</em>')[0] || '';  
40 - this.str03 = this.contentDTO.title?.split('<em>')[1].split('</em>')[1] || '';  
41 - } 35 + const titleInitRes:titleInitRes = SearchShowRed.titleInit(this.contentDTO.title);
  36 + this.titleMarked = titleInitRes.titleMarked;
  37 + this.textArr = titleInitRes.textArr;
42 } 38 }
43 39
44 build() { 40 build() {
@@ -70,10 +66,14 @@ export struct Card6Component { @@ -70,10 +66,14 @@ export struct Card6Component {
70 66
71 Text() { 67 Text() {
72 if (this.titleMarked) { 68 if (this.titleMarked) {
73 - Span(this.str01)  
74 - Span(this.str02) 69 + ForEach(this.textArr, (textItem: textItem) => {
  70 + if (textItem.isRed) {
  71 + Span(textItem.content)
75 .fontColor(0xED2800) 72 .fontColor(0xED2800)
76 - Span(this.str03) 73 + } else {
  74 + Span(textItem.content)
  75 + }
  76 + })
77 } else { 77 } else {
78 Span(this.contentDTO.newsTitle) 78 Span(this.contentDTO.newsTitle)
79 } 79 }
@@ -7,6 +7,7 @@ import { onlyWifiLoadImg } from '../../utils/lazyloadImg'; @@ -7,6 +7,7 @@ import { onlyWifiLoadImg } from '../../utils/lazyloadImg';
7 import { persistentStorage, hasClicked } from '../../utils/persistentStorage'; 7 import { persistentStorage, hasClicked } from '../../utils/persistentStorage';
8 import { InfomationCardClick } from '../../utils/infomationCardClick' 8 import { InfomationCardClick } from '../../utils/infomationCardClick'
9 import { TrackConstants, TrackingPageBrowse } from 'wdTracking/Index'; 9 import { TrackConstants, TrackingPageBrowse } from 'wdTracking/Index';
  10 +import { SearchShowRed, titleInitRes, textItem } from '../../utils/searchShowRed';
10 11
11 /** 12 /**
12 * 时间链卡--CompStyle: 09 13 * 时间链卡--CompStyle: 09
@@ -22,9 +23,7 @@ export struct Card9Component { @@ -22,9 +23,7 @@ export struct Card9Component {
22 // @State loadImg: boolean = true; 23 // @State loadImg: boolean = true;
23 @State clicked: boolean = false; 24 @State clicked: boolean = false;
24 @State titleMarked: boolean = false; 25 @State titleMarked: boolean = false;
25 - @State str01: string = '';  
26 - @State str02: string = '';  
27 - @State str03: string = ''; 26 + @State textArr: textItem[] = []
28 pageShowTime:number = 0; 27 pageShowTime:number = 0;
29 pageHideTime:number = 0; 28 pageHideTime:number = 0;
30 29
@@ -48,12 +47,9 @@ export struct Card9Component { @@ -48,12 +47,9 @@ export struct Card9Component {
48 } 47 }
49 48
50 titleInit() { 49 titleInit() {
51 - if (this.contentDTO.title?.includes('<em>') && this.contentDTO.title?.includes('</em>')) {  
52 - this.titleMarked = true;  
53 - this.str01 = this.contentDTO.title?.split('<em>')[0] || '';  
54 - this.str02 = this.contentDTO.title?.split('<em>')[1].split('</em>')[0] || '';  
55 - this.str03 = this.contentDTO.title?.split('<em>')[1].split('</em>')[1] || '';  
56 - } 50 + const titleInitRes:titleInitRes = SearchShowRed.titleInit(this.contentDTO.title);
  51 + this.titleMarked = titleInitRes.titleMarked;
  52 + this.textArr = titleInitRes.textArr;
57 } 53 }
58 54
59 build() { 55 build() {
@@ -62,10 +58,14 @@ export struct Card9Component { @@ -62,10 +58,14 @@ export struct Card9Component {
62 if (this.contentDTO.titleShow === 1 && this.contentDTO.newsTitle) { 58 if (this.contentDTO.titleShow === 1 && this.contentDTO.newsTitle) {
63 Text() { 59 Text() {
64 if (this.titleMarked) { 60 if (this.titleMarked) {
65 - Span(this.str01)  
66 - Span(this.str02) 61 + ForEach(this.textArr, (textItem: textItem) => {
  62 + if (textItem.isRed) {
  63 + Span(textItem.content)
67 .fontColor(0xED2800) 64 .fontColor(0xED2800)
68 - Span(this.str03) 65 + } else {
  66 + Span(textItem.content)
  67 + }
  68 + })
69 } else { 69 } else {
70 Span(this.contentDTO.newsTitle) 70 Span(this.contentDTO.newsTitle)
71 } 71 }
@@ -5,6 +5,7 @@ import { CardSourceInfo } from '../cardCommon/CardSourceInfo' @@ -5,6 +5,7 @@ import { CardSourceInfo } from '../cardCommon/CardSourceInfo'
5 import { CardMediaInfo } from '../cardCommon/CardMediaInfo' 5 import { CardMediaInfo } from '../cardCommon/CardMediaInfo'
6 import { onlyWifiLoadImg } from '../../utils/lazyloadImg'; 6 import { onlyWifiLoadImg } from '../../utils/lazyloadImg';
7 import { InfomationCardClick } from '../../utils/infomationCardClick' 7 import { InfomationCardClick } from '../../utils/infomationCardClick'
  8 +import { SearchShowRed, titleInitRes, textItem } from '../../utils/searchShowRed';
8 9
9 const TAG: string = 'Card4Component'; 10 const TAG: string = 'Card4Component';
10 11
@@ -19,9 +20,7 @@ export struct SearchContentComponent { @@ -19,9 +20,7 @@ export struct SearchContentComponent {
19 @State contentDTO: ContentDTO = new ContentDTO(); 20 @State contentDTO: ContentDTO = new ContentDTO();
20 @State loadImg: boolean = false; 21 @State loadImg: boolean = false;
21 @State clicked: boolean = false; 22 @State clicked: boolean = false;
22 - @State str01: string = '';  
23 - @State str02: string = '';  
24 - @State str03: string = ''; 23 + @State textArr: textItem[] = []
25 24
26 25
27 async aboutToAppear(): Promise<void> { 26 async aboutToAppear(): Promise<void> {
@@ -30,9 +29,9 @@ export struct SearchContentComponent { @@ -30,9 +29,9 @@ export struct SearchContentComponent {
30 } 29 }
31 30
32 titleInit() { 31 titleInit() {
33 - this.str01 = this.contentDTO.contentText?.split('<em>')[0] || '';  
34 - this.str02 = this.contentDTO.contentText?.split('<em>')[1].split('</em>')[0] || '';  
35 - this.str03 = this.contentDTO.contentText?.split('<em>')[1].split('</em>')[1] || ''; 32 + const titleInitRes:titleInitRes = SearchShowRed.titleInit(this.contentDTO.title);
  33 + // this.titleMarked = titleInitRes.titleMarked;
  34 + this.textArr = titleInitRes.textArr;
36 } 35 }
37 36
38 build() { 37 build() {
@@ -47,11 +46,15 @@ export struct SearchContentComponent { @@ -47,11 +46,15 @@ export struct SearchContentComponent {
47 .textOverflow({ overflow: TextOverflow.Ellipsis }) // 超出的部分显示省略号。 46 .textOverflow({ overflow: TextOverflow.Ellipsis }) // 超出的部分显示省略号。
48 47
49 // 命中内容 48 // 命中内容
50 - Text(this.contentDTO.contentText) {  
51 - Span(this.str01)  
52 - Span(this.str02) 49 + Text() {
  50 + ForEach(this.textArr, (textItem: textItem) => {
  51 + if (textItem.isRed) {
  52 + Span(textItem.content)
53 .fontColor(0xED2800) 53 .fontColor(0xED2800)
54 - Span(this.str03) 54 + } else {
  55 + Span(textItem.content)
  56 + }
  57 + })
55 } 58 }
56 .fontSize(13) 59 .fontSize(13)
57 .width(CommonConstants.FULL_PARENT) 60 .width(CommonConstants.FULL_PARENT)
  1 +export interface textItem {
  2 + content: string,
  3 + isRed: boolean
  4 +}
  5 +
  6 +export interface titleInitRes {
  7 + titleMarked: boolean,
  8 + textArr: textItem[]
  9 +}
  10 +
  11 +export class SearchShowRed {
  12 + // title: this.contentDTO.title
  13 + static titleInit(title: string) {
  14 + let titleMarked: boolean = false;
  15 + let textArr: textItem[] = [];
  16 +
  17 + if (title?.includes('<em>') && title?.includes('</em>')) {
  18 + titleMarked = true;
  19 +
  20 + const html: string = title;
  21 + const pattern = /<[a-z]+[1-6]?\b[^>]*>(.*?)<\/[a-z]+[1-6]?>/g;
  22 + const res: string[] = [];
  23 + let match: RegExpExecArray | null;
  24 +
  25 + while ((match = pattern.exec(html)) !== null) {
  26 + const content: string = match[1].trim();
  27 + res.push(content);
  28 + }
  29 +
  30 + SearchShowRed.formatTitle(html, res, 0, textArr);
  31 + }
  32 +
  33 + const titleInitRes: titleInitRes = {
  34 + titleMarked,
  35 + textArr
  36 + }
  37 + return titleInitRes
  38 + }
  39 +
  40 + private static formatTitle(textStr: string, matchArr: string[], index: number, textArr: textItem[]) {
  41 + const item: string = matchArr[index];
  42 + const arr = textStr.split(item);
  43 + arr.forEach((str: string, ind: number) => {
  44 + if (ind === 0) {
  45 + textArr.push({
  46 + content: str.replaceAll('<em>', '').replaceAll('</em>', ''),
  47 + isRed: false
  48 + } as textItem)
  49 + textArr.push({
  50 + content: item,
  51 + isRed: true
  52 + })
  53 + } else if (ind === 1) {
  54 + SearchShowRed.formatTitle(str, matchArr, index + 1, textArr)
  55 + }
  56 + })
  57 + }
  58 +}
@@ -22,7 +22,7 @@ struct ForgetPasswordPage { @@ -22,7 +22,7 @@ struct ForgetPasswordPage {
22 @State isSubmit: boolean = false //是否可以提交 默认不可以 22 @State isSubmit: boolean = false //是否可以提交 默认不可以
23 loginViewModel: LoginViewModel = new LoginViewModel() 23 loginViewModel: LoginViewModel = new LoginViewModel()
24 @State @Watch('onCodeSend') isCodeSend: boolean = false //验证码点击发送事件 24 @State @Watch('onCodeSend') isCodeSend: boolean = false //验证码点击发送事件
25 - phone:string = (router.getParams() as Record<string, number>)['phone'] + ""; //登录 密码登录 填写手机号 点击忘记密码 带过来手机号 25 + @State params:Record<string, number> = router.getParams() as Record<string, number>;//登录 密码登录 填写手机号 点击忘记密码 带过来手机号
26 @State pageTitle:string = '找回密码'; 26 @State pageTitle:string = '找回密码';
27 @State codeStateSuccess:boolean=false 27 @State codeStateSuccess:boolean=false
28 onCodeSend() { 28 onCodeSend() {
@@ -31,6 +31,10 @@ struct ForgetPasswordPage { @@ -31,6 +31,10 @@ struct ForgetPasswordPage {
31 } 31 }
32 } 32 }
33 33
  34 +
  35 +
  36 +
  37 +
34 @State toastText:string = "" 38 @State toastText:string = ""
35 dialogToast: CustomDialogController = new CustomDialogController({ 39 dialogToast: CustomDialogController = new CustomDialogController({
36 builder: CustomToast({ 40 builder: CustomToast({
@@ -80,9 +84,14 @@ struct ForgetPasswordPage { @@ -80,9 +84,14 @@ struct ForgetPasswordPage {
80 } 84 }
81 85
82 aboutToAppear() { 86 aboutToAppear() {
83 - if(StringUtils.isNotEmpty(this.phone) && this.phone.indexOf("****") === -1){  
84 - this.phoneContent = this.phone 87 + let phone = ""
  88 + if(this.params){
  89 + phone = this.params['phone']+ ""
  90 + }
  91 + if(StringUtils.isNotEmpty(phone) && phone.indexOf("****") === -1){
  92 + this.phoneContent = phone
85 } 93 }
  94 +
86 } 95 }
87 96
88 //发送验证码 97 //发送验证码