提交 3c9a73ac 编写于 作者: D DCloud_LXH

wip: search page

上级 19c08bf4
...@@ -5,8 +5,8 @@ $svg-hover-color = #9b9b9b ...@@ -5,8 +5,8 @@ $svg-hover-color = #9b9b9b
position relative position relative
overflow auto overflow auto
position fixed position fixed
width 100vw width 100%
height 100vh height 100%
left 0 left 0
top 0 top 0
z-index 200 z-index 200
...@@ -195,6 +195,7 @@ $svg-hover-color = #9b9b9b ...@@ -195,6 +195,7 @@ $svg-hover-color = #9b9b9b
display flex display flex
p.aw-text p.aw-text
font-weight normal
margin 0 margin 0
display inline-flex display inline-flex
......
...@@ -173,14 +173,13 @@ ...@@ -173,14 +173,13 @@
]), ]),
categoryIndex: 0, categoryIndex: 0,
resultList: [], resultList: [],
serverHtml: '',
searchPage: 0, // 跳转页数 searchPage: 0, // 跳转页数
curHits: 0, // 当前搜索结果总条数 curHits: 0, // 当前搜索结果总条数
totalPage: 0, // 搜索结果总共页数 totalPage: 0, // 搜索结果总共页数
curPage: 1, // 当前页 curPage: 1, // 当前页
pageSize: 0, // 每页条数 pageSize: 0, // 每页条数
serverHtml: '',
}; };
}, },
...@@ -235,9 +234,16 @@ ...@@ -235,9 +234,16 @@
const searchNavbarHeight = document.querySelector('.search-navbar').clientHeight; const searchNavbarHeight = document.querySelector('.search-navbar').clientHeight;
const resultNumberHeight = document.querySelector('.result-number').clientHeight; const resultNumberHeight = document.querySelector('.result-number').clientHeight;
const algoliaLogoHeight = document.querySelector('.algolia-logo').clientHeight; const algoliaLogoHeight = document.querySelector('.algolia-logo').clientHeight;
const searchPagination = 36;
document.querySelector('.result-wrap').style.minHeight = document.querySelector('.result-wrap').style.minHeight =
pageHeight - searchNavbarHeight - resultNumberHeight - algoliaLogoHeight - 20 + 'px'; pageHeight -
searchNavbarHeight -
resultNumberHeight -
algoliaLogoHeight -
searchPagination -
20 +
'px';
}, },
resetSearchPage() { resetSearchPage() {
...@@ -250,8 +256,8 @@ ...@@ -250,8 +256,8 @@
}, },
search() { search() {
if (!this.searchValue) return; if (!this.searchValue || !this.searchValue.trim().length) return;
const { text, type } = this.currentCategory; const { type } = this.currentCategory;
switch (type) { switch (type) {
case 'algolia': case 'algolia':
this.searchByAlgolia(this.searchValue, this.searchPage).then( this.searchByAlgolia(this.searchValue, this.searchPage).then(
...@@ -307,15 +313,13 @@ ...@@ -307,15 +313,13 @@
switch (tag) { switch (tag) {
case 'ext': case 'ext':
postExt(query).then(({ html, hits }) => { postExt(query).then(({ html, hits }) => {
this.serverHtml = ''; this.serverHtml = html;
this.serverHtml += html;
this.curHits = hits; this.curHits = hits;
}); });
break; break;
case 'ask': case 'ask':
postAsk(query).then(({ html, hits }) => { postAsk(query).then(({ html, hits }) => {
this.serverHtml = ''; this.serverHtml = html;
this.serverHtml += html;
this.curHits = hits; this.curHits = hits;
}); });
break; break;
......
const isProduction = process.env.NODE_ENV === "production" const isProduction = process.env.NODE_ENV === "production"
const isMock = false const isMock = true
import mock from './mock' import mock from './mock'
function ajax(url = '', method = 'get',) { function ajax(url = '', method = 'get',) {
...@@ -71,10 +71,12 @@ function _renderExt(ext, keyword) { ...@@ -71,10 +71,12 @@ function _renderExt(ext, keyword) {
return `<div class="matching-post"> return `<div class="matching-post">
<a href="${ext.url}" target="_blank"> <a href="${ext.url}" target="_blank">
<div class="post-wrapper"> <div class="post-wrapper">
<p class="aw-text"> <h2>
<span class="post-tag">插件</span> <p class="aw-text">
</p> <span class="post-tag">插件</span>
<h2>${_handleHTMLString(ext.name, keyword)}</h2> </p>
${_handleHTMLString(ext.name, keyword)}
</h2>
</div> </div>
<p>${ext.total_download}次下载</p> <p>${ext.total_download}次下载</p>
<p>${_handleHTMLString(ext.description, keyword)}</p> <p>${_handleHTMLString(ext.description, keyword)}</p>
...@@ -103,17 +105,23 @@ function _renderPost(post, value) { ...@@ -103,17 +105,23 @@ function _renderPost(post, value) {
} }
html += `<div class="matching-post"> html += `<div class="matching-post">
<a href="${post.url}" target="_blank"><div class="post-wrapper"> <a href="${post.url}" target="_blank">
<p class="aw-text"><span class="post-tag">${tagName}</span></p> <div class="post-wrapper">
<h2>${post.title}</h2></div>` <h2>
/* html += '<div class="matching-post">\n'; <p class="aw-text">
html += `<a href="${post.url}" target="_blank"><div class="post-wrapper">`; <span class="post-tag">${tagName}</span>
html += `<p class="aw-text"><span class="post-tag">${tagName}</span></p>` </p>
html += `\n<h2>${post.title}</h2></div>`; */ ${post.title}
</h2>
</div>`
if (!!value) { if (!!value) {
commentText = post.type === 'questions' ? '回复' : '评论'; commentText = post.type === 'questions' ? '回复' : '评论';
html += `<p>${post.comment_count}${commentText}<span class="aw-text-space">-</span>${post.view_count}次浏览</p>`; html += `<p>
${post.comment_count}${commentText}
<span class="aw-text-space">-</span>
${post.view_count}次浏览
</p>`;
} }
html += `\n<p>${post.content}</p>\n</a>\n</div>`; html += `\n<p>${post.content}</p>\n</a>\n</div>`;
......
...@@ -35,11 +35,8 @@ ...@@ -35,11 +35,8 @@
} : {}" } : {}"
> >
<a class="switch-version" href="javascript:void(0)" @click="switchVersion">回到旧版</a> <a class="switch-version" href="javascript:void(0)" @click="switchVersion">回到旧版</a>
<DcloudSearchPage ref="dcloudSearchPage" v-if="isAlgoliaSearch" :options="algolia"/> <DcloudSearchPage v-if="isAlgoliaSearch" ref="dcloudSearchPage" :options="algolia"/>
<AlgoliaSearchBox <AlgoliaSearchBox v-if="isAlgoliaSearch" />
v-if="isAlgoliaSearch"
:options="algolia"
/>
<SearchBox v-else-if="$site.themeConfig.search !== false && $page.frontmatter.search !== false" /> <SearchBox v-else-if="$site.themeConfig.search !== false && $page.frontmatter.search !== false" />
</div> </div>
</div> </div>
......
...@@ -92,7 +92,8 @@ $navbar-logo-height = $navbar-main-navbar-height - 2rem ...@@ -92,7 +92,8 @@ $navbar-logo-height = $navbar-main-navbar-height - 2rem
justify-content flex-end justify-content flex-end
.mobile-main-navbar .mobile-main-navbar
display inline-block display inline-block
padding-right 75px // padding-right 75px
padding-right 165px
a a
color $navbar-a-color color $navbar-a-color
.mobile-links__btn:after .mobile-links__btn:after
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册