From c71f3110fb415c5da940f3436d5c8ff3244659c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8A=B1=E8=A3=A4=E8=A1=A9?= Date: Wed, 13 Feb 2019 15:09:14 +0800 Subject: [PATCH] feature[Navbar]: add header-search component (#1591) * init * init * refactor search function by fuse * fix bug * fix bug * tweak --- package.json | 1 + src/components/HeaderSearch/index.vue | 187 +++++++++++++++++++++++++ src/icons/svg/search.svg | 1 + src/views/layout/components/Navbar.vue | 35 +++-- 4 files changed, 212 insertions(+), 12 deletions(-) create mode 100644 src/components/HeaderSearch/index.vue create mode 100644 src/icons/svg/search.svg diff --git a/package.json b/package.json index 83e93bce..5854b8d6 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,7 @@ "echarts": "4.1.0", "element-ui": "2.4.11", "file-saver": "1.3.8", + "fuse.js": "3.4.2", "js-cookie": "2.2.0", "jsonlint": "1.6.3", "jszip": "3.1.5", diff --git a/src/components/HeaderSearch/index.vue b/src/components/HeaderSearch/index.vue new file mode 100644 index 00000000..ab0d556a --- /dev/null +++ b/src/components/HeaderSearch/index.vue @@ -0,0 +1,187 @@ + + + + + diff --git a/src/icons/svg/search.svg b/src/icons/svg/search.svg new file mode 100644 index 00000000..84233dda --- /dev/null +++ b/src/icons/svg/search.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/views/layout/components/Navbar.vue b/src/views/layout/components/Navbar.vue index 018ef0f9..dcb09ec1 100644 --- a/src/views/layout/components/Navbar.vue +++ b/src/views/layout/components/Navbar.vue @@ -6,24 +6,26 @@
- +
@@ -57,6 +59,7 @@ import Screenfull from '@/components/Screenfull' import SizeSelect from '@/components/SizeSelect' import LangSelect from '@/components/LangSelect' import ThemePicker from '@/components/ThemePicker' +import Search from '@/components/HeaderSearch' export default { components: { @@ -66,7 +69,8 @@ export default { Screenfull, SizeSelect, LangSelect, - ThemePicker + ThemePicker, + Search }, computed: { ...mapGetters([ @@ -100,6 +104,7 @@ export default { float: left; cursor: pointer; transition: background .3s; + &:hover { background: rgba(0, 0, 0, .025) } @@ -124,24 +129,30 @@ export default { } .right-menu-item { - cursor: pointer; display: inline-block; padding: 0 8px; height: 100%; - font-size: 20px; + font-size: 18px; color: #5a5e66; vertical-align: text-bottom; - transition: background .3s; - &:hover { - background: rgba(0, 0, 0, .025) + + &.hover-effect { + cursor: pointer; + transition: background .3s; + + &:hover { + background: rgba(0, 0, 0, .025) + } } } .avatar-container { margin-right: 30px; + .avatar-wrapper { margin-top: 5px; position: relative; + .user-avatar { cursor: pointer; width: 40px;