Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
unidocs-zh
提交
d0ea2a29
unidocs-zh
项目概览
DCloud
/
unidocs-zh
通知
3182
Star
105
Fork
807
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
93
列表
看板
标记
里程碑
合并请求
69
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
unidocs-zh
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
93
Issue
93
列表
看板
标记
里程碑
合并请求
69
合并请求
69
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
d0ea2a29
编写于
3月 18, 2022
作者:
D
DCloud_LXH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
wip: dcloud search page
上级
6b977787
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
22 addition
and
153 deletion
+22
-153
docs/.vuepress/theme/components/DcloudSearchPage/index.styl
docs/.vuepress/theme/components/DcloudSearchPage/index.styl
+6
-1
docs/.vuepress/theme/components/DcloudSearchPage/index.vue
docs/.vuepress/theme/components/DcloudSearchPage/index.vue
+16
-25
docs/.vuepress/theme/util/base64Encode.js
docs/.vuepress/theme/util/base64Encode.js
+0
-126
docs/.vuepress/theme/util/index.js
docs/.vuepress/theme/util/index.js
+0
-1
未找到文件。
docs/.vuepress/theme/components/DcloudSearchPage/index.styl
浏览文件 @
d0ea2a29
...
...
@@ -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
...
...
docs/.vuepress/theme/components/DcloudSearchPage/index.vue
浏览文件 @
d0ea2a29
...
...
@@ -42,14 +42,7 @@
<div
class=
"main-navbar-links"
>
<template
v-for=
"(item, index) in category"
>
<div
:class=
"mainNavLinkClass(index)"
:key=
"item.text"
>
<MainNavbarLink
:key=
"item.text"
v-if=
"item.link"
:item=
"
{
...item,
link: searchLink(item.link),
}"
/>
<MainNavbarLink
v-if=
"item.link"
:key=
"item.text"
:item=
"item"
/>
<a
v-else
href=
"javascript:;"
@
click=
"switchCategory(index)"
>
{{
item
.
text
}}
</a>
...
...
@@ -85,7 +78,7 @@
</
template
>
</div>
<div
v-if=
"isAlgolia"
style=
"display: flex; justify-content: center; margin: 10px 0 20px
"
>
<div
v-if=
"isAlgolia"
class=
"algolia-logo
"
>
<div
class=
"DocSearch-Logo"
>
<a
href=
"https://www.algolia.com/ref/docsearch/?utm_source=uniapp.dcloud.io&utm_medium=referral&utm_content=powered_by&utm_campaign=docsearch"
...
...
@@ -124,13 +117,7 @@
import
MainNavbarLink
from
'
../MainNavbarLink.vue
'
;
import
{
search
as
searchClient
}
from
'
./searchClient
'
;
import
{
postExt
,
postAsk
}
from
'
./postDcloudServer
'
;
import
{
forbidScroll
,
removeHighlightTags
,
debounce
,
isEditingContent
,
Base64Encode
,
}
from
'
../../util
'
;
import
{
forbidScroll
,
removeHighlightTags
,
debounce
,
isEditingContent
}
from
'
../../util
'
;
const
resolveRoutePathFromUrl
=
(
url
,
base
=
'
/
'
)
=>
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
()
{
...
...
docs/.vuepress/theme/util/base64Encode.js
已删除
100644 → 0
浏览文件 @
6b977787
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
docs/.vuepress/theme/util/index.js
浏览文件 @
d0ea2a29
import
Vue
from
'
vue
'
;
export
*
from
'
./searchUtils
'
;
export
*
from
'
./base64Encode
'
;
export
const
isServer
=
Vue
.
prototype
.
$isServer
export
const
hashRE
=
/#.*$/
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录