提交 2bccdf58 编写于 作者: X xjh22222228

fix(#61): optimize search

上级 7fec439c
......@@ -42,12 +42,6 @@ export function randomInt(max: number) {
export function fuzzySearch(navList: INavProps[], keyword: string) {
let searchResultList = [{ nav: [] }]
let url: null|string = null
try {
const { hostname } = new URL(keyword)
url = hostname
} catch {}
function f(arr?: any[]) {
arr = arr || navList
......@@ -63,6 +57,7 @@ export function fuzzySearch(navList: INavProps[], keyword: string) {
if (item.name) {
const name = item.name.toLowerCase()
const desc = item.desc.toLowerCase()
const url = item.url.toLowerCase()
const search = keyword.toLowerCase()
const urls = Object.values(item.urls || {})
......@@ -80,11 +75,11 @@ export function fuzzySearch(navList: INavProps[], keyword: string) {
} catch (err) {}
}
if (item.url?.includes?.(url)) {
if (url?.includes?.(keyword.toLowerCase())) {
searchResultList[0].nav.push(item)
}
const find = urls.some((item: string) => item.includes(url))
const find = urls.some((item: string) => item.includes(keyword))
if (find) {
searchResultList[0].nav.push(item)
}
......
......@@ -27,7 +27,7 @@
</nz-sider>
<nz-layout class="inner-layout">
<nz-content class="content" id="content">
<div class="search dark-bg-deep">
<div class="search dark-bg-deep dark-border-color">
<app-search-engine></app-search-engine>
</div>
......
......@@ -19,13 +19,13 @@ $sideWidth: 200px;
left: 201px;
right: 0;
text-align: center;
background-color: #fff;
}
&.fixed {
.search {
top: 0;
border-bottom: 1px solid #30363d;
background-color: #fff;
border-bottom: 1px solid #ccc;
}
}
}
......
......@@ -74,7 +74,7 @@ export default class HomeComponent {
if (!this.contentEl) {
this.contentEl = document.getElementById('content')
}
if (y > 100) {
if (y > 70) {
this.contentEl.classList.add('fixed')
} else {
this.contentEl.classList.remove('fixed')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册