Demo:搜索新增搜索结果列表显示
This commit is contained in:
parent
83c9d16d2b
commit
834651d471
@ -318,7 +318,8 @@ export default {
|
|||||||
replacePlaceholder: 'Please enter replacement content',
|
replacePlaceholder: 'Please enter replacement content',
|
||||||
replace: 'Replace',
|
replace: 'Replace',
|
||||||
replaceAll: 'Replace all',
|
replaceAll: 'Replace all',
|
||||||
cancel: 'Cancel'
|
cancel: 'Cancel',
|
||||||
|
noResult: 'No result'
|
||||||
},
|
},
|
||||||
nodeIconSidebar: {
|
nodeIconSidebar: {
|
||||||
title: 'Icon/Sticker',
|
title: 'Icon/Sticker',
|
||||||
|
|||||||
@ -310,7 +310,8 @@ export default {
|
|||||||
replacePlaceholder: '请输入替换内容',
|
replacePlaceholder: '请输入替换内容',
|
||||||
replace: '替换',
|
replace: '替换',
|
||||||
replaceAll: '全部替换',
|
replaceAll: '全部替换',
|
||||||
cancel: '取消'
|
cancel: '取消',
|
||||||
|
noResult: '暂无结果'
|
||||||
},
|
},
|
||||||
nodeIconSidebar: {
|
nodeIconSidebar: {
|
||||||
title: '图标/贴纸',
|
title: '图标/贴纸',
|
||||||
|
|||||||
@ -54,14 +54,20 @@
|
|||||||
<div
|
<div
|
||||||
class="searchResultList"
|
class="searchResultList"
|
||||||
:style="{ height: searchResultListHeight + 'px' }"
|
:style="{ height: searchResultListHeight + 'px' }"
|
||||||
|
v-if="showSearchResultList"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="searchResultItem"
|
class="searchResultItem"
|
||||||
v-for="item in searchResultList"
|
v-for="(item, index) in searchResultList"
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
:title="item.name"
|
:title="item.name"
|
||||||
v-html="item.text"
|
v-html="item.text"
|
||||||
|
@click.stop="onSearchResultItemClick(index)"
|
||||||
></div>
|
></div>
|
||||||
|
<div class="empty" v-if="searchResultList.length <= 0">
|
||||||
|
<span class="iconfont iconwushuju"></span>
|
||||||
|
<span class="text">{{ $t('search.noResult') }}</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -88,7 +94,8 @@ export default {
|
|||||||
total: 0,
|
total: 0,
|
||||||
showSearchInfo: false,
|
showSearchInfo: false,
|
||||||
searchResultListHeight: 0,
|
searchResultListHeight: 0,
|
||||||
searchResultList: []
|
searchResultList: [],
|
||||||
|
showSearchResultList: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -180,9 +187,8 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
onSearchNext() {
|
onSearchNext() {
|
||||||
this.mindMap.search.search(this.searchText, () => {
|
this.showSearchResultList = true
|
||||||
this.$refs.searchInputRef.focus()
|
this.mindMap.search.search(this.searchText)
|
||||||
})
|
|
||||||
},
|
},
|
||||||
|
|
||||||
replace() {
|
replace() {
|
||||||
@ -195,6 +201,7 @@ export default {
|
|||||||
|
|
||||||
close() {
|
close() {
|
||||||
this.show = false
|
this.show = false
|
||||||
|
this.showSearchResultList = false
|
||||||
this.showSearchInfo = false
|
this.showSearchInfo = false
|
||||||
this.total = 0
|
this.total = 0
|
||||||
this.currentIndex = 0
|
this.currentIndex = 0
|
||||||
@ -212,10 +219,9 @@ export default {
|
|||||||
name = getTextFromHtml(name)
|
name = getTextFromHtml(name)
|
||||||
}
|
}
|
||||||
const reg = new RegExp(`${this.searchText.trim()}`, 'g')
|
const reg = new RegExp(`${this.searchText.trim()}`, 'g')
|
||||||
name.replace(reg, (a, b, c) => {
|
const text = name.replace(reg, a => {
|
||||||
console.log(a, b, c)
|
return `<span class="match">${a}</span>`
|
||||||
})
|
})
|
||||||
const text = ''
|
|
||||||
return {
|
return {
|
||||||
data: item,
|
data: item,
|
||||||
id,
|
id,
|
||||||
@ -227,6 +233,10 @@ export default {
|
|||||||
|
|
||||||
setSearchResultListHeight() {
|
setSearchResultListHeight() {
|
||||||
this.searchResultListHeight = window.innerHeight - 267 - 24
|
this.searchResultListHeight = window.innerHeight - 267 - 24
|
||||||
|
},
|
||||||
|
|
||||||
|
onSearchResultItemClick(index) {
|
||||||
|
this.mindMap.search.jump(index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -305,15 +315,44 @@ export default {
|
|||||||
border-radius: 12px;
|
border-radius: 12px;
|
||||||
margin-top: 5px;
|
margin-top: 5px;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
|
padding: 12px 0;
|
||||||
|
|
||||||
.searchResultItem {
|
.searchResultItem {
|
||||||
height: 30px;
|
height: 30px;
|
||||||
|
line-height: 30px;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
|
padding: 0 12px;
|
||||||
|
font-size: 14px;
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
.match {
|
&:hover {
|
||||||
|
background-color: #f2f4f7;
|
||||||
|
}
|
||||||
|
|
||||||
|
/deep/.match {
|
||||||
|
color: #409eff;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.empty {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
|
||||||
|
.iconfont {
|
||||||
|
font-size: 50px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text {
|
||||||
|
font-size: 14px;
|
||||||
|
color: rgba(26, 26, 26, 0.8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user