yuzhilin
@@ -28,7 +28,7 @@ struct PeopleShipHomePage { @@ -28,7 +28,7 @@ struct PeopleShipHomePage {
28 // 总滑动空间 28 // 总滑动空间
29 scroller: Scroller = new Scroller() 29 scroller: Scroller = new Scroller()
30 // 顶部透明度 30 // 顶部透明度
31 - @State topOpacity: number = 0 31 + @Watch('topOpacityChange') @State topOpacity: number = 0
32 //发布数量 32 //发布数量
33 @State publishCount: number = 0 33 @State publishCount: number = 0
34 // 是否关注 34 // 是否关注
@@ -42,6 +42,22 @@ struct PeopleShipHomePage { @@ -42,6 +42,22 @@ struct PeopleShipHomePage {
42 @State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0 42 @State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0
43 @State isConnectNetwork : boolean = NetworkUtil.isNetConnected() 43 @State isConnectNetwork : boolean = NetworkUtil.isNetConnected()
44 44
  45 + onPageShow(): void {
  46 + WindowModel.shared.setWindowSystemBarProperties({ statusBarContentColor: '#ffffff'})
  47 + }
  48 +
  49 + onPageHide(): void {
  50 + WindowModel.shared.setWindowSystemBarProperties({ statusBarContentColor: '#000000', })
  51 + }
  52 +
  53 + topOpacityChange(){
  54 + if(this.topOpacity > 0.8){
  55 + WindowModel.shared.setWindowSystemBarProperties({ statusBarContentColor: '#000000', })
  56 + }else{
  57 + WindowModel.shared.setWindowSystemBarProperties({ statusBarContentColor: '#ffffff'})
  58 + }
  59 + }
  60 +
45 build() { 61 build() {
46 if(this.isConnectNetwork){ 62 if(this.isConnectNetwork){
47 Stack({ alignContent: Alignment.TopStart }) { 63 Stack({ alignContent: Alignment.TopStart }) {
@@ -50,7 +66,8 @@ struct PeopleShipHomePage { @@ -50,7 +66,8 @@ struct PeopleShipHomePage {
50 Image($r('app.media.home_page_bg')) 66 Image($r('app.media.home_page_bg'))
51 .width('100%') 67 .width('100%')
52 .height('120vp') 68 .height('120vp')
53 - .objectFit(ImageFit.Fill) 69 + .objectFit(ImageFit.Auto)
  70 + .objectRepeat(ImageRepeat.NoRepeat)
54 .backgroundColor(Color.White) 71 .backgroundColor(Color.White)
55 .visibility(this.isLoading ? Visibility.None : Visibility.Visible) 72 .visibility(this.isLoading ? Visibility.None : Visibility.Visible)
56 .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP]) 73 .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP])
@@ -40,7 +40,9 @@ export struct PeopleShipHomePageTopComponent { @@ -40,7 +40,9 @@ export struct PeopleShipHomePageTopComponent {
40 Image($r('app.media.home_page_bg')) 40 Image($r('app.media.home_page_bg'))
41 .width('100%') 41 .width('100%')
42 .height('48vp') 42 .height('48vp')
43 - .objectFit(ImageFit.Fill) 43 + .objectFit(ImageFit.Auto)
  44 + .objectRepeat(ImageRepeat.NoRepeat)
  45 + .objectFit(ImageFit.Auto)
44 .backgroundColor(Color.White) 46 .backgroundColor(Color.White)
45 // 头像和名称 47 // 头像和名称
46 Row() { 48 Row() {
@@ -27,32 +27,60 @@ export class SearchShowRed { @@ -27,32 +27,60 @@ export class SearchShowRed {
27 res.push(content); 27 res.push(content);
28 } 28 }
29 29
30 - SearchShowRed.formatTitle(html, res, 0, textArr); 30 + console.log('SearchShowRed-res', JSON.stringify(res))
  31 +
  32 + SearchShowRed.formatTitle(
  33 + html.replaceAll('<em>', '').replaceAll('</em>', ''),
  34 + res,
  35 + 0,
  36 + textArr
  37 + );
31 } 38 }
32 39
33 const titleInitRes: titleInitRes = { 40 const titleInitRes: titleInitRes = {
34 titleMarked, 41 titleMarked,
35 textArr 42 textArr
36 } 43 }
  44 + console.log('SearchShowRed-titleInitRes', JSON.stringify(titleInitRes))
37 return titleInitRes 45 return titleInitRes
38 } 46 }
39 47
40 private static formatTitle(textStr: string, matchArr: string[], index: number, textArr: textItem[]) { 48 private static formatTitle(textStr: string, matchArr: string[], index: number, textArr: textItem[]) {
41 const item: string = matchArr[index]; 49 const item: string = matchArr[index];
42 - const arr = textStr.split(item);  
43 - arr.forEach((str: string, ind: number) => { 50 + if (!item) {
  51 + textArr.push({
  52 + content: textStr,
  53 + isRed: false
  54 + })
  55 + return;
  56 + }
  57 + const ind = textStr.indexOf(item);
  58 + const len = item.length;
44 if (ind === 0) { 59 if (ind === 0) {
45 textArr.push({ 60 textArr.push({
46 - content: str.replaceAll('<em>', '').replaceAll('</em>', ''), 61 + content: item,
  62 + isRed: true
  63 + })
  64 + SearchShowRed.formatTitle(textStr.slice(len), matchArr, index + 1, textArr);
  65 + } else if (ind + len === textStr.length) {
  66 + textArr.push({
  67 + content: textStr.slice(0, ind),
47 isRed: false 68 isRed: false
48 - } as textItem) 69 + })
49 textArr.push({ 70 textArr.push({
50 content: item, 71 content: item,
51 isRed: true 72 isRed: true
52 }) 73 })
53 - } else if (ind === 1) {  
54 - SearchShowRed.formatTitle(str, matchArr, index + 1, textArr)  
55 - } 74 + } else {
  75 + textArr.push({
  76 + content: textStr.slice(0, ind),
  77 + isRed: false
56 }) 78 })
  79 + textArr.push({
  80 + content: item,
  81 + isRed: true
  82 + })
  83 + SearchShowRed.formatTitle(textStr.slice(ind + len), matchArr, index + 1, textArr);
  84 + }
57 } 85 }
58 } 86 }