Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
unidocs-zh
提交
90ac7eb6
unidocs-zh
项目概览
DCloud
/
unidocs-zh
通知
3599
Star
108
Fork
921
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
120
列表
看板
标记
里程碑
合并请求
109
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
unidocs-zh
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
120
Issue
120
列表
看板
标记
里程碑
合并请求
109
合并请求
109
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
90ac7eb6
编写于
3月 22, 2022
作者:
D
DCloud_LXH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore: search page
上级
8b3ca4f3
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
28 addition
and
22 deletion
+28
-22
docs/.vuepress/theme/components/DcloudSearchPage/index.vue
docs/.vuepress/theme/components/DcloudSearchPage/index.vue
+20
-14
docs/.vuepress/theme/components/DcloudSearchPage/postDcloudServer.js
...ess/theme/components/DcloudSearchPage/postDcloudServer.js
+8
-8
未找到文件。
docs/.vuepress/theme/components/DcloudSearchPage/index.vue
浏览文件 @
90ac7eb6
...
...
@@ -65,12 +65,12 @@
</div>
<div
class=
"result-number"
>
<span>
共{{ curHits }}个相关结果
</span>
<span>
{{ resultText }}
</span>
</div>
<div
class=
"search-result"
>
<div
class=
"result-wrap"
>
<
template
v-if=
"isAlgolia
&& resultList.length
"
>
<
template
v-if=
"isAlgolia"
>
<template
v-for=
"item in resultList"
>
<Results
:key=
"item.id"
:title=
"item.title"
:results=
"item.items"
/>
</
template
>
...
...
@@ -180,6 +180,7 @@
]),
categoryIndex
:
0
,
resultList
:
[],
noResult
:
false
,
serverHtml
:
''
,
searchPage
:
0
,
// 跳转页数
...
...
@@ -200,6 +201,11 @@
showPagination
()
{
return
!!
(
this
.
resultList
.
length
&&
this
.
totalPage
>
1
&&
this
.
isAlgolia
);
},
resultText
()
{
return
this
.
noResult
?
`没有找到
${
this
.
currentCategory
.
text
}
相关内容`
:
`
${
this
.
curHits
}
个相关结果`
;
},
},
mounted
()
{
...
...
@@ -278,6 +284,7 @@
items
,
};
});
this
.
noResult
=
!
this
.
resultList
.
length
;
this
.
curHits
=
nbHits
;
this
.
pageSize
=
hitsPerPage
;
this
.
totalPage
=
nbPages
;
...
...
@@ -315,26 +322,24 @@
);
},
searchByServer
(
query
=
''
)
{
async
searchByServer
(
query
=
''
)
{
const
{
tag
}
=
this
.
currentCategory
;
let
postResult
=
Promise
.
resolve
({
html
:
''
,
hits
:
0
});
switch
(
tag
)
{
case
'
ext
'
:
postExt
(
query
).
then
(({
html
,
hits
})
=>
{
this
.
serverHtml
=
html
;
this
.
curHits
=
hits
;
});
postResult
=
postExt
(
query
);
break
;
case
'
ask
'
:
postAsk
(
query
).
then
(({
html
,
hits
})
=>
{
this
.
serverHtml
=
html
;
this
.
curHits
=
hits
;
});
break
;
default
:
postResult
=
postAsk
(
query
);
break
;
}
const
{
html
,
hits
}
=
await
postResult
;
this
.
serverHtml
=
html
;
this
.
curHits
=
hits
;
this
.
noResult
=
!
hits
;
},
mainNavLinkClass
(
index
)
{
...
...
@@ -367,6 +372,7 @@
this
.
curHits
=
0
;
this
.
totalPage
=
0
;
this
.
serverHtml
=
''
;
this
.
noResult
=
false
;
},
onSearchOpen
()
{
...
...
docs/.vuepress/theme/components/DcloudSearchPage/postDcloudServer.js
浏览文件 @
90ac7eb6
...
...
@@ -56,8 +56,8 @@ export async function postAsk(query) {
return
;
}
var
data
=
ret
.
data
;
var
askHtml
=
''
;
let
data
=
ret
.
data
;
let
askHtml
=
''
;
data
.
forEach
(
function
(
item
)
{
askHtml
+=
_renderPost
(
item
,
query
);
});
...
...
@@ -85,9 +85,9 @@ function _renderExt(ext, keyword) {
}
function
_renderPost
(
post
,
value
)
{
var
html
=
''
;
var
commentText
=
''
;
var
tagName
=
'
规范
'
;
let
html
=
''
;
let
commentText
=
''
;
let
tagName
=
'
规范
'
;
// 1,问题;2,文章;默认是规范。
switch
(
post
.
type
)
{
...
...
@@ -130,15 +130,15 @@ function _renderPost(post, value) {
}
function
_handleHTMLString
(
dataString
,
keyword
)
{
var
keywordReg
=
new
RegExp
(
let
keywordReg
=
new
RegExp
(
keyword
.
replace
(
/
[
|
\\
{}()[
\]
^$+*?.
]
/g
,
'
\\
$&
'
),
'
gi
'
);
var
tagStartReg
=
new
RegExp
(
let
tagStartReg
=
new
RegExp
(
'
<span style=
\'
font-weight:bold;color:red
\'
>
'
,
'
g
'
);
var
tagEndReg
=
new
RegExp
(
let
tagEndReg
=
new
RegExp
(
'
</span>
'
,
'
g
'
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录