Skip to content

Commit dcdbbae

Browse files
committed
refactor:添加搜索框
1 parent 3569f58 commit dcdbbae

2 files changed

Lines changed: 57 additions & 10 deletions

File tree

vue/src/assets/blog.css

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1896,6 +1896,55 @@ body {
18961896
display: inline-block;
18971897
}
18981898

1899+
.site-search-bar {
1900+
display: inline-flex;
1901+
align-items: center;
1902+
gap: 8px;
1903+
flex: 1 1 220px;
1904+
max-width: 320px;
1905+
min-width: 140px;
1906+
height: 36px;
1907+
padding: 0 14px;
1908+
border-radius: 999px;
1909+
background: #f0f0f0;
1910+
border: 1px solid transparent;
1911+
color: var(--muted);
1912+
cursor: text;
1913+
transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
1914+
box-sizing: border-box;
1915+
}
1916+
1917+
[data-theme='dark'] .site-search-bar {
1918+
background: #1e1e22;
1919+
border-color: #2a2a2e;
1920+
}
1921+
1922+
.site-search-bar:hover {
1923+
background: #e8e8e8;
1924+
border-color: #d0d0d0;
1925+
}
1926+
1927+
[data-theme='dark'] .site-search-bar:hover {
1928+
background: #26262b;
1929+
border-color: #3a3a3e;
1930+
}
1931+
1932+
.site-search-bar-icon {
1933+
flex-shrink: 0;
1934+
display: block;
1935+
opacity: 0.5;
1936+
}
1937+
1938+
.site-search-bar-placeholder {
1939+
font-size: 13px;
1940+
color: inherit;
1941+
opacity: 0.5;
1942+
white-space: nowrap;
1943+
overflow: hidden;
1944+
text-overflow: ellipsis;
1945+
line-height: 1;
1946+
}
1947+
18991948
.site-nav {
19001949
display: inline-flex;
19011950
align-items: center;

vue/src/components/BlogHeader.vue

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@
66
<span class="site-brand-text">{{ (siteConfig && siteConfig.blog_name) || '烧仙草冰室' }}</span>
77
</router-link>
88

9+
<div class="site-search-bar" aria-label="搜索">
10+
<svg class="site-search-bar-icon" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
11+
<circle cx="11" cy="11" r="8" />
12+
<path d="M21 21l-4.35-4.35" />
13+
</svg>
14+
<span class="site-search-bar-placeholder">搜索文章...</span>
15+
</div>
16+
917
<nav class="site-nav" aria-label="站点导航">
1018
<router-link to="/" class="site-nav-link" active-class="active">
1119
<span class="site-nav-ico" aria-hidden="true">
@@ -26,16 +34,6 @@
2634
文章
2735
</router-link>
2836

29-
<router-link to="/search" class="site-nav-link" active-class="active">
30-
<span class="site-nav-ico" aria-hidden="true">
31-
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
32-
<circle cx="11" cy="11" r="8" />
33-
<path d="M21 21l-4.35-4.35" />
34-
</svg>
35-
</span>
36-
搜索
37-
</router-link>
38-
3937
<router-link to="/feedback" class="site-nav-link" active-class="active">
4038
<span class="site-nav-ico" aria-hidden="true">
4139
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">

0 commit comments

Comments
 (0)