diff --git a/docs/.vuepress/theme/components/DcloudSearchPage/index.styl b/docs/.vuepress/theme/components/DcloudSearchPage/index.styl
index e08b7a0b567d0a839a40d8500b4d9366c77b6051..7e35861e7a83970ab28ed1b3af6d495b7d4edade 100644
--- a/docs/.vuepress/theme/components/DcloudSearchPage/index.styl
+++ b/docs/.vuepress/theme/components/DcloudSearchPage/index.styl
@@ -107,7 +107,7 @@ $svg-hover-color = #9b9b9b
display flex
justify-content center
align-items center
- margin-top 20px
+ padding-top 20px
font-size 20px
.DocSearch-Logo
@@ -124,6 +124,11 @@ $svg-hover-color = #9b9b9b
margin 0
padding 0
+ .algolia-logo
+ display flex
+ justify-content center
+ padding 10px 0 20px
+
@media (max-width $MQMobile)
#search-container
.search-navbar-header>.main-navbar
diff --git a/docs/.vuepress/theme/components/DcloudSearchPage/index.vue b/docs/.vuepress/theme/components/DcloudSearchPage/index.vue
index 7fd4b4801e2b7a585142428790b8af9191806a91..34aa81608992a610521974c5732ee9002d2e067a 100644
--- a/docs/.vuepress/theme/components/DcloudSearchPage/index.vue
+++ b/docs/.vuepress/theme/components/DcloudSearchPage/index.vue
@@ -42,14 +42,7 @@
-
+
url
@@ -173,11 +160,6 @@
tag: 'ext',
type: 'server',
},
- {
- text: 'DCloud 社区',
- type: 'link',
- link: 'https://ask.dcloud.net.cn/search/q-',
- },
{
text: '原生开发文档',
type: 'link',
@@ -229,7 +211,10 @@
if (val) {
forbidScroll();
document.body.appendChild(this.$el);
- this.$nextTick(() => this.$refs.searchInput.focus());
+ this.$nextTick(() => {
+ this.$refs.searchInput.focus();
+ this.initResultWrapHeight();
+ });
} else {
this.cancel();
forbidScroll(false);
@@ -245,8 +230,14 @@
},
methods: {
- searchLink(link) {
- return link + (link.includes('ask') ? Base64Encode(this.searchValue) : this.searchValue);
+ initResultWrapHeight() {
+ const pageHeight = this.$el.clientHeight;
+ const searchNavbarHeight = document.querySelector('.search-navbar').clientHeight;
+ const resultNumberHeight = document.querySelector('.result-number').clientHeight;
+ const algoliaLogoHeight = document.querySelector('.algolia-logo').clientHeight;
+
+ document.querySelector('.result-wrap').style.minHeight =
+ pageHeight - searchNavbarHeight - resultNumberHeight - algoliaLogoHeight - 20 + 'px';
},
resetSearchPage() {
@@ -349,7 +340,6 @@
},
switchCategory(index) {
- this.curHits = 0;
this.categoryIndex = index;
this.research(1);
},
@@ -359,6 +349,7 @@
this.searchValue = '';
this.curHits = 0;
this.totalPage = 0;
+ this.serverHtml = '';
},
onSearchOpen() {
diff --git a/docs/.vuepress/theme/util/base64Encode.js b/docs/.vuepress/theme/util/base64Encode.js
deleted file mode 100644
index cad67634d2540c4f0961e73bc466bd9c4f6c33a2..0000000000000000000000000000000000000000
--- a/docs/.vuepress/theme/util/base64Encode.js
+++ /dev/null
@@ -1,126 +0,0 @@
-var validBitList = [
- [7],
- [5, 6],
- [4, 6, 6],
- [3, 6, 6, 6],
- [2, 6, 6, 6, 6],
- [1, 6, 6, 6, 6, 6]
-]
-var otherByteBase = 1 << 7
-var b64Info = new Array(6)
-for (var i = 0; i < validBitList.length; i++) {
- var validBit = validBitList[i]
- var firstByteBase
- if (i === 0) {
- firstByteBase = 0
- }
- var fillLength = validBit[0] + 1
- firstByteBase = 255 >> fillLength << fillLength
-
- b64Info[i] = {
- validBit,
- firstByteBase,
- otherByteBase,
- maxValue: Math.pow(2, sum(validBit)) - 1 // 移位会溢出,使用Math.pow计算
- }
-}
-
-function sum(arr) {
- return arr.reduce(function (total, value) {
- return total + value
- }, 0)
-}
-
-function Encoder() {
- this.remainder = 0
- this.remainderBit = 0
- this.utf8ArrLength = 0
- this.result = ''
-}
-
-Encoder.prototype.push = function (utf8Code) {
- this.utf8ArrLength++
- var remainderMoveBit = (6 - this.remainderBit)
- this.remainderBit = 8 - remainderMoveBit
- var b64Value1 = this.remainder << remainderMoveBit
- var b64Value2 = utf8Code >> this.remainderBit
- var b64Value = b64Value1 + b64Value2
- this.remainder = utf8Code - (b64Value2 << this.remainderBit)
- this.result += b64CodeToString(b64Value)
- if (this.remainderBit === 6) {
- this.result += b64CodeToString(this.remainder)
- this.remainder = 0
- this.remainderBit = 0
- }
-}
-
-Encoder.prototype.flush = function () {
- if (this.remainderBit) {
- var b64Value = this.remainder << (6 - this.remainderBit)
- this.result += b64CodeToString(b64Value)
- }
- var eqLength = (3 - (this.utf8ArrLength % 3)) % 3
- this.result += '='.repeat(eqLength)
-}
-
-function charCodeToUtf8(code) {
- var lengthIndex
- for (var i = 0; i < b64Info.length; i++) {
- var maxValue = b64Info[i].maxValue;
- if (code <= maxValue) {
- lengthIndex = i
- break;
- }
- }
- if (lengthIndex === undefined) {
- throw new Error('invalid char code')
- }
- var {
- validBit,
- firstByteBase,
- otherByteBase,
- } = b64Info[lengthIndex]
- var result = []
- for (var i = validBit.length - 1; i >= 0; i--) {
- var base = i === 0 ? firstByteBase : otherByteBase
- var tempCode = code >>> validBit[i]
- result.unshift(base + code - (tempCode << validBit[i]))
- code = tempCode
- }
- return result
-}
-
-export function Base64Encode(str) {
- // 一次循环计算出结果,减少内存占用
- var encoder = new Encoder()
- for (var i = 0; i < str.length; i++) {
- var charCode = str.charCodeAt(i);
- var utf8Arr = charCodeToUtf8(charCode)
- utf8Arr.forEach(function (item) {
- encoder.push(item)
- });
- }
- encoder.flush()
- return encoder.result
-}
-
-function b64CodeToString(code) {
- return String.fromCharCode(uint6ToB64(code))
-}
-
-/**
- * 将base64 code转换为字符对应的char code
- */
-function uint6ToB64(nUint6) {
- return nUint6 < 26 ?
- nUint6 + 65 :
- nUint6 < 52 ?
- nUint6 + 71 :
- nUint6 < 62 ?
- nUint6 - 4 :
- nUint6 === 62 ?
- 43 :
- nUint6 === 63 ?
- 47 :
- 65;
-}
\ No newline at end of file
diff --git a/docs/.vuepress/theme/util/index.js b/docs/.vuepress/theme/util/index.js
index 0c1c9dee20e84cf318ace66ae247954088ece24e..3edc290a49d5b110d04f7ad9a6bcfb8e3b4f836f 100644
--- a/docs/.vuepress/theme/util/index.js
+++ b/docs/.vuepress/theme/util/index.js
@@ -1,7 +1,6 @@
import Vue from 'vue';
export * from './searchUtils';
-export * from './base64Encode';
export const isServer = Vue.prototype.$isServer
export const hashRE = /#.*$/