zhangbo1_wd

解决搜索页面,appfreeze、crash问题

@@ -66,31 +66,31 @@ export struct SearchComponent { @@ -66,31 +66,31 @@ export struct SearchComponent {
66 this.breakpointSystem.unregister(); 66 this.breakpointSystem.unregister();
67 } 67 }
68 68
69 - getRelatedSearchContent() {  
70 - if (StringUtils.isNotEmpty(this.searchText)) {  
71 - SearcherAboutDataModel.getRelatedSearchContentData(encodeURI(this.searchText), getContext(this)).then((value) => { 69 + getRelatedSearchContent(searchText: string) {
  70 + if (StringUtils.isNotEmpty(searchText)) {
  71 + SearcherAboutDataModel.getRelatedSearchContentData(encodeURI(searchText), getContext(this)).then((value) => {
72 if (value != null && value.length > 0) { 72 if (value != null && value.length > 0) {
73 this.relatedSearchContentsData = [] 73 this.relatedSearchContentsData = []
74 value.forEach(item => { 74 value.forEach(item => {
75 let tempValue: string = item 75 let tempValue: string = item
76 let tempArr: string[] = [] 76 let tempArr: string[] = []
77 - if (tempValue.indexOf(this.searchText) === -1) { 77 + if (tempValue.indexOf(searchText) === -1) {
78 tempArr.push(item) 78 tempArr.push(item)
79 this.relatedSearchContentsData.push(new SearchRelatedItem(item, tempArr)) 79 this.relatedSearchContentsData.push(new SearchRelatedItem(item, tempArr))
80 } else { 80 } else {
81 - while (tempValue.indexOf(this.searchText) != -1) {  
82 - let index = tempValue.indexOf(this.searchText) 81 + while (tempValue.indexOf(searchText) != -1) {
  82 + let index = tempValue.indexOf(searchText)
83 if (index === 0) { 83 if (index === 0) {
84 try { 84 try {
85 - tempArr.push(this.searchText)  
86 - tempValue = tempValue.substring(this.searchText.length, tempValue.length) 85 + tempArr.push(searchText)
  86 + tempValue = tempValue.substring(searchText.length, tempValue.length)
87 } catch (e) { 87 } catch (e) {
88 } 88 }
89 } else { 89 } else {
90 try { 90 try {
91 tempArr.push(tempValue.substring(0, index)) 91 tempArr.push(tempValue.substring(0, index))
92 - tempArr.push(this.searchText)  
93 - tempValue = tempValue.substring(index + this.searchText.length, tempValue.length) 92 + tempArr.push(searchText)
  93 + tempValue = tempValue.substring(index + searchText.length, tempValue.length)
94 } catch (e) { 94 } catch (e) {
95 } 95 }
96 } 96 }
@@ -356,7 +356,7 @@ export struct SearchComponent { @@ -356,7 +356,7 @@ export struct SearchComponent {
356 this.resetSearch() 356 this.resetSearch()
357 } else { 357 } else {
358 if (this.hasInputContent) { 358 if (this.hasInputContent) {
359 - this.getRelatedSearchContent() 359 + this.getRelatedSearchContent(value)
360 } 360 }
361 } 361 }
362 }) 362 })