全文检索入口调整

This commit is contained in:
结发受长生 2019-07-10 23:42:33 +08:00
parent 3439b8d34b
commit 22aa1b322e
6 changed files with 27 additions and 17 deletions

View File

@ -4,6 +4,7 @@
<canvas id="live2d" width="520" height="480" @mouseover="linkMouseover('waifu')" style="width: 260px;height: 240px;"></canvas>
</div>
<div class="waifu-tool" v-show="waifu.showTools">
<span class="icon icon-search" @mouseover="linkMouseover('tools.search')" @click="toolsClick('tools.search')"></span>
<span class="icon icon-eye" @mouseover="linkMouseover('tools.eye')" @click="toolsClick('tools.eye')"></span>
<span class="icon icon-comment-o" @mouseover="linkMouseover('tools.chart')" @click="toolsClick('tools.chart')"></span>
<span class="icon icon-camera" @mouseover="linkMouseover('tools.photo')" @click="toolsClick('tools.photo')"></span>

View File

@ -10,16 +10,15 @@
</div>
</div>
<div class="search-result">
<div class="search-result-item" v-for="(item,index) in fullTextSearchItems" :key="index">
<a v-text="item.title" :href="themeConfig.root + item.path"></a>
<div v-html="item.content"></div>
</div>
<div class="more-item tip" v-show="fullTextSearchItems.hasMore" @click="loadSearchResult">
<div class="more-item tip" v-show="fullTextSearch.hasMore" @click="loadSearchResult">
<i class="icon icon-chevron-up"></i>
</div>
<div class="tip" v-show="fullTextSearchItems.isLoading || fullTextSearchTip"
v-text="fullTextSearchTip || '正在搜索...'"></div>
<div class="tip" v-show="fullTextSearch.isLoading || fullTextSearch.tip"
v-text="fullTextSearch.tip || '正在搜索...'"></div>
</div>
</div>
</div>

View File

@ -26,7 +26,7 @@
<i class="icon icon-close" @click="searchItems.splice(index,1)"></i>
</span>
<input class="search-ipt" v-model="search" @blur="addSearchItem(search)" @keydown="searchKeydown" type="text" placeholder="<%=__('search') %>…">
<i class="icon icon-search" @click="openFullTextSearch"></i>
<i class="icon icon-search" @click="addSearchItem(search)"></i>
</div>
<div class="widget tagcloud search-tag">
<div>

View File

@ -9,6 +9,7 @@
"weibo": "发现主人出没地点!",
"rss": "订阅就可以看到最新的文章啦",
"mail": "这里是主人的联系方式",
"tools.search": "在这里搜索所有文章",
"tools.eye": "深夜时要爱护眼睛呀",
"tools.chart": "猜猜我要说些什么",
"tools.photo": "你要给我拍照呀,一二三~茄子~~",

View File

@ -56,7 +56,7 @@
}
.waifu-tool {
color: $colorA;
top: 100px;
top: 80px;
right: 60px;
font-size: 14px;
position: absolute;

View File

@ -15,7 +15,7 @@ function setScrollZero() {
})
}
var waifuTipTimer = null, fullTextSearchTimer = null
new Vue({
const vm = new Vue({
el: '#container',
data: {
isCtnShow: false,
@ -31,10 +31,12 @@ new Vue({
fullTextSearch: {
pageNum: 1,
limit: 10,
isLoading: false,
tip: undefined,
hasMore: false
},
fullTextSearchWords: null,
fullTextSearchItems: [],
fullTextSearchTip: undefined,
waifu: {
tip: null, // 提示语文字
tipOpacity: 0, // 提示语框透明度
@ -96,23 +98,26 @@ new Vue({
},
loadSearchResult() {
this.fullTextSearch.pageNum ++
this.fullTextSearchItems.isLoading = true
this.fullTextSearchTip = undefined
let params = Object.assign({}, this.fullTextSearch)
params.words = this.fullTextSearchWords
this.fullTextSearch.isLoading = true
this.fullTextSearch.tip = undefined
let params = {
pageNum: this.fullTextSearch.pageNum,
limit: this.fullTextSearch.limit,
words: this.fullTextSearchWords
}
axios.get(window.themeConfig.root + 'api/common/search', {params}).then(res => {
this.fullTextSearchItems.isLoading = false
this.fullTextSearch.isLoading = false
fullTextSearchTimer = null
let result = res.data
if(!Array.isArray(result.data) || !result.data.length) {
this.fullTextSearchTip = '未搜索到匹配文章'
this.fullTextSearch.tip = '未搜索到匹配文章'
} else {
this.fullTextSearchItems.push(...result.data)
}
this.fullTextSearchItems.hasMore = (result.total > this.fullTextSearch.pageNum * this.fullTextSearch.limit)
}).catch(err => {
this.fullTextSearchTip = '加载失败, 请刷新重试'
this.fullTextSearchItems.isLoading = false
this.fullTextSearch.tip = '加载失败, 请刷新重试'
this.fullTextSearch.isLoading = false
throw err
})
},
@ -156,7 +161,7 @@ new Vue({
fullTextSearchWords (newVal, oldVal) {
this.fullTextSearchItems.hasMore = false
this.fullTextSearchItems.isLoading = false
this.fullTextSearchTip = undefined
this.fullTextSearch.tip = undefined
this.fullTextSearchItems.splice(0, this.fullTextSearchItems.length)
if(fullTextSearchTimer) {
clearTimeout(fullTextSearchTimer)
@ -274,6 +279,10 @@ const waifuTools = {
axios.get(`${window.themeConfig.root}api/common/hitokoto?length=40&format=json`).then(res => {
this.showMessage(res.data.hitokoto + (res.data.from?`  ——${res.data.from}`:''))
})
},
'tools.search'() {
// 打开全文检索Modal
vm.openFullTextSearch()
}
}